Skip to content

Commit

Permalink
Merge pull request git-for-windows#191 from jeffhostetler/sc223-gvfs-…
Browse files Browse the repository at this point in the history
…helper

gvfs-helper: create tool to fetch objects using the GVFS Protocol
  • Loading branch information
jeffhostetler authored Oct 3, 2019
2 parents d28da65 + 80ead37 commit 8f53588
Show file tree
Hide file tree
Showing 22 changed files with 2,925 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
/git-gc
/git-get-tar-commit-id
/git-grep
/git-gvfs-helper
/git-hash-object
/git-help
/git-http-backend
Expand Down
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ include::config/gui.txt[]

include::config/guitool.txt[]

include::config/gvfs.txt[]

include::config/help.txt[]

include::config/http.txt[]
Expand Down
3 changes: 3 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ core.gvfs::
flag just blocks them from occurring at all.
--

core.useGvfsHelper::
TODO

core.sparseCheckout::
Enable "sparse checkout" feature. If "false", then sparse-checkout
is disabled. If "true", then sparse-checkout is enabled with the full
Expand Down
5 changes: 5 additions & 0 deletions Documentation/config/gvfs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gvfs.cache-server::
TODO

gvfs.sharedcache::
TODO
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o
LIB_OBJS += grep.o
LIB_OBJS += gvfs.o
LIB_OBJS += gvfs-helper-client.o
LIB_OBJS += hashmap.o
LIB_OBJS += linear-assignment.o
LIB_OBJS += help.o
Expand Down Expand Up @@ -1359,6 +1360,8 @@ else
CURL_LIBCURL += $(shell $(CURL_CONFIG) --libs)
endif

PROGRAM_OBJS += gvfs-helper.o

REMOTE_CURL_PRIMARY = git-remote-http$X
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
Expand Down Expand Up @@ -2469,6 +2472,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

$(LIB_FILE): $(LIB_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

Expand Down
4 changes: 2 additions & 2 deletions builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
collision_test_needed =
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
has_object_file_with_flags(oid, OBJECT_INFO_FOR_PREFETCH);
read_unlock();
}

Expand Down Expand Up @@ -1352,7 +1352,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
sorted_by_pos[i] = &ref_deltas[i];
QSORT(sorted_by_pos, nr_ref_deltas, delta_pos_compare);

if (repository_format_partial_clone) {
if (repository_format_partial_clone || core_use_gvfs_helper) {
/*
* Prefetch the delta bases.
*/
Expand Down
3 changes: 3 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,9 @@ extern int precomposed_unicode;
extern int protect_hfs;
extern int protect_ntfs;
extern const char *core_fsmonitor;
extern int core_use_gvfs_helper;
extern const char *gvfs_cache_server_url;
extern const char *gvfs_shared_cache_pathname;

int core_apply_sparse_checkout;
int core_sparse_checkout_cone;
Expand Down
40 changes: 40 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "color.h"
#include "refs.h"
#include "gvfs.h"
#include "transport.h"

struct config_source {
struct config_source *prev;
Expand Down Expand Up @@ -1365,6 +1366,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
return 0;
}

if (!strcmp(var, "core.usegvfshelper")) {
core_use_gvfs_helper = git_config_bool(var, value);
return 0;
}

if (!strcmp(var, "core.sparsecheckout")) {
/* virtual file system relies on the sparse checkout logic so force it on */
if (core_virtualfilesystem)
Expand Down Expand Up @@ -1495,6 +1501,37 @@ static int git_default_mailmap_config(const char *var, const char *value)
return 0;
}

static int git_default_gvfs_config(const char *var, const char *value)
{
if (!strcmp(var, "gvfs.cache-server")) {
const char *v2 = NULL;

if (!git_config_string(&v2, var, value) && v2 && *v2)
gvfs_cache_server_url = transport_anonymize_url(v2);
free((char*)v2);
return 0;
}

if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, value);
if (strbuf_normalize_path(&buf) < 0) {
/*
* Pretend it wasn't set. This will cause us to
* fallback to ".git/objects" effectively.
*/
strbuf_release(&buf);
return 0;
}
strbuf_trim_trailing_dir_sep(&buf);

gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
return 0;
}

return 0;
}

int git_default_config(const char *var, const char *value, void *cb)
{
if (starts_with(var, "core."))
Expand Down Expand Up @@ -1541,6 +1578,9 @@ int git_default_config(const char *var, const char *value, void *cb)
return 0;
}

if (starts_with(var, "gvfs."))
return git_default_gvfs_config(var, value);

/* Add other config variables here and to Documentation/config.txt. */
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ static int run_credential_helper(struct credential *c,
else
helper.no_stdout = 1;

helper.trace2_child_class = "cred";

if (start_command(&helper) < 0)
return -1;

Expand Down
2 changes: 1 addition & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -6499,7 +6499,7 @@ static void add_if_missing(struct repository *r,
void diffcore_std(struct diff_options *options)
{
if (options->repo == the_repository &&
repository_format_partial_clone) {
(repository_format_partial_clone || core_use_gvfs_helper)) {
/*
* Prefetch the diff pairs that are about to be flushed.
*/
Expand Down
3 changes: 3 additions & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
#endif
int protect_ntfs = PROTECT_NTFS_DEFAULT;
const char *core_fsmonitor;
int core_use_gvfs_helper;
const char *gvfs_cache_server_url;
const char *gvfs_shared_cache_pathname;

/*
* The character that begins a commented line in user-editable file
Expand Down
9 changes: 9 additions & 0 deletions fetch-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "strbuf.h"
#include "transport.h"
#include "fetch-object.h"
#include "gvfs-helper-client.h"

static void fetch_refs(const char *remote_name, struct ref *ref)
{
Expand All @@ -29,6 +30,14 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
struct ref *ref = NULL;
int i;

if (core_use_gvfs_helper) {
enum ghc__created ghc = GHC__CREATED__NOTHING;

ghc__queue_oid_array(oids, oid_nr);
ghc__drain_queue(&ghc);
return;
}

for (i = 0; i < oid_nr; i++) {
struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
oidcpy(&new_ref->old_oid, &oids[i]);
Expand Down
Loading

0 comments on commit 8f53588

Please sign in to comment.