Skip to content

Commit 138169e

Browse files
jeffhostetlervdye
authored andcommitted
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 <jeffhost@microsoft.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent 99d876a commit 138169e

File tree

15 files changed

+2851
-3
lines changed

15 files changed

+2851
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
/git-gc
7474
/git-get-tar-commit-id
7575
/git-grep
76+
/git-gvfs-helper
7677
/git-hash-object
7778
/git-help
7879
/git-hook

Documentation/config.txt

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

442442
include::config/guitool.txt[]
443443

444+
include::config/gvfs.txt[]
445+
444446
include::config/help.txt[]
445447

446448
include::config/http.txt[]

Documentation/config/core.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,9 @@ core.gvfs::
778778
flag just blocks them from occurring at all.
779779
--
780780

781+
core.useGvfsHelper::
782+
TODO
783+
781784
core.sparseCheckout::
782785
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
783786
for more information.

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
@@ -1043,6 +1043,7 @@ LIB_OBJS += gpg-interface.o
10431043
LIB_OBJS += graph.o
10441044
LIB_OBJS += grep.o
10451045
LIB_OBJS += gvfs.o
1046+
LIB_OBJS += gvfs-helper-client.o
10461047
LIB_OBJS += hash-lookup.o
10471048
LIB_OBJS += hashmap.o
10481049
LIB_OBJS += help.o
@@ -1631,6 +1632,8 @@ endif
16311632
endif
16321633
BASIC_CFLAGS += $(CURL_CFLAGS)
16331634

1635+
PROGRAM_OBJS += gvfs-helper.o
1636+
16341637
REMOTE_CURL_PRIMARY = git-remote-http$X
16351638
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
16361639
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2872,6 +2875,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
28722875
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
28732876
$(filter %.o,$^) $(LIBS)
28742877

2878+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
2879+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2880+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2881+
28752882
$(LIB_FILE): $(LIB_OBJS)
28762883
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
28772884

config.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "ws.h"
4040
#include "wrapper.h"
4141
#include "write-or-die.h"
42+
#include "transport.h"
4243

4344
struct config_source {
4445
struct config_source *prev;
@@ -1820,6 +1821,11 @@ int git_default_core_config(const char *var, const char *value, void *cb)
18201821
return 0;
18211822
}
18221823

1824+
if (!strcmp(var, "core.usegvfshelper")) {
1825+
core_use_gvfs_helper = git_config_bool(var, value);
1826+
return 0;
1827+
}
1828+
18231829
if (!strcmp(var, "core.sparsecheckout")) {
18241830
/* virtual file system relies on the sparse checkout logic so force it on */
18251831
if (core_virtualfilesystem)
@@ -1962,6 +1968,37 @@ static int git_default_mailmap_config(const char *var, const char *value)
19621968
return 0;
19631969
}
19641970

1971+
static int git_default_gvfs_config(const char *var, const char *value)
1972+
{
1973+
if (!strcmp(var, "gvfs.cache-server")) {
1974+
const char *v2 = NULL;
1975+
1976+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1977+
gvfs_cache_server_url = transport_anonymize_url(v2);
1978+
free((char*)v2);
1979+
return 0;
1980+
}
1981+
1982+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1983+
struct strbuf buf = STRBUF_INIT;
1984+
strbuf_addstr(&buf, value);
1985+
if (strbuf_normalize_path(&buf) < 0) {
1986+
/*
1987+
* Pretend it wasn't set. This will cause us to
1988+
* fallback to ".git/objects" effectively.
1989+
*/
1990+
strbuf_release(&buf);
1991+
return 0;
1992+
}
1993+
strbuf_trim_trailing_dir_sep(&buf);
1994+
1995+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
1996+
return 0;
1997+
}
1998+
1999+
return 0;
2000+
}
2001+
19652002
int git_default_config(const char *var, const char *value, void *cb)
19662003
{
19672004
if (starts_with(var, "core."))
@@ -2011,6 +2048,9 @@ int git_default_config(const char *var, const char *value, void *cb)
20112048
if (starts_with(var, "sparse."))
20122049
return git_default_sparse_config(var, value);
20132050

2051+
if (starts_with(var, "gvfs."))
2052+
return git_default_gvfs_config(var, value);
2053+
20142054
/* Add other config variables here and to Documentation/config.txt. */
20152055
return 0;
20162056
}

contrib/buildsystems/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ if(NOT CURL_FOUND)
648648
add_compile_definitions(NO_CURL)
649649
message(WARNING "git-http-push and git-http-fetch will not be built")
650650
else()
651-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
651+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
652652
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
653653
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
654654
endif()
@@ -817,6 +817,9 @@ if(CURL_FOUND)
817817
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
818818
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
819819
endif()
820+
821+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
822+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
820823
endif()
821824

822825
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")

environment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
9696
#define PROTECT_NTFS_DEFAULT 1
9797
#endif
9898
int protect_ntfs = PROTECT_NTFS_DEFAULT;
99+
int core_use_gvfs_helper;
100+
const char *gvfs_cache_server_url;
101+
const char *gvfs_shared_cache_pathname;
99102

100103
/*
101104
* The character that begins a commented line in user-editable file

environment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ extern int core_gvfs;
152152
extern int precomposed_unicode;
153153
extern int protect_hfs;
154154
extern int protect_ntfs;
155+
extern int core_use_gvfs_helper;
156+
extern const char *gvfs_cache_server_url;
157+
extern const char *gvfs_shared_cache_pathname;
155158

156159
extern int core_apply_sparse_checkout;
157160
extern int core_sparse_checkout_cone;

0 commit comments

Comments
 (0)