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:

	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 <dstolee@microsoft.com>
  • Loading branch information
jeffhostetler authored and mjcheetham committed Jul 23, 2024
2 parents 4825ba9 + e6674f3 commit c2db5a3
Show file tree
Hide file tree
Showing 25 changed files with 7,190 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-hook
Expand Down
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,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 @@ -793,6 +793,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
1 change: 1 addition & 0 deletions Documentation/lint-manpages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ check_missing_docs () (
git-init-db) continue;;
git-remote-*) continue;;
git-stage) continue;;
git-gvfs-helper) continue;;
git-legacy-*) continue;;
git-?*--?* ) continue ;;
esac
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,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 += hash-lookup.o
LIB_OBJS += hashmap.o
LIB_OBJS += help.o
Expand Down Expand Up @@ -1651,6 +1652,9 @@ endif
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 @@ -2914,6 +2918,10 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
$(filter %.o,$^) $(LIBS)

git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS) $(LAZYLOAD_LIBCURL_OBJ)
$(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 @@ -811,7 +811,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
read_lock();
collision_test_needed =
repo_has_object_file_with_flags(the_repository, oid,
OBJECT_INFO_QUICK);
OBJECT_INFO_FOR_PREFETCH);
read_unlock();
}

Expand Down
40 changes: 40 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "wildmatch.h"
#include "ws.h"
#include "write-or-die.h"
#include "transport.h"

struct config_source {
struct config_source *prev;
Expand Down Expand Up @@ -1671,6 +1672,11 @@ int git_default_core_config(const char *var, const char *value,
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 @@ -1822,6 +1828,37 @@ 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")) {
char *v2 = NULL;

if (!git_config_string(&v2, var, value) && v2 && *v2) {
free(gvfs_cache_server_url);
gvfs_cache_server_url = transport_anonymize_url(v2);
}
free(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;
}

static int git_default_attr_config(const char *var, const char *value)
{
if (!strcmp(var, "attr.tree")) {
Expand Down Expand Up @@ -1889,6 +1926,9 @@ int git_default_config(const char *var, const char *value,
if (starts_with(var, "sparse."))
return git_default_sparse_config(var, value);

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 @@ -649,7 +649,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 @@ -818,6 +818,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()

parse_makefile_for_executables(git_builtin_extra "BUILT_INS")
Expand Down Expand Up @@ -1058,6 +1061,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 @@ -417,6 +417,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 @@ -111,6 +111,9 @@ int protect_hfs = PROTECT_HFS_DEFAULT;
#define PROTECT_NTFS_DEFAULT 1
#endif
int protect_ntfs = PROTECT_NTFS_DEFAULT;
int core_use_gvfs_helper;
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
3 changes: 3 additions & 0 deletions environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ extern int core_gvfs;
extern int precomposed_unicode;
extern int protect_hfs;
extern int protect_ntfs;
extern int core_use_gvfs_helper;
extern 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
Loading

0 comments on commit c2db5a3

Please sign in to comment.