Skip to content

Commit 8f53588

Browse files
Merge pull request git-for-windows#191 from jeffhostetler/sc223-gvfs-helper
gvfs-helper: create tool to fetch objects using the GVFS Protocol
2 parents d28da65 + 80ead37 commit 8f53588

22 files changed

+2925
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
/git-gc
7373
/git-get-tar-commit-id
7474
/git-grep
75+
/git-gvfs-helper
7576
/git-hash-object
7677
/git-help
7778
/git-http-backend

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ include::config/gui.txt[]
369369

370370
include::config/guitool.txt[]
371371

372+
include::config/gvfs.txt[]
373+
372374
include::config/help.txt[]
373375

374376
include::config/http.txt[]

Documentation/config/core.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ core.gvfs::
659659
flag just blocks them from occurring at all.
660660
--
661661

662+
core.useGvfsHelper::
663+
TODO
664+
662665
core.sparseCheckout::
663666
Enable "sparse checkout" feature. If "false", then sparse-checkout
664667
is disabled. If "true", then sparse-checkout is enabled with the full

Documentation/config/gvfs.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
gvfs.cache-server::
2+
TODO
3+
4+
gvfs.sharedcache::
5+
TODO

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ LIB_OBJS += gpg-interface.o
898898
LIB_OBJS += graph.o
899899
LIB_OBJS += grep.o
900900
LIB_OBJS += gvfs.o
901+
LIB_OBJS += gvfs-helper-client.o
901902
LIB_OBJS += hashmap.o
902903
LIB_OBJS += linear-assignment.o
903904
LIB_OBJS += help.o
@@ -1359,6 +1360,8 @@ else
13591360
CURL_LIBCURL += $(shell $(CURL_CONFIG) --libs)
13601361
endif
13611362

1363+
PROGRAM_OBJS += gvfs-helper.o
1364+
13621365
REMOTE_CURL_PRIMARY = git-remote-http$X
13631366
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
13641367
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2469,6 +2472,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
24692472
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
24702473
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
24712474

2475+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2476+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2477+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2478+
24722479
$(LIB_FILE): $(LIB_OBJS)
24732480
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
24742481

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
781781
if (startup_info->have_repository) {
782782
read_lock();
783783
collision_test_needed =
784-
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
784+
has_object_file_with_flags(oid, OBJECT_INFO_FOR_PREFETCH);
785785
read_unlock();
786786
}
787787

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

1355-
if (repository_format_partial_clone) {
1355+
if (repository_format_partial_clone || core_use_gvfs_helper) {
13561356
/*
13571357
* Prefetch the delta bases.
13581358
*/

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,9 @@ extern int precomposed_unicode;
895895
extern int protect_hfs;
896896
extern int protect_ntfs;
897897
extern const char *core_fsmonitor;
898+
extern int core_use_gvfs_helper;
899+
extern const char *gvfs_cache_server_url;
900+
extern const char *gvfs_shared_cache_pathname;
898901

899902
int core_apply_sparse_checkout;
900903
int core_sparse_checkout_cone;

config.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "color.h"
2222
#include "refs.h"
2323
#include "gvfs.h"
24+
#include "transport.h"
2425

2526
struct config_source {
2627
struct config_source *prev;
@@ -1365,6 +1366,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
13651366
return 0;
13661367
}
13671368

1369+
if (!strcmp(var, "core.usegvfshelper")) {
1370+
core_use_gvfs_helper = git_config_bool(var, value);
1371+
return 0;
1372+
}
1373+
13681374
if (!strcmp(var, "core.sparsecheckout")) {
13691375
/* virtual file system relies on the sparse checkout logic so force it on */
13701376
if (core_virtualfilesystem)
@@ -1495,6 +1501,37 @@ static int git_default_mailmap_config(const char *var, const char *value)
14951501
return 0;
14961502
}
14971503

1504+
static int git_default_gvfs_config(const char *var, const char *value)
1505+
{
1506+
if (!strcmp(var, "gvfs.cache-server")) {
1507+
const char *v2 = NULL;
1508+
1509+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1510+
gvfs_cache_server_url = transport_anonymize_url(v2);
1511+
free((char*)v2);
1512+
return 0;
1513+
}
1514+
1515+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1516+
struct strbuf buf = STRBUF_INIT;
1517+
strbuf_addstr(&buf, value);
1518+
if (strbuf_normalize_path(&buf) < 0) {
1519+
/*
1520+
* Pretend it wasn't set. This will cause us to
1521+
* fallback to ".git/objects" effectively.
1522+
*/
1523+
strbuf_release(&buf);
1524+
return 0;
1525+
}
1526+
strbuf_trim_trailing_dir_sep(&buf);
1527+
1528+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
1529+
return 0;
1530+
}
1531+
1532+
return 0;
1533+
}
1534+
14981535
int git_default_config(const char *var, const char *value, void *cb)
14991536
{
15001537
if (starts_with(var, "core."))
@@ -1541,6 +1578,9 @@ int git_default_config(const char *var, const char *value, void *cb)
15411578
return 0;
15421579
}
15431580

1581+
if (starts_with(var, "gvfs."))
1582+
return git_default_gvfs_config(var, value);
1583+
15441584
/* Add other config variables here and to Documentation/config.txt. */
15451585
return 0;
15461586
}

credential.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ static int run_credential_helper(struct credential *c,
224224
else
225225
helper.no_stdout = 1;
226226

227+
helper.trace2_child_class = "cred";
228+
227229
if (start_command(&helper) < 0)
228230
return -1;
229231

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6499,7 +6499,7 @@ static void add_if_missing(struct repository *r,
64996499
void diffcore_std(struct diff_options *options)
65006500
{
65016501
if (options->repo == the_repository &&
6502-
repository_format_partial_clone) {
6502+
(repository_format_partial_clone || core_use_gvfs_helper)) {
65036503
/*
65046504
* Prefetch the diff pairs that are about to be flushed.
65056505
*/

environment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
8888
#endif
8989
int protect_ntfs = PROTECT_NTFS_DEFAULT;
9090
const char *core_fsmonitor;
91+
int core_use_gvfs_helper;
92+
const char *gvfs_cache_server_url;
93+
const char *gvfs_shared_cache_pathname;
9194

9295
/*
9396
* The character that begins a commented line in user-editable file

fetch-object.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "strbuf.h"
55
#include "transport.h"
66
#include "fetch-object.h"
7+
#include "gvfs-helper-client.h"
78

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

33+
if (core_use_gvfs_helper) {
34+
enum ghc__created ghc = GHC__CREATED__NOTHING;
35+
36+
ghc__queue_oid_array(oids, oid_nr);
37+
ghc__drain_queue(&ghc);
38+
return;
39+
}
40+
3241
for (i = 0; i < oid_nr; i++) {
3342
struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
3443
oidcpy(&new_ref->old_oid, &oids[i]);

0 commit comments

Comments
 (0)