Skip to content

Commit

Permalink
Merge first wave of gvfs-helper feature
Browse files Browse the repository at this point in the history
Includes commits from these pull requests:

	#191
	#205
	#206
	#207
	#208
	#215
	#220
	#221

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Oct 6, 2020
2 parents 1e748e8 + 950d08a commit 93da4f0
Show file tree
Hide file tree
Showing 24 changed files with 7,072 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
/git-gc
/git-get-tar-commit-id
/git-grep
/git-gvfs-helper
/git-hash-object
/git-help
/git-http-backend
Expand Down
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ include::config/gui.txt[]

include::config/guitool.txt[]

include::config/gvfs.txt[]

include::config/help.txt[]

include::config/http.txt[]
Expand Down
3 changes: 3 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ core.gvfs::
flag just blocks them from occurring at all.
--

core.useGvfsHelper::
TODO

core.sparseCheckout::
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
for more information.
Expand Down
5 changes: 5 additions & 0 deletions Documentation/config/gvfs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gvfs.cache-server::
TODO

gvfs.sharedcache::
TODO
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o
LIB_OBJS += grep.o
LIB_OBJS += gvfs.o
LIB_OBJS += gvfs-helper-client.o
LIB_OBJS += hashmap.o
LIB_OBJS += help.o
LIB_OBJS += hex.o
Expand Down Expand Up @@ -1417,6 +1418,9 @@ else
endif
BASIC_CFLAGS += $(CURL_CFLAGS)

PROGRAM_OBJS += gvfs-helper.o
TEST_PROGRAMS_NEED_X += test-gvfs-protocol

REMOTE_CURL_PRIMARY = git-remote-http$X
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
Expand Down Expand Up @@ -2536,6 +2540,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

$(LIB_FILE): $(LIB_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

Expand Down
2 changes: 1 addition & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
collision_test_needed =
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
has_object_file_with_flags(oid, OBJECT_INFO_FOR_PREFETCH);
read_unlock();
}

Expand Down
3 changes: 3 additions & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,9 @@ extern int precomposed_unicode;
extern int protect_hfs;
extern int protect_ntfs;
extern const char *core_fsmonitor;
extern int core_use_gvfs_helper;
extern const char *gvfs_cache_server_url;
extern struct strbuf gvfs_shared_cache_pathname;

extern int core_apply_sparse_checkout;
extern int core_sparse_checkout_cone;
Expand Down
38 changes: 38 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "color.h"
#include "refs.h"
#include "gvfs.h"
#include "transport.h"

struct config_source {
struct config_source *prev;
Expand Down Expand Up @@ -1380,6 +1381,11 @@ static int git_default_core_config(const char *var, const char *value, void *cb)
return 0;
}

if (!strcmp(var, "core.usegvfshelper")) {
core_use_gvfs_helper = git_config_bool(var, value);
return 0;
}

if (!strcmp(var, "core.sparsecheckout")) {
/* virtual file system relies on the sparse checkout logic so force it on */
if (core_virtualfilesystem)
Expand Down Expand Up @@ -1505,6 +1511,35 @@ static int git_default_mailmap_config(const char *var, const char *value)
return 0;
}

static int git_default_gvfs_config(const char *var, const char *value)
{
if (!strcmp(var, "gvfs.cache-server")) {
const char *v2 = NULL;

if (!git_config_string(&v2, var, value) && v2 && *v2)
gvfs_cache_server_url = transport_anonymize_url(v2);
free((char*)v2);
return 0;
}

if (!strcmp(var, "gvfs.sharedcache") && value && *value) {
strbuf_setlen(&gvfs_shared_cache_pathname, 0);
strbuf_addstr(&gvfs_shared_cache_pathname, value);
if (strbuf_normalize_path(&gvfs_shared_cache_pathname) < 0) {
/*
* Pretend it wasn't set. This will cause us to
* fallback to ".git/objects" effectively.
*/
strbuf_release(&gvfs_shared_cache_pathname);
return 0;
}
strbuf_trim_trailing_dir_sep(&gvfs_shared_cache_pathname);
return 0;
}

return 0;
}

int git_default_config(const char *var, const char *value, void *cb)
{
if (starts_with(var, "core."))
Expand Down Expand Up @@ -1551,6 +1586,9 @@ int git_default_config(const char *var, const char *value, void *cb)
return 0;
}

if (starts_with(var, "gvfs."))
return git_default_gvfs_config(var, value);

/* Add other config variables here and to Documentation/config.txt. */
return 0;
}
Expand Down
19 changes: 18 additions & 1 deletion contrib/buildsystems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ if(NOT CURL_FOUND)
add_compile_definitions(NO_CURL)
message(WARNING "git-http-push and git-http-fetch will not be built")
else()
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http git-gvfs-helper)
if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
endif()
Expand Down Expand Up @@ -671,6 +671,9 @@ if(CURL_FOUND)
add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
endif()

add_executable(git-gvfs-helper ${CMAKE_SOURCE_DIR}/gvfs-helper.c)
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
endif()

set(git_builtin_extra
Expand Down Expand Up @@ -872,6 +875,20 @@ set(wrapper_scripts
set(wrapper_test_scripts
test-fake-ssh test-tool)

if(CURL_FOUND)
list(APPEND wrapper_test_scripts test-gvfs-protocol)

add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
target_link_libraries(test-gvfs-protocol common-main)

if(MSVC)
set_target_properties(test-gvfs-protocol
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
set_target_properties(test-gvfs-protocol
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
endif()
endif()


foreach(script ${wrapper_scripts})
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
Expand Down
2 changes: 2 additions & 0 deletions credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ static int run_credential_helper(struct credential *c,
else
helper.no_stdout = 1;

helper.trace2_child_class = "cred";

if (start_command(&helper) < 0)
return -1;

Expand Down
3 changes: 3 additions & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
#endif
int protect_ntfs = PROTECT_NTFS_DEFAULT;
const char *core_fsmonitor;
int core_use_gvfs_helper;
const char *gvfs_cache_server_url;
struct strbuf gvfs_shared_cache_pathname = STRBUF_INIT;

/*
* The character that begins a commented line in user-editable file
Expand Down
Loading

0 comments on commit 93da4f0

Please sign in to comment.