Skip to content

Commit e6c52ec

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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent 4675e0b commit e6c52ec

File tree

17 files changed

+2891
-3
lines changed

17 files changed

+2891
-3
lines changed

.gitignore

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

Documentation/config.adoc

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

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

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

453455
include::config/http.adoc[]

Documentation/config/core.adoc

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

795+
core.useGvfsHelper::
796+
TODO
797+
795798
core.sparseCheckout::
796799
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
797800
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
@@ -1047,6 +1047,7 @@ LIB_OBJS += gpg-interface.o
10471047
LIB_OBJS += graph.o
10481048
LIB_OBJS += grep.o
10491049
LIB_OBJS += gvfs.o
1050+
LIB_OBJS += gvfs-helper-client.o
10501051
LIB_OBJS += hash-lookup.o
10511052
LIB_OBJS += hash.o
10521053
LIB_OBJS += hashmap.o
@@ -1698,6 +1699,8 @@ endif
16981699
endif
16991700
BASIC_CFLAGS += $(CURL_CFLAGS)
17001701

1702+
PROGRAM_OBJS += gvfs-helper.o
1703+
17011704
REMOTE_CURL_PRIMARY = git-remote-http$X
17021705
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
17031706
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2979,6 +2982,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
29792982
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
29802983
$(filter %.o,$^) $(LIBS)
29812984

2985+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
2986+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2987+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2988+
29822989
$(LIB_FILE): $(LIB_OBJS)
29832990
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
29842991

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "trace2.h"
3636
#include "wildmatch.h"
3737
#include "write-or-die.h"
38+
#include "transport.h"
3839

3940
struct config_source {
4041
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()
@@ -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: 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

@@ -129,6 +130,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
129130
#define PROTECT_NTFS_DEFAULT 1
130131
#endif
131132
int protect_ntfs = PROTECT_NTFS_DEFAULT;
133+
int core_use_gvfs_helper;
134+
char *gvfs_cache_server_url;
135+
const char *gvfs_shared_cache_pathname;
132136

133137
/*
134138
* The character that begins a commented line in user-editable file
@@ -545,6 +549,11 @@ int git_default_core_config(const char *var, const char *value,
545549
return 0;
546550
}
547551

552+
if (!strcmp(var, "core.usegvfshelper")) {
553+
core_use_gvfs_helper = git_config_bool(var, value);
554+
return 0;
555+
}
556+
548557
if (!strcmp(var, "core.sparsecheckout")) {
549558
/* virtual file system relies on the sparse checkout logic so force it on */
550559
if (core_virtualfilesystem)
@@ -691,6 +700,39 @@ static int git_default_mailmap_config(const char *var, const char *value)
691700
return 0;
692701
}
693702

703+
static int git_default_gvfs_config(const char *var, const char *value)
704+
{
705+
if (!strcmp(var, "gvfs.cache-server")) {
706+
char *v2 = NULL;
707+
708+
if (!git_config_string(&v2, var, value) && v2 && *v2) {
709+
free(gvfs_cache_server_url);
710+
gvfs_cache_server_url = transport_anonymize_url(v2);
711+
}
712+
free(v2);
713+
return 0;
714+
}
715+
716+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
717+
struct strbuf buf = STRBUF_INIT;
718+
strbuf_addstr(&buf, value);
719+
if (strbuf_normalize_path(&buf) < 0) {
720+
/*
721+
* Pretend it wasn't set. This will cause us to
722+
* fallback to ".git/objects" effectively.
723+
*/
724+
strbuf_release(&buf);
725+
return 0;
726+
}
727+
strbuf_trim_trailing_dir_sep(&buf);
728+
729+
gvfs_shared_cache_pathname = strbuf_detach(&buf, NULL);
730+
return 0;
731+
}
732+
733+
return 0;
734+
}
735+
694736
static int git_default_attr_config(const char *var, const char *value)
695737
{
696738
if (!strcmp(var, "attr.tree")) {
@@ -758,6 +800,9 @@ int git_default_config(const char *var, const char *value,
758800
if (starts_with(var, "sparse."))
759801
return git_default_sparse_config(var, value);
760802

803+
if (starts_with(var, "gvfs."))
804+
return git_default_gvfs_config(var, value);
805+
761806
/* Add other config variables here and to Documentation/config.adoc. */
762807
return 0;
763808
}

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)