Skip to content

Commit 0b30c5f

Browse files
jeffhostetlerderrickstolee
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 <[email protected]>
2 parents e901c94 + 9011aa4 commit 0b30c5f

24 files changed

+7072
-5
lines changed

.gitignore

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

Documentation/config.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ include::config/gui.txt[]
378378

379379
include::config/guitool.txt[]
380380

381+
include::config/gvfs.txt[]
382+
381383
include::config/help.txt[]
382384

383385
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
@@ -902,6 +902,7 @@ LIB_OBJS += gpg-interface.o
902902
LIB_OBJS += graph.o
903903
LIB_OBJS += grep.o
904904
LIB_OBJS += gvfs.o
905+
LIB_OBJS += gvfs-helper-client.o
905906
LIB_OBJS += hashmap.o
906907
LIB_OBJS += help.o
907908
LIB_OBJS += hex.o
@@ -1417,6 +1418,9 @@ else
14171418
endif
14181419
BASIC_CFLAGS += $(CURL_CFLAGS)
14191420

1421+
PROGRAM_OBJS += gvfs-helper.o
1422+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1423+
14201424
REMOTE_CURL_PRIMARY = git-remote-http$X
14211425
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
14221426
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2536,6 +2540,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
25362540
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
25372541
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
25382542

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

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
@@ -961,6 +961,9 @@ extern int precomposed_unicode;
961961
extern int protect_hfs;
962962
extern int protect_ntfs;
963963
extern const char *core_fsmonitor;
964+
extern int core_use_gvfs_helper;
965+
extern const char *gvfs_cache_server_url;
966+
extern struct strbuf gvfs_shared_cache_pathname;
964967

965968
extern int core_apply_sparse_checkout;
966969
extern int core_sparse_checkout_cone;

config.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "color.h"
2222
#include "refs.h"
2323
#include "gvfs.h"
24+
#include "transport.h"
2425

2526
struct config_source {
2627
struct config_source *prev;
@@ -1380,6 +1381,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
13801381
return 0;
13811382
}
13821383

1384+
if (!strcmp(var, "core.usegvfshelper")) {
1385+
core_use_gvfs_helper = git_config_bool(var, value);
1386+
return 0;
1387+
}
1388+
13831389
if (!strcmp(var, "core.sparsecheckout")) {
13841390
/* virtual file system relies on the sparse checkout logic so force it on */
13851391
if (core_virtualfilesystem)
@@ -1505,6 +1511,35 @@ static int git_default_mailmap_config(const char *var, const char *value)
15051511
return 0;
15061512
}
15071513

1514+
static int git_default_gvfs_config(const char *var, const char *value)
1515+
{
1516+
if (!strcmp(var, "gvfs.cache-server")) {
1517+
const char *v2 = NULL;
1518+
1519+
if (!git_config_string(&v2, var, value) && v2 && *v2)
1520+
gvfs_cache_server_url = transport_anonymize_url(v2);
1521+
free((char*)v2);
1522+
return 0;
1523+
}
1524+
1525+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1526+
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
1527+
strbuf_addstr(&gvfs_shared_cache_pathname, value);
1528+
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
1529+
/*
1530+
* Pretend it wasn't set. This will cause us to
1531+
* fallback to ".git/objects" effectively.
1532+
*/
1533+
strbuf_release(&gvfs_shared_cache_pathname);
1534+
return 0;
1535+
}
1536+
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
1537+
return 0;
1538+
}
1539+
1540+
return 0;
1541+
}
1542+
15081543
int git_default_config(const char *var, const char *value, void *cb)
15091544
{
15101545
if (starts_with(var, "core."))
@@ -1551,6 +1586,9 @@ int git_default_config(const char *var, const char *value, void *cb)
15511586
return 0;
15521587
}
15531588

1589+
if (starts_with(var, "gvfs."))
1590+
return git_default_gvfs_config(var, value);
1591+
15541592
/* Add other config variables here and to Documentation/config.txt. */
15551593
return 0;
15561594
}

contrib/buildsystems/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ if(NOT CURL_FOUND)
532532
add_compile_definitions(NO_CURL)
533533
message(WARNING "git-http-push and git-http-fetch will not be built")
534534
else()
535-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
535+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
536536
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
537537
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
538538
endif()
@@ -671,6 +671,9 @@ if(CURL_FOUND)
671671
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
672672
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
673673
endif()
674+
675+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
676+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
674677
endif()
675678

676679
set(git_builtin_extra
@@ -872,6 +875,20 @@ set(wrapper_scripts
872875
set(wrapper_test_scripts
873876
test-fake-ssh test-tool)
874877

878+
if(CURL_FOUND)
879+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
880+
881+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
882+
target_link_libraries(test-gvfs-protocol common-main)
883+
884+
if(MSVC)
885+
set_target_properties(test-gvfs-protocol
886+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
887+
set_target_properties(test-gvfs-protocol
888+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
889+
endif()
890+
endif()
891+
875892

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

environment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
8787
#endif
8888
int protect_ntfs = PROTECT_NTFS_DEFAULT;
8989
const char *core_fsmonitor;
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)