Skip to content

Commit 8f70ba6

Browse files
committed
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 471cbef + e2c797c commit 8f70ba6

24 files changed

+7074
-5
lines changed

.gitignore

+1
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-http-backend

Documentation/config.txt

+2
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ include::config/gui.txt[]
380380

381381
include::config/guitool.txt[]
382382

383+
include::config/gvfs.txt[]
384+
383385
include::config/help.txt[]
384386

385387
include::config/http.txt[]

Documentation/config/core.txt

+3
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ core.gvfs::
699699
flag just blocks them from occurring at all.
700700
--
701701

702+
core.useGvfsHelper::
703+
TODO
704+
702705
core.sparseCheckout::
703706
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
704707
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
@@ -897,6 +897,7 @@ LIB_OBJS += gpg-interface.o
897897
LIB_OBJS += graph.o
898898
LIB_OBJS += grep.o
899899
LIB_OBJS += gvfs.o
900+
LIB_OBJS += gvfs-helper-client.o
900901
LIB_OBJS += hash-lookup.o
901902
LIB_OBJS += hashmap.o
902903
LIB_OBJS += help.o
@@ -1422,6 +1423,9 @@ else
14221423
endif
14231424
BASIC_CFLAGS += $(CURL_CFLAGS)
14241425

1426+
PROGRAM_OBJS += gvfs-helper.o
1427+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1428+
14251429
REMOTE_CURL_PRIMARY = git-remote-http$X
14261430
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14271431
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2562,6 +2566,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
25622566
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
25632567
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
25642568

2569+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2570+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2571+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2572+
25652573
$(LIB_FILE): $(LIB_OBJS)
25662574
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
25672575

builtin/index-pack.c

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

cache.h

+3
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,9 @@ extern int precomposed_unicode;
963963
extern int protect_hfs;
964964
extern int protect_ntfs;
965965
extern const char *core_fsmonitor;
966+
extern int core_use_gvfs_helper;
967+
extern const char *gvfs_cache_server_url;
968+
extern struct strbuf gvfs_shared_cache_pathname;
966969

967970
extern int core_apply_sparse_checkout;
968971
extern int core_sparse_checkout_cone;

config.c

+38
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "dir.h"
2323
#include "color.h"
2424
#include "refs.h"
25+
#include "transport.h"
2526

2627
struct config_source {
2728
struct config_source *prev;
@@ -1548,6 +1549,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
15481549
return 0;
15491550
}
15501551

1552+
if (!strcmp(var, "core.usegvfshelper")) {
1553+
core_use_gvfs_helper = git_config_bool(var, value);
1554+
return 0;
1555+
}
1556+
15511557
if (!strcmp(var, "core.sparsecheckout")) {
15521558
/* virtual file system relies on the sparse checkout logic so force it on */
15531559
if (core_virtualfilesystem)
@@ -1673,6 +1679,35 @@ static int git_default_mailmap_config(const char *var, const char *value)
16731679
return 0;
16741680
}
16751681

1682+
static int git_default_gvfs_config(const char *var, const char *value)
1683+
{
1684+
if (!strcmp(var, "gvfs.cache-server")) {
1685+
const char *v2 = NULL;
1686+
1687+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1688+
gvfs_cache_server_url = transport_anonymize_url(v2);
1689+
free((char*)v2);
1690+
return 0;
1691+
}
1692+
1693+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1694+
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
1695+
strbuf_addstr(&gvfs_shared_cache_pathname, value);
1696+
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
1697+
/*
1698+
* Pretend it wasn't set. This will cause us to
1699+
* fallback to ".git/objects" effectively.
1700+
*/
1701+
strbuf_release(&gvfs_shared_cache_pathname);
1702+
return 0;
1703+
}
1704+
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
1705+
return 0;
1706+
}
1707+
1708+
return 0;
1709+
}
1710+
16761711
int git_default_config(const char *var, const char *value, void *cb)
16771712
{
16781713
if (starts_with(var, "core."))
@@ -1719,6 +1754,9 @@ int git_default_config(const char *var, const char *value, void *cb)
17191754
return 0;
17201755
}
17211756

1757+
if (starts_with(var, "gvfs."))
1758+
return git_default_gvfs_config(var, value);
1759+
17221760
/* Add other config variables here and to Documentation/config.txt. */
17231761
return 0;
17241762
}

contrib/buildsystems/CMakeLists.txt

+18-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ if(NOT CURL_FOUND)
563563
add_compile_definitions(NO_CURL)
564564
message(WARNING "git-http-push and git-http-fetch will not be built")
565565
else()
566-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
566+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
567567
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
568568
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
569569
endif()
@@ -705,6 +705,9 @@ if(CURL_FOUND)
705705
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
706706
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
707707
endif()
708+
709+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
710+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
708711
endif()
709712

710713
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
@@ -911,6 +914,20 @@ set(wrapper_scripts
911914
set(wrapper_test_scripts
912915
test-fake-ssh test-tool)
913916

917+
if(CURL_FOUND)
918+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
919+
920+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
921+
target_link_libraries(test-gvfs-protocol common-main)
922+
923+
if(MSVC)
924+
set_target_properties(test-gvfs-protocol
925+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
926+
set_target_properties(test-gvfs-protocol
927+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
928+
endif()
929+
endif()
930+
914931

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

credential.c

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

287+
helper.trace2_child_class = "cred";
288+
287289
if (start_command(&helper) < 0)
288290
return -1;
289291

environment.c

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
8888
#endif
8989
int protect_ntfs = PROTECT_NTFS_DEFAULT;
9090
const char *core_fsmonitor;
91+
int core_use_gvfs_helper;
92+
const char *gvfs_cache_server_url;
93+
struct strbuf gvfs_shared_cache_pathname = STRBUF_INIT;
9194

9295
/*
9396
* The character that begins a commented line in user-editable file

0 commit comments

Comments
 (0)