Skip to content

Commit 1a03b17

Browse files
jeffhostetlerdscho
authored andcommitted
Merge first wave of gvfs-helper feature
Includes commits from these pull requests: #191 #205 #206 #207 #208 #215 #220 #221 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2 parents b9258db + ed9d239 commit 1a03b17

24 files changed

+7072
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
/git-gc
7575
/git-get-tar-commit-id
7676
/git-grep
77+
/git-gvfs-helper
7778
/git-hash-object
7879
/git-help
7980
/git-http-backend

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ core.gvfs::
672672
flag just blocks them from occurring at all.
673673
--
674674

675+
core.useGvfsHelper::
676+
TODO
677+
675678
core.sparseCheckout::
676679
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
677680
for more information.

Documentation/config/gvfs.txt

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

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ LIB_OBJS += gpg-interface.o
887887
LIB_OBJS += graph.o
888888
LIB_OBJS += grep.o
889889
LIB_OBJS += gvfs.o
890+
LIB_OBJS += gvfs-helper-client.o
890891
LIB_OBJS += hash-lookup.o
891892
LIB_OBJS += hashmap.o
892893
LIB_OBJS += help.o
@@ -1411,6 +1412,9 @@ else
14111412
endif
14121413
BASIC_CFLAGS += $(CURL_CFLAGS)
14131414

1415+
PROGRAM_OBJS += gvfs-helper.o
1416+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1417+
14141418
REMOTE_CURL_PRIMARY = git-remote-http$X
14151419
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14161420
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2534,6 +2538,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
25342538
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
25352539
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
25362540

2541+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
2542+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2543+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2544+
25372545
$(LIB_FILE): $(LIB_OBJS)
25382546
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
25392547

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 38 additions & 0 deletions
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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ if(NOT CURL_FOUND)
546546
add_compile_definitions(NO_CURL)
547547
message(WARNING "git-http-push and git-http-fetch will not be built")
548548
else()
549-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
549+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
550550
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
551551
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
552552
endif()
@@ -688,6 +688,9 @@ if(CURL_FOUND)
688688
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
689689
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
690690
endif()
691+
692+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
693+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
691694
endif()
692695

693696
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
@@ -890,6 +893,20 @@ set(wrapper_scripts
890893
set(wrapper_test_scripts
891894
test-fake-ssh test-tool)
892895

896+
if(CURL_FOUND)
897+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
898+
899+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
900+
target_link_libraries(test-gvfs-protocol common-main)
901+
902+
if(MSVC)
903+
set_target_properties(test-gvfs-protocol
904+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
905+
set_target_properties(test-gvfs-protocol
906+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
907+
endif()
908+
endif()
909+
893910

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

credential.c

Lines changed: 2 additions & 0 deletions
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

0 commit comments

Comments
 (0)