Skip to content

Commit 3446dd0

Browse files
committed
gvfs-helper: create tool to fetch objects using the GVFS Protocol
Create gvfs-helper. This is a helper tool to use the GVFS Protocol REST API to fetch objects and configuration data from a GVFS cache-server or Git server. This tool uses libcurl to send object requests to either server. This tool creates loose objects and/or packfiles. Create gvfs-helper-client. This code resides within git proper and uses the sub-process API to manage gvfs-helper as a long-running background process. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 98b842c commit 3446dd0

File tree

17 files changed

+2842
-3
lines changed

17 files changed

+2842
-3
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/checkout.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "wt-status.h"
2828
#include "xdiff-interface.h"
2929
#include "packfile.h"
30+
#include "gvfs-helper-client.h"
3031

3132
static const char * const checkout_usage[] = {
3233
N_("git checkout [<options>] <branch>"),
@@ -1033,6 +1034,13 @@ static int switch_branches(const struct checkout_opts *opts,
10331034
int flag, writeout_error = 0;
10341035
int do_merge = 1;
10351036

1037+
#if 0
1038+
ghc__pre_checkout_commit(the_repository,
1039+
new_branch_info->commit,
1040+
opts->show_progress);
1041+
exit(1);
1042+
#endif
1043+
10361044
trace2_cmd_mode("branch");
10371045

10381046
memset(&old_branch_info, 0, sizeof(old_branch_info));

‎builtin/index-pack.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
@@ -893,6 +893,9 @@ extern int precomposed_unicode;
893893
extern int protect_hfs;
894894
extern int protect_ntfs;
895895
extern const char *core_fsmonitor;
896+
extern int core_use_gvfs_helper;
897+
extern const char *gvfs_cache_server_url;
898+
extern const char *gvfs_shared_cache_pathname;
896899

897900
int core_apply_sparse_checkout;
898901
int core_sparse_checkout_cone;

‎config.c‎

Lines changed: 28 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,25 @@ 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+
git_config_string(&gvfs_shared_cache_pathname, var, value);
1517+
return 0;
1518+
}
1519+
1520+
return 0;
1521+
}
1522+
14981523
int git_default_config(const char *var, const char *value, void *cb)
14991524
{
15001525
if (starts_with(var, "core."))
@@ -1541,6 +1566,9 @@ int git_default_config(const char *var, const char *value, void *cb)
15411566
return 0;
15421567
}
15431568

1569+
if (starts_with(var, "gvfs."))
1570+
return git_default_gvfs_config(var, value);
1571+
15441572
/* Add other config variables here and to Documentation/config.txt. */
15451573
return 0;
15461574
}

‎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
*/

0 commit comments

Comments
 (0)