Skip to content

Commit f568365

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 84a1cf8 commit f568365

18 files changed

Lines changed: 2866 additions & 3 deletions

‎.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
@@ -812,6 +812,9 @@ core.gvfs::
812812
flag just blocks them from occurring at all.
813813
--
814814

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

‎Documentation/config/gvfs.adoc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
gvfs.cache-server::
2+
When set, redirect all GVFS Protocol requests to this base URL instead
3+
of the origin server.
4+
5+
gvfs.sharedcache::
6+
When set, place all object data downloaded via the GVFS Protocol into
7+
this Git alternate.

‎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
@@ -1173,6 +1173,7 @@ LIB_OBJS += gpg-interface.o
11731173
LIB_OBJS += graph.o
11741174
LIB_OBJS += grep.o
11751175
LIB_OBJS += gvfs.o
1176+
LIB_OBJS += gvfs-helper-client.o
11761177
LIB_OBJS += hash-lookup.o
11771178
LIB_OBJS += hash.o
11781179
LIB_OBJS += hashmap.o
@@ -1810,6 +1811,8 @@ endif
18101811
endif
18111812
BASIC_CFLAGS += $(CURL_CFLAGS)
18121813

1814+
PROGRAM_OBJS += gvfs-helper.o
1815+
18131816
REMOTE_CURL_PRIMARY = git-remote-http$X
18141817
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
18151818
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -3070,6 +3073,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
30703073
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
30713074
$(filter %.o,$^) $(LIBS)
30723075

3076+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
3077+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
3078+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
3079+
30733080
$(LIB_FILE): $(LIB_OBJS)
30743081
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
30753082

‎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
@@ -638,7 +638,7 @@ if(NOT CURL_FOUND)
638638
add_compile_definitions(NO_CURL)
639639
message(WARNING "git-http-push and git-http-fetch will not be built")
640640
else()
641-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
641+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
642642
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
643643
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
644644
endif()
@@ -814,6 +814,9 @@ if(CURL_FOUND)
814814
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
815815
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
816816
endif()
817+
818+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
819+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
817820
endif()
818821

819822
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

@@ -92,6 +93,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
9293
#define PROTECT_NTFS_DEFAULT 1
9394
#endif
9495
int protect_ntfs = PROTECT_NTFS_DEFAULT;
96+
int core_use_gvfs_helper;
97+
char *gvfs_cache_server_url;
98+
const char *gvfs_shared_cache_pathname;
9599

96100
/*
97101
* The character that begins a commented line in user-editable file
@@ -522,6 +526,11 @@ int git_default_core_config(const char *var, const char *value,
522526
return 0;
523527
}
524528

529+
if (!strcmp(var, "core.usegvfshelper")) {
530+
core_use_gvfs_helper = git_config_bool(var, value);
531+
return 0;
532+
}
533+
525534
if (!strcmp(var, "core.sparsecheckout")) {
526535
/* virtual file system relies on the sparse checkout logic so force it on */
527536
if (core_virtualfilesystem)
@@ -663,6 +672,39 @@ static int git_default_mailmap_config(const char *var, const char *value)
663672
return 0;
664673
}
665674

675+
static int git_default_gvfs_config(const char *var, const char *value)
676+
{
677+
if (!strcmp(var, "gvfs.cache-server")) {
678+
char *v2 = NULL;
679+
680+
if (!git_config_string(&v2, var, value) && v2 && *v2) {
681+
free(gvfs_cache_server_url);
682+
gvfs_cache_server_url = transport_anonymize_url(v2);
683+
}
684+
free(v2);
685+
return 0;
686+
}
687+
688+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
689+
struct strbuf buf = STRBUF_INIT;
690+
strbuf_addstr(&buf, value);
691+
if (strbuf_normalize_path(&buf) < 0) {
692+
/*
693+
* Pretend it wasn't set. This will cause us to
694+
* fallback to ".git/objects" effectively.
695+
*/
696+
strbuf_release(&buf);
697+
return 0;
698+
}
699+
strbuf_trim_trailing_dir_sep(&buf);
700+
701+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
702+
return 0;
703+
}
704+
705+
return 0;
706+
}
707+
666708
static int git_default_attr_config(const char *var, const char *value)
667709
{
668710
if (!strcmp(var, "attr.tree")) {
@@ -730,6 +772,9 @@ int git_default_config(const char *var, const char *value,
730772
if (starts_with(var, "sparse."))
731773
return git_default_sparse_config(var, value);
732774

775+
if (starts_with(var, "gvfs."))
776+
return git_default_gvfs_config(var, value);
777+
733778
/* Add other config variables here and to Documentation/config.adoc. */
734779
return 0;
735780
}

‎environment.h‎

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

167170
extern int core_apply_sparse_checkout;
168171
extern int core_sparse_checkout_cone;

0 commit comments

Comments
 (0)