Skip to content

Commit b013f94

Browse files
jeffhostetlerderrickstolee
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 d030032 + d241c5f commit b013f94

24 files changed

+7144
-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-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
@@ -700,6 +700,9 @@ core.gvfs::
700700
flag just blocks them from occurring at all.
701701
--
702702

703+
core.useGvfsHelper::
704+
TODO
705+
703706
core.sparseCheckout::
704707
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
705708
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
@@ -921,6 +921,7 @@ LIB_OBJS += gpg-interface.o
921921
LIB_OBJS += graph.o
922922
LIB_OBJS += grep.o
923923
LIB_OBJS += gvfs.o
924+
LIB_OBJS += gvfs-helper-client.o
924925
LIB_OBJS += hash-lookup.o
925926
LIB_OBJS += hashmap.o
926927
LIB_OBJS += help.o
@@ -1451,6 +1452,9 @@ else
14511452
endif
14521453
BASIC_CFLAGS += $(CURL_CFLAGS)
14531454

1455+
PROGRAM_OBJS += gvfs-helper.o
1456+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1457+
14541458
REMOTE_CURL_PRIMARY = git-remote-http$X
14551459
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14561460
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2639,6 +2643,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
26392643
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
26402644
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
26412645

2646+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2647+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2648+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2649+
26422650
$(LIB_FILE): $(LIB_OBJS)
26432651
$(QUIET_AR)$(AR) $(ARFLAGS) $@ $^
26442652

builtin/index-pack.c

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

cache.h

+3
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,9 @@ extern int core_gvfs;
992992
extern int precomposed_unicode;
993993
extern int protect_hfs;
994994
extern int protect_ntfs;
995+
extern int core_use_gvfs_helper;
996+
extern const char *gvfs_cache_server_url;
997+
extern struct strbuf gvfs_shared_cache_pathname;
995998

996999
extern int core_apply_sparse_checkout;
9971000
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;
@@ -1534,6 +1535,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
15341535
return 0;
15351536
}
15361537

1538+
if (!strcmp(var, "core.usegvfshelper")) {
1539+
core_use_gvfs_helper = git_config_bool(var, value);
1540+
return 0;
1541+
}
1542+
15371543
if (!strcmp(var, "core.sparsecheckout")) {
15381544
/* virtual file system relies on the sparse checkout logic so force it on */
15391545
if (core_virtualfilesystem)
@@ -1659,6 +1665,35 @@ static int git_default_mailmap_config(const char *var, const char *value)
16591665
return 0;
16601666
}
16611667

1668+
static int git_default_gvfs_config(const char *var, const char *value)
1669+
{
1670+
if (!strcmp(var, "gvfs.cache-server")) {
1671+
const char *v2 = NULL;
1672+
1673+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1674+
gvfs_cache_server_url = transport_anonymize_url(v2);
1675+
free((char*)v2);
1676+
return 0;
1677+
}
1678+
1679+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1680+
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
1681+
strbuf_addstr(&gvfs_shared_cache_pathname, value);
1682+
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
1683+
/*
1684+
* Pretend it wasn't set. This will cause us to
1685+
* fallback to ".git/objects" effectively.
1686+
*/
1687+
strbuf_release(&gvfs_shared_cache_pathname);
1688+
return 0;
1689+
}
1690+
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
1691+
return 0;
1692+
}
1693+
1694+
return 0;
1695+
}
1696+
16621697
int git_default_config(const char *var, const char *value, void *cb)
16631698
{
16641699
if (starts_with(var, "core."))
@@ -1705,6 +1740,9 @@ int git_default_config(const char *var, const char *value, void *cb)
17051740
return 0;
17061741
}
17071742

1743+
if (starts_with(var, "gvfs."))
1744+
return git_default_gvfs_config(var, value);
1745+
17081746
/* Add other config variables here and to Documentation/config.txt. */
17091747
return 0;
17101748
}

contrib/buildsystems/CMakeLists.txt

+18-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ if(NOT CURL_FOUND)
604604
add_compile_definitions(NO_CURL)
605605
message(WARNING "git-http-push and git-http-fetch will not be built")
606606
else()
607-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
607+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
608608
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
609609
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
610610
endif()
@@ -746,6 +746,9 @@ if(CURL_FOUND)
746746
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
747747
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
748748
endif()
749+
750+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
751+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
749752
endif()
750753

751754
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
@@ -952,6 +955,20 @@ set(wrapper_scripts
952955
set(wrapper_test_scripts
953956
test-fake-ssh test-tool)
954957

958+
if(CURL_FOUND)
959+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
960+
961+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
962+
target_link_libraries(test-gvfs-protocol common-main)
963+
964+
if(MSVC)
965+
set_target_properties(test-gvfs-protocol
966+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
967+
set_target_properties(test-gvfs-protocol
968+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
969+
endif()
970+
endif()
971+
955972

956973
foreach(script ${wrapper_scripts})
957974
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
@@ -87,6 +87,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
8787
#define PROTECT_NTFS_DEFAULT 1
8888
#endif
8989
int protect_ntfs = PROTECT_NTFS_DEFAULT;
90+
int core_use_gvfs_helper;
91+
const char *gvfs_cache_server_url;
92+
struct strbuf gvfs_shared_cache_pathname = STRBUF_INIT;
9093

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

0 commit comments

Comments
 (0)