Skip to content

Commit d94022b

Browse files
jeffhostetlerdscho
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 4cff3b4 + ee28d9d commit d94022b

24 files changed

+7171
-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
@@ -907,6 +907,7 @@ LIB_OBJS += gpg-interface.o
907907
LIB_OBJS += graph.o
908908
LIB_OBJS += grep.o
909909
LIB_OBJS += gvfs.o
910+
LIB_OBJS += gvfs-helper-client.o
910911
LIB_OBJS += hash-lookup.o
911912
LIB_OBJS += hashmap.o
912913
LIB_OBJS += help.o
@@ -1436,6 +1437,9 @@ else
14361437
endif
14371438
BASIC_CFLAGS += $(CURL_CFLAGS)
14381439

1440+
PROGRAM_OBJS += gvfs-helper.o
1441+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1442+
14391443
REMOTE_CURL_PRIMARY = git-remote-http$X
14401444
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14411445
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2612,6 +2616,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
26122616
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
26132617
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
26142618

2619+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2620+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2621+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2622+
26152623
$(LIB_FILE): $(LIB_OBJS)
26162624
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
26172625

builtin/index-pack.c

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

cache.h

+3
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,9 @@ extern int precomposed_unicode;
984984
extern int protect_hfs;
985985
extern int protect_ntfs;
986986
extern const char *core_fsmonitor;
987+
extern int core_use_gvfs_helper;
988+
extern const char *gvfs_cache_server_url;
989+
extern struct strbuf gvfs_shared_cache_pathname;
987990

988991
extern int core_apply_sparse_checkout;
989992
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
@@ -570,7 +570,7 @@ if(NOT CURL_FOUND)
570570
add_compile_definitions(NO_CURL)
571571
message(WARNING "git-http-push and git-http-fetch will not be built")
572572
else()
573-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
573+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
574574
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
575575
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
576576
endif()
@@ -712,6 +712,9 @@ if(CURL_FOUND)
712712
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
713713
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
714714
endif()
715+
716+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
717+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
715718
endif()
716719

717720
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
@@ -918,6 +921,20 @@ set(wrapper_scripts
918921
set(wrapper_test_scripts
919922
test-fake-ssh test-tool)
920923

924+
if(CURL_FOUND)
925+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
926+
927+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
928+
target_link_libraries(test-gvfs-protocol common-main)
929+
930+
if(MSVC)
931+
set_target_properties(test-gvfs-protocol
932+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
933+
set_target_properties(test-gvfs-protocol
934+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
935+
endif()
936+
endif()
937+
921938

922939
foreach(script ${wrapper_scripts})
923940
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)