Skip to content

Commit 60da059

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 19b2ac8 commit 60da059

File tree

16 files changed

+2863
-3
lines changed

16 files changed

+2863
-3
lines changed

.gitignore

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

Documentation/config.txt

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

449449
include::config/guitool.txt[]
450450

451+
include::config/gvfs.txt[]
452+
451453
include::config/help.txt[]
452454

453455
include::config/http.txt[]

Documentation/config/core.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ core.gvfs::
793793
flag just blocks them from occurring at all.
794794
--
795795

796+
core.useGvfsHelper::
797+
TODO
798+
796799
core.sparseCheckout::
797800
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
798801
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

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
@@ -1046,6 +1046,7 @@ LIB_OBJS += gpg-interface.o
10461046
LIB_OBJS += graph.o
10471047
LIB_OBJS += grep.o
10481048
LIB_OBJS += gvfs.o
1049+
LIB_OBJS += gvfs-helper-client.o
10491050
LIB_OBJS += hash-lookup.o
10501051
LIB_OBJS += hashmap.o
10511052
LIB_OBJS += help.o
@@ -1682,6 +1683,8 @@ endif
16821683
endif
16831684
BASIC_CFLAGS += $(CURL_CFLAGS)
16841685

1686+
PROGRAM_OBJS += gvfs-helper.o
1687+
16851688
REMOTE_CURL_PRIMARY = git-remote-http$X
16861689
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
16871690
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2934,6 +2937,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
29342937
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
29352938
$(filter %.o,$^) $(LIBS)
29362939

2940+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
2941+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2942+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2943+
29372944
$(LIB_FILE): $(LIB_OBJS)
29382945
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
29392946

config.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "wildmatch.h"
4343
#include "ws.h"
4444
#include "write-or-die.h"
45+
#include "transport.h"
4546

4647
struct config_source {
4748
struct config_source *prev;
@@ -1626,6 +1627,11 @@ int git_default_core_config(const char *var, const char *value,
16261627
return 0;
16271628
}
16281629

1630+
if (!strcmp(var, "core.usegvfshelper")) {
1631+
core_use_gvfs_helper = git_config_bool(var, value);
1632+
return 0;
1633+
}
1634+
16291635
if (!strcmp(var, "core.sparsecheckout")) {
16301636
/* virtual file system relies on the sparse checkout logic so force it on */
16311637
if (core_virtualfilesystem)
@@ -1777,6 +1783,39 @@ static int git_default_mailmap_config(const char *var, const char *value)
17771783
return 0;
17781784
}
17791785

1786+
static int git_default_gvfs_config(const char *var, const char *value)
1787+
{
1788+
if (!strcmp(var, "gvfs.cache-server")) {
1789+
char *v2 = NULL;
1790+
1791+
if (!git_config_string(&v2, var, value) && v2 && *v2) {
1792+
free(gvfs_cache_server_url);
1793+
gvfs_cache_server_url = transport_anonymize_url(v2);
1794+
}
1795+
free(v2);
1796+
return 0;
1797+
}
1798+
1799+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1800+
struct strbuf buf = STRBUF_INIT;
1801+
strbuf_addstr(&buf, value);
1802+
if (strbuf_normalize_path(&buf) < 0) {
1803+
/*
1804+
* Pretend it wasn't set. This will cause us to
1805+
* fallback to ".git/objects" effectively.
1806+
*/
1807+
strbuf_release(&buf);
1808+
return 0;
1809+
}
1810+
strbuf_trim_trailing_dir_sep(&buf);
1811+
1812+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
1813+
return 0;
1814+
}
1815+
1816+
return 0;
1817+
}
1818+
17801819
static int git_default_attr_config(const char *var, const char *value)
17811820
{
17821821
if (!strcmp(var, "attr.tree")) {
@@ -1844,6 +1883,9 @@ int git_default_config(const char *var, const char *value,
18441883
if (starts_with(var, "sparse."))
18451884
return git_default_sparse_config(var, value);
18461885

1886+
if (starts_with(var, "gvfs."))
1887+
return git_default_gvfs_config(var, value);
1888+
18471889
/* Add other config variables here and to Documentation/config.txt. */
18481890
return 0;
18491891
}

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()
@@ -823,6 +823,9 @@ if(CURL_FOUND)
823823
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
824824
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
825825
endif()
826+
827+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
828+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
826829
endif()
827830

828831
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
@@ -98,6 +98,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
9898
#define PROTECT_NTFS_DEFAULT 1
9999
#endif
100100
int protect_ntfs = PROTECT_NTFS_DEFAULT;
101+
int core_use_gvfs_helper;
102+
char *gvfs_cache_server_url;
103+
const char *gvfs_shared_cache_pathname;
101104

102105
/*
103106
* 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
@@ -175,6 +175,9 @@ extern int core_gvfs;
175175
extern int precomposed_unicode;
176176
extern int protect_hfs;
177177
extern int protect_ntfs;
178+
extern int core_use_gvfs_helper;
179+
extern char *gvfs_cache_server_url;
180+
extern const char *gvfs_shared_cache_pathname;
178181

179182
extern int core_apply_sparse_checkout;
180183
extern int core_sparse_checkout_cone;

0 commit comments

Comments
 (0)