Skip to content

Commit 579c64d

Browse files
jeffhostetlermjcheetham
authored andcommitted
Merge first wave of gvfs-helper feature
Includes commits from these pull requests: git-for-windows#191 git-for-windows#205 git-for-windows#206 git-for-windows#207 git-for-windows#208 git-for-windows#215 git-for-windows#220 git-for-windows#221 Signed-off-by: Derrick Stolee <[email protected]>
2 parents b899e1f + e3c3dd5 commit 579c64d

24 files changed

+7150
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
/git-gc
7777
/git-get-tar-commit-id
7878
/git-grep
79+
/git-gvfs-helper
7980
/git-hash-object
8081
/git-help
8182
/git-hook

Documentation/config.txt

+2
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

+3
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ core.gvfs::
763763
flag just blocks them from occurring at all.
764764
--
765765

766+
core.useGvfsHelper::
767+
TODO
768+
766769
core.sparseCheckout::
767770
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
768771
for more information.

Documentation/config/gvfs.txt

+5
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

+8
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ LIB_OBJS += gpg-interface.o
959959
LIB_OBJS += graph.o
960960
LIB_OBJS += grep.o
961961
LIB_OBJS += gvfs.o
962+
LIB_OBJS += gvfs-helper-client.o
962963
LIB_OBJS += hash-lookup.o
963964
LIB_OBJS += hashmap.o
964965
LIB_OBJS += help.o
@@ -1491,6 +1492,9 @@ else
14911492
endif
14921493
BASIC_CFLAGS += $(CURL_CFLAGS)
14931494

1495+
PROGRAM_OBJS += gvfs-helper.o
1496+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1497+
14941498
REMOTE_CURL_PRIMARY = git-remote-http$X
14951499
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14961500
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2695,6 +2699,10 @@ contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
26952699
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
26962700
$(filter %.o,$^) $(LIBS)
26972701

2702+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2703+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2704+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2705+
26982706
$(LIB_FILE): $(LIB_OBJS)
26992707
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
27002708

builtin/index-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
801801
if (startup_info->have_repository) {
802802
read_lock();
803803
collision_test_needed =
804-
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
804+
has_object_file_with_flags(oid, OBJECT_INFO_FOR_PREFETCH);
805805
read_unlock();
806806
}
807807

cache.h

+3
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,9 @@ extern int core_gvfs;
10721072
extern int precomposed_unicode;
10731073
extern int protect_hfs;
10741074
extern int protect_ntfs;
1075+
extern int core_use_gvfs_helper;
1076+
extern const char *gvfs_cache_server_url;
1077+
extern struct strbuf gvfs_shared_cache_pathname;
10751078

10761079
extern int core_apply_sparse_checkout;
10771080
extern int core_sparse_checkout_cone;

config.c

+38
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;
@@ -1723,6 +1724,11 @@ int git_default_core_config(const char *var, const char *value, void *cb)
17231724
return 0;
17241725
}
17251726

1727+
if (!strcmp(var, "core.usegvfshelper")) {
1728+
core_use_gvfs_helper = git_config_bool(var, value);
1729+
return 0;
1730+
}
1731+
17261732
if (!strcmp(var, "core.sparsecheckout")) {
17271733
/* virtual file system relies on the sparse checkout logic so force it on */
17281734
if (core_virtualfilesystem)
@@ -1865,6 +1871,35 @@ static int git_default_mailmap_config(const char *var, const char *value)
18651871
return 0;
18661872
}
18671873

1874+
static int git_default_gvfs_config(const char *var, const char *value)
1875+
{
1876+
if (!strcmp(var, "gvfs.cache-server")) {
1877+
const char *v2 = NULL;
1878+
1879+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1880+
gvfs_cache_server_url = transport_anonymize_url(v2);
1881+
free((char*)v2);
1882+
return 0;
1883+
}
1884+
1885+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1886+
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
1887+
strbuf_addstr(&gvfs_shared_cache_pathname, value);
1888+
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
1889+
/*
1890+
* Pretend it wasn't set. This will cause us to
1891+
* fallback to ".git/objects" effectively.
1892+
*/
1893+
strbuf_release(&gvfs_shared_cache_pathname);
1894+
return 0;
1895+
}
1896+
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
1897+
return 0;
1898+
}
1899+
1900+
return 0;
1901+
}
1902+
18681903
int git_default_config(const char *var, const char *value, void *cb)
18691904
{
18701905
if (starts_with(var, "core."))
@@ -1914,6 +1949,9 @@ int git_default_config(const char *var, const char *value, void *cb)
19141949
if (starts_with(var, "sparse."))
19151950
return git_default_sparse_config(var, value);
19161951

1952+
if (starts_with(var, "gvfs."))
1953+
return git_default_gvfs_config(var, value);
1954+
19171955
/* Add other config variables here and to Documentation/config.txt. */
19181956
return 0;
19191957
}

contrib/buildsystems/CMakeLists.txt

+18-1
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")
@@ -1017,6 +1020,20 @@ set(wrapper_scripts
10171020
set(wrapper_test_scripts
10181021
test-fake-ssh test-tool)
10191022

1023+
if(CURL_FOUND)
1024+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
1025+
1026+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
1027+
target_link_libraries(test-gvfs-protocol common-main)
1028+
1029+
if(MSVC)
1030+
set_target_properties(test-gvfs-protocol
1031+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
1032+
set_target_properties(test-gvfs-protocol
1033+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
1034+
endif()
1035+
endif()
1036+
10201037

10211038
foreach(script ${wrapper_scripts})
10221039
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)

credential.c

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ static int run_credential_helper(struct credential *c,
286286
else
287287
helper.no_stdout = 1;
288288

289+
helper.trace2_child_class = "cred";
290+
289291
if (start_command(&helper) < 0)
290292
return -1;
291293

environment.c

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
9090
#define PROTECT_NTFS_DEFAULT 1
9191
#endif
9292
int protect_ntfs = PROTECT_NTFS_DEFAULT;
93+
int core_use_gvfs_helper;
94+
const char *gvfs_cache_server_url;
95+
struct strbuf gvfs_shared_cache_pathname = STRBUF_INIT;
9396

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

0 commit comments

Comments
 (0)