Skip to content

Commit 3c62776

Browse files
jeffhostetlerdscho
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 cbfef64 commit 3c62776

File tree

15 files changed

+2840
-3
lines changed

15 files changed

+2840
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
/git-gc
7878
/git-get-tar-commit-id
7979
/git-grep
80+
/git-gvfs-helper
8081
/git-hash-object
8182
/git-help
8283
/git-hook

Documentation/config.txt

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

438438
include::config/guitool.txt[]
439439

440+
include::config/gvfs.txt[]
441+
440442
include::config/help.txt[]
441443

442444
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
@@ -969,6 +969,7 @@ LIB_OBJS += gpg-interface.o
969969
LIB_OBJS += graph.o
970970
LIB_OBJS += grep.o
971971
LIB_OBJS += gvfs.o
972+
LIB_OBJS += gvfs-helper-client.o
972973
LIB_OBJS += hash-lookup.o
973974
LIB_OBJS += hashmap.o
974975
LIB_OBJS += help.o
@@ -1502,6 +1503,8 @@ else
15021503
endif
15031504
BASIC_CFLAGS += $(CURL_CFLAGS)
15041505

1506+
PROGRAM_OBJS += gvfs-helper.o
1507+
15051508
REMOTE_CURL_PRIMARY = git-remote-http$X
15061509
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
15071510
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2734,6 +2737,10 @@ contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
27342737
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
27352738
$(filter %.o,$^) $(LIBS)
27362739

2740+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2741+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2742+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2743+
27372744
$(LIB_FILE): $(LIB_OBJS)
27382745
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
27392746

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,9 @@ extern int core_gvfs;
10791079
extern int precomposed_unicode;
10801080
extern int protect_hfs;
10811081
extern int protect_ntfs;
1082+
extern int core_use_gvfs_helper;
1083+
extern const char *gvfs_cache_server_url;
1084+
extern const char *gvfs_shared_cache_pathname;
10821085

10831086
extern int core_apply_sparse_checkout;
10841087
extern int core_sparse_checkout_cone;

config.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "color.h"
2525
#include "refs.h"
2626
#include "worktree.h"
27+
#include "transport.h"
2728

2829
struct config_source {
2930
struct config_source *prev;
@@ -1735,6 +1736,11 @@ int git_default_core_config(const char *var, const char *value, void *cb)
17351736
return 0;
17361737
}
17371738

1739+
if (!strcmp(var, "core.usegvfshelper")) {
1740+
core_use_gvfs_helper = git_config_bool(var, value);
1741+
return 0;
1742+
}
1743+
17381744
if (!strcmp(var, "core.sparsecheckout")) {
17391745
/* virtual file system relies on the sparse checkout logic so force it on */
17401746
if (core_virtualfilesystem)
@@ -1877,6 +1883,37 @@ static int git_default_mailmap_config(const char *var, const char *value)
18771883
return 0;
18781884
}
18791885

1886+
static int git_default_gvfs_config(const char *var, const char *value)
1887+
{
1888+
if (!strcmp(var, "gvfs.cache-server")) {
1889+
const char *v2 = NULL;
1890+
1891+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1892+
gvfs_cache_server_url = transport_anonymize_url(v2);
1893+
free((char*)v2);
1894+
return 0;
1895+
}
1896+
1897+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1898+
struct strbuf buf = STRBUF_INIT;
1899+
strbuf_addstr(&buf, value);
1900+
if (strbuf_normalize_path(&buf) < 0) {
1901+
/*
1902+
* Pretend it wasn't set. This will cause us to
1903+
* fallback to ".git/objects" effectively.
1904+
*/
1905+
strbuf_release(&buf);
1906+
return 0;
1907+
}
1908+
strbuf_trim_trailing_dir_sep(&buf);
1909+
1910+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
1911+
return 0;
1912+
}
1913+
1914+
return 0;
1915+
}
1916+
18801917
int git_default_config(const char *var, const char *value, void *cb)
18811918
{
18821919
if (starts_with(var, "core."))
@@ -1926,6 +1963,9 @@ int git_default_config(const char *var, const char *value, void *cb)
19261963
if (starts_with(var, "sparse."))
19271964
return git_default_sparse_config(var, value);
19281965

1966+
if (starts_with(var, "gvfs."))
1967+
return git_default_gvfs_config(var, value);
1968+
19291969
/* Add other config variables here and to Documentation/config.txt. */
19301970
return 0;
19311971
}

contrib/buildsystems/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ if(NOT CURL_FOUND)
643643
add_compile_definitions(NO_CURL)
644644
message(WARNING "git-http-push and git-http-fetch will not be built")
645645
else()
646-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
646+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
647647
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
648648
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
649649
endif()
@@ -808,6 +808,9 @@ if(CURL_FOUND)
808808
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
809809
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
810810
endif()
811+
812+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
813+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
811814
endif()
812815

813816
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
@@ -89,6 +89,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
8989
#define PROTECT_NTFS_DEFAULT 1
9090
#endif
9191
int protect_ntfs = PROTECT_NTFS_DEFAULT;
92+
int core_use_gvfs_helper;
93+
const char *gvfs_cache_server_url;
94+
const char *gvfs_shared_cache_pathname;
9295

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

0 commit comments

Comments
 (0)