Thread (72 messages) flat view 72 messages, 20 authors, 2016-06-15
STALE3713d

[PATCH 12/12] [TODO] setup: bring changes from 4msysgit/next to next

From: Steffen Prohaska <hidden>
Date: 2016-06-15 22:44:52
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

From: Johannes Sixt <redacted>

Hannes,
You introduced "minoffset" in 861429a7c37c7.  Here is your original
message:

'''
An earlier patch has implemented getcwd() so that it converts the
drive letter into the POSIX-like path that is used internally by
MinGW (C:\foo => /c/foo), but this style does not work outside
the MinGW shell. It is better to just convert the backslashes
to forward slashes and handle the drive letter explicitly.
'''

Dmitry replaced setenv() with set_git_dir in 855f254b2b5b08.
Here is his original message:

'''
git clone was failing with 'invalid object name HEAD' if ran from
cmd.exe directly

environment.c caches results of many getenv calls.
Under MinGW setenv(X) invalidates all previous values returned by
getenv(X)
so cached values become dangling pointers.

Replaced all setenv(GIT_DIR, ...) with set_git_dir

Signed-off-by: Dmitry Kakurin <redacted>
'''
Signed-off-by: Steffen Prohaska <redacted>
---
 setup.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/setup.c b/setup.c
index 6cf9094..1fd30c4 100644
--- a/setup.c
+++ b/setup.c
@@ -381,6 +381,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	const char *gitdirenv;
 	const char *gitfile_dir;
 	int len, offset, ceil_offset;
+	int minoffset = 0;
 
 	/*
 	 * Let's assume that we are in a git repository.
@@ -431,6 +432,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 
 	if (!getcwd(cwd, sizeof(cwd)-1))
 		die("Unable to read current working directory");
+	if (has_dos_drive_prefix(cwd))
+		minoffset = 2;
 
 	ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
 	if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
@@ -461,11 +464,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			inside_git_dir = 1;
 			if (!work_tree_env)
 				inside_work_tree = 0;
-			setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+			set_git_dir(".");
 			check_repository_format_gently(nongit_ok);
 			return NULL;
 		}
-		while (--offset > ceil_offset && cwd[offset] != '/');
+		while (offset > minoffset && --offset > ceil_offset && cwd[offset] != '/');
 		if (offset <= ceil_offset) {
 			if (nongit_ok) {
 				if (chdir(cwd))
-- 
1.5.6.1.255.g32571
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help