Skip to content

Commit 58a4bd9

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 79853d0 commit 58a4bd9

File tree

18 files changed

+2892
-4
lines changed

18 files changed

+2892
-4
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.adoc

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

450450
include::config/guitool.adoc[]
451451

452+
include::config/gvfs.adoc[]
453+
452454
include::config/help.adoc[]
453455

454456
include::config/http.adoc[]

Documentation/config/core.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ core.gvfs::
811811
flag just blocks them from occurring at all.
812812
--
813813

814+
core.useGvfsHelper::
815+
TODO
816+
814817
core.sparseCheckout::
815818
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
816819
for more information.

Documentation/config/gvfs.adoc

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

Documentation/lint-manpages.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ check_missing_docs () (
2727
git-init-db) continue;;
2828
git-remote-*) continue;;
2929
git-stage) continue;;
30+
git-gvfs-helper) continue;;
3031
git-legacy-*) continue;;
3132
git-?*--?* ) continue ;;
3233
esac

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,7 @@ LIB_OBJS += gpg-interface.o
11631163
LIB_OBJS += graph.o
11641164
LIB_OBJS += grep.o
11651165
LIB_OBJS += gvfs.o
1166+
LIB_OBJS += gvfs-helper-client.o
11661167
LIB_OBJS += hash-lookup.o
11671168
LIB_OBJS += hash.o
11681169
LIB_OBJS += hashmap.o
@@ -1770,6 +1771,8 @@ endif
17701771
endif
17711772
BASIC_CFLAGS += $(CURL_CFLAGS)
17721773

1774+
PROGRAM_OBJS += gvfs-helper.o
1775+
17731776
REMOTE_CURL_PRIMARY = git-remote-http$X
17741777
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
17751778
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -3026,6 +3029,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
30263029
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
30273030
$(filter %.o,$^) $(LIBS)
30283031

3032+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
3033+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
3034+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
3035+
30293036
$(LIB_FILE): $(LIB_OBJS)
30303037
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
30313038

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "trace2.h"
3838
#include "wildmatch.h"
3939
#include "write-or-die.h"
40+
#include "transport.h"
4041

4142
struct config_source {
4243
struct config_source *prev;

contrib/buildsystems/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ if(NOT CURL_FOUND)
635635
add_compile_definitions(NO_CURL)
636636
message(WARNING "git-http-push and git-http-fetch will not be built")
637637
else()
638-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
638+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
639639
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
640640
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
641641
endif()
@@ -811,6 +811,9 @@ if(CURL_FOUND)
811811
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
812812
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
813813
endif()
814+
815+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
816+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
814817
endif()
815818

816819
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")

environment.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "quote.h"
3535
#include "chdir-notify.h"
3636
#include "setup.h"
37+
#include "transport.h"
3738
#include "ws.h"
3839
#include "write-or-die.h"
3940

@@ -128,6 +129,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
128129
#define PROTECT_NTFS_DEFAULT 1
129130
#endif
130131
int protect_ntfs = PROTECT_NTFS_DEFAULT;
132+
int core_use_gvfs_helper;
133+
char *gvfs_cache_server_url;
134+
const char *gvfs_shared_cache_pathname;
131135

132136
/*
133137
* The character that begins a commented line in user-editable file
@@ -558,6 +562,11 @@ int git_default_core_config(const char *var, const char *value,
558562
return 0;
559563
}
560564

565+
if (!strcmp(var, "core.usegvfshelper")) {
566+
core_use_gvfs_helper = git_config_bool(var, value);
567+
return 0;
568+
}
569+
561570
if (!strcmp(var, "core.sparsecheckout")) {
562571
/* virtual file system relies on the sparse checkout logic so force it on */
563572
if (core_virtualfilesystem)
@@ -704,6 +713,39 @@ static int git_default_mailmap_config(const char *var, const char *value)
704713
return 0;
705714
}
706715

716+
static int git_default_gvfs_config(const char *var, const char *value)
717+
{
718+
if (!strcmp(var, "gvfs.cache-server")) {
719+
char *v2 = NULL;
720+
721+
if (!git_config_string(&v2, var, value) && v2 && *v2) {
722+
free(gvfs_cache_server_url);
723+
gvfs_cache_server_url = transport_anonymize_url(v2);
724+
}
725+
free(v2);
726+
return 0;
727+
}
728+
729+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
730+
struct strbuf buf = STRBUF_INIT;
731+
strbuf_addstr(&buf, value);
732+
if (strbuf_normalize_path(&buf) < 0) {
733+
/*
734+
* Pretend it wasn't set. This will cause us to
735+
* fallback to ".git/objects" effectively.
736+
*/
737+
strbuf_release(&buf);
738+
return 0;
739+
}
740+
strbuf_trim_trailing_dir_sep(&buf);
741+
742+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
743+
return 0;
744+
}
745+
746+
return 0;
747+
}
748+
707749
static int git_default_attr_config(const char *var, const char *value)
708750
{
709751
if (!strcmp(var, "attr.tree")) {
@@ -771,6 +813,9 @@ int git_default_config(const char *var, const char *value,
771813
if (starts_with(var, "sparse."))
772814
return git_default_sparse_config(var, value);
773815

816+
if (starts_with(var, "gvfs."))
817+
return git_default_gvfs_config(var, value);
818+
774819
/* Add other config variables here and to Documentation/config.adoc. */
775820
return 0;
776821
}

environment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ extern char *core_virtualfilesystem;
164164
extern int precomposed_unicode;
165165
extern int protect_hfs;
166166
extern int protect_ntfs;
167+
extern int core_use_gvfs_helper;
168+
extern char *gvfs_cache_server_url;
169+
extern const char *gvfs_shared_cache_pathname;
167170

168171
extern int core_apply_sparse_checkout;
169172
extern int core_sparse_checkout_cone;

0 commit comments

Comments
 (0)