Skip to content

Commit 90f95f0

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 <[email protected]>
2 parents a08b098 + 5a9ea20 commit 90f95f0

30 files changed

+7236
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
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-hook

Documentation/config.adoc

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

449449
include::config/guitool.adoc[]
450450

451+
include::config/gvfs.adoc[]
452+
451453
include::config/help.adoc[]
452454

453455
include::config/http.adoc[]

Documentation/config/core.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ core.gvfs::
792792
flag just blocks them from occurring at all.
793793
--
794794

795+
core.useGvfsHelper::
796+
TODO
797+
795798
core.sparseCheckout::
796799
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
797800
for more information.

Documentation/config/gvfs.adoc

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

Documentation/lint-manpages.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ check_missing_docs () (
2727
git-init-db) continue;;
2828
git-remote-*) continue;;
2929
git-stage) continue;;
30+
git-gvfs-helper) continue;;
3031
git-legacy-*) continue;;
3132
git-?*--?* ) continue ;;
3233
esac

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ LIB_OBJS += gpg-interface.o
10491049
LIB_OBJS += graph.o
10501050
LIB_OBJS += grep.o
10511051
LIB_OBJS += gvfs.o
1052+
LIB_OBJS += gvfs-helper-client.o
10521053
LIB_OBJS += hash-lookup.o
10531054
LIB_OBJS += hash.o
10541055
LIB_OBJS += hashmap.o
@@ -1701,6 +1702,9 @@ endif
17011702
endif
17021703
BASIC_CFLAGS += $(CURL_CFLAGS)
17031704

1705+
PROGRAM_OBJS += gvfs-helper.o
1706+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
1707+
17041708
REMOTE_CURL_PRIMARY = git-remote-http$X
17051709
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
17061710
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
@@ -2985,6 +2989,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
29852989
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
29862990
$(filter %.o,$^) $(LIBS)
29872991

2992+
git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
2993+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
2994+
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
2995+
29882996
$(LIB_FILE): $(LIB_OBJS)
29892997
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
29902998

bin-wrappers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/git-upload-pack
77
/scalar
88
/test-fake-ssh
9+
/test-gvfs-protocol
910
/test-tool

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
893893
if (startup_info->have_repository) {
894894
read_lock();
895895
collision_test_needed = has_object(the_repository, oid,
896-
HAS_OBJECT_FETCH_PROMISOR);
896+
OBJECT_INFO_FOR_PREFETCH);
897897
read_unlock();
898898
}
899899

config.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "wildmatch.h"
4545
#include "ws.h"
4646
#include "write-or-die.h"
47+
#include "transport.h"
4748

4849
struct config_source {
4950
struct config_source *prev;
@@ -1618,6 +1619,11 @@ int git_default_core_config(const char *var, const char *value,
16181619
return 0;
16191620
}
16201621

1622+
if (!strcmp(var, "core.usegvfshelper")) {
1623+
core_use_gvfs_helper = git_config_bool(var, value);
1624+
return 0;
1625+
}
1626+
16211627
if (!strcmp(var, "core.sparsecheckout")) {
16221628
/* virtual file system relies on the sparse checkout logic so force it on */
16231629
if (core_virtualfilesystem)
@@ -1769,6 +1775,37 @@ static int git_default_mailmap_config(const char *var, const char *value)
17691775
return 0;
17701776
}
17711777

1778+
static int git_default_gvfs_config(const char *var, const char *value)
1779+
{
1780+
if (!strcmp(var, "gvfs.cache-server")) {
1781+
char *v2 = NULL;
1782+
1783+
if (!git_config_string(&v2, var, value) && v2 && *v2) {
1784+
free(gvfs_cache_server_url);
1785+
gvfs_cache_server_url = transport_anonymize_url(v2);
1786+
}
1787+
free(v2);
1788+
return 0;
1789+
}
1790+
1791+
if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
1792+
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
1793+
strbuf_addstr(&gvfs_shared_cache_pathname, value);
1794+
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
1795+
/*
1796+
* Pretend it wasn't set. This will cause us to
1797+
* fallback to ".git/objects" effectively.
1798+
*/
1799+
strbuf_release(&gvfs_shared_cache_pathname);
1800+
return 0;
1801+
}
1802+
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
1803+
return 0;
1804+
}
1805+
1806+
return 0;
1807+
}
1808+
17721809
static int git_default_attr_config(const char *var, const char *value)
17731810
{
17741811
if (!strcmp(var, "attr.tree")) {
@@ -1836,6 +1873,9 @@ int git_default_config(const char *var, const char *value,
18361873
if (starts_with(var, "sparse."))
18371874
return git_default_sparse_config(var, value);
18381875

1876+
if (starts_with(var, "gvfs."))
1877+
return git_default_gvfs_config(var, value);
1878+
18391879
/* Add other config variables here and to Documentation/config.adoc. */
18401880
return 0;
18411881
}

contrib/buildsystems/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ if(NOT CURL_FOUND)
635635
add_compile_definitions(NO_CURL)
636636
message(WARNING "git-http-push and git-http-fetch will not be built")
637637
else()
638-
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
638+
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
639639
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
640640
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
641641
endif()
@@ -823,6 +823,9 @@ if(CURL_FOUND)
823823
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
824824
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
825825
endif()
826+
827+
add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
828+
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
826829
endif()
827830

828831
parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
@@ -1120,6 +1123,20 @@ set(wrapper_scripts
11201123
set(wrapper_test_scripts
11211124
test-fake-ssh test-tool)
11221125

1126+
if(CURL_FOUND)
1127+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
1128+
1129+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
1130+
target_link_libraries(test-gvfs-protocol common-main)
1131+
1132+
if(MSVC)
1133+
set_target_properties(test-gvfs-protocol
1134+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
1135+
set_target_properties(test-gvfs-protocol
1136+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
1137+
endif()
1138+
endif()
1139+
11231140

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

credential.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ static int run_credential_helper(struct credential *c,
456456
else
457457
helper.no_stdout = 1;
458458

459+
helper.trace2_child_class = "cred";
460+
459461
if (start_command(&helper) < 0)
460462
return -1;
461463

environment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
119119
#define PROTECT_NTFS_DEFAULT 1
120120
#endif
121121
int protect_ntfs = PROTECT_NTFS_DEFAULT;
122+
int core_use_gvfs_helper;
123+
char *gvfs_cache_server_url;
124+
struct strbuf gvfs_shared_cache_pathname = STRBUF_INIT;
122125

123126
/*
124127
* The character that begins a commented line in user-editable file

environment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ extern int core_gvfs;
161161
extern int precomposed_unicode;
162162
extern int protect_hfs;
163163
extern int protect_ntfs;
164+
extern int core_use_gvfs_helper;
165+
extern char *gvfs_cache_server_url;
166+
extern struct strbuf gvfs_shared_cache_pathname;
164167

165168
extern int core_apply_sparse_checkout;
166169
extern int core_sparse_checkout_cone;

0 commit comments

Comments
 (0)