Skip to contentSkip to conversation

fix crash in path.c on Windows

PATCH In review René Scharfe 6 participants 26 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix crash in path.c on Windows

Use PATH_SEP and is_absolute_path() instead of using Unix conventions to enhance portability. On Windows, the assert() fails almost always without this change.

Also convert all backslashes in DOS-style paths to slashes, as that's what git uses internally.

---
The patch doesn't fix t1504 on Windows, but it allows one to at least run this test without git crashing multiple times due to the failed assertion. The test case "first_of_two" still fails, due to the weird translation applied to environment variables like $GIT_CEILING_DIRECTORIES. Is there a method to it? Here some experiments:

	set a=	getenv("a")
	======= ===========
	c	c
	/c	c:/
	c/	c/
	/c/	c:/
	c:c	c:c
	/c:c	c:c
	c:/c	c:/c
	/c:/c	c:/c
	c/:/c	c\;c:\
	/c:c/	c:c/
	/c/:c	/c/:c
	/c/:/c	c:\;c:\
	/c:/c/	c:/c/
	/c/:/c/	c:\;c:\

The test case can be convinced to pass by replacing "bar" with "/bar", but I'm not sure that's the right fix. Shouldn't we warn on invalid paths in $GIT_CEILING_DIRECTORIES?

 path.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
path.c +11 -2
index a074aea..4cae7f6 100644
@@ -387,7 +387,7 @@ int normalize_absolute_path(char *buf, const char *path)
 	assert(path);
 
 	while (*comp_start) {
-		assert(*comp_start == '/');
+		assert(is_absolute_path(comp_start));
 		while (*++comp_end && *comp_end != '/')
 			; /* nothing */
 		comp_len = comp_end - comp_start;
@@ -438,11 +438,20 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
 		return -1;
 
 	for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-		for (colon = ceil; *colon && *colon != ':'; colon++);
+		for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
 		len = colon - ceil;
 		if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
 			continue;
 		strlcpy(buf, ceil, len+1);
+
+		if (has_dos_drive_prefix(buf)) {
+			char *p;
+			for (p = buf; *p; p++) {
+				if (*p == '\\')
+					*p = '/';
+			}
+		}
+
 		len = normalize_absolute_path(buf, buf);
 		/* Strip "trailing slashes" from "/". */
 		if (len == 1)
Signature · 1 line
1.6.1.2
#1 lore raw
Quoted 8 lines · René Scharfe
	set a=	getenv("a")
	======= ===========
	c	c
	/c	c:/
	c/	c/
	/c/	c:/
	c:c	c:c
	/c:c	c:c
Quoted 8 lines
	c:/c	c:/c
	/c:/c	c:/c
	c/:/c	c\;c:\
	/c:c/	c:c/
	/c/:c	/c/:c
	/c/:/c	c:\;c:\
	/c:/c/	c:/c/
	/c/:/c/	c:\;c:\

Bash translates leading single-letter path components to drive prefix notation if it invokes a non-MSYS program; and it also translates ':' to ';' if the value looks like a path list. Sometimes there is an ambiguity and bash guesses wrong.

path.c int normalize_absolute_path(char *buf, const char *path) · line 393

Quoted 9 lines
path.c +1 -1
@@ -387,7 +387,7 @@ int normalize_absolute_path(char *buf, const char *path)
 	assert(path);
 
 	while (*comp_start) {
-		assert(*comp_start == '/');
+		assert(is_absolute_path(comp_start));
 		while (*++comp_end && *comp_end != '/')
 			; /* nothing */
 		comp_len = comp_end - comp_start;

Junio has pointed out your thinko here. Furthermore, *all* uses of '/' in this loop must be replaced by is_dir_sep().

But I would really appreciate if you could unify normalize_absolute_path() with setup.c's sanitary_path_copy() because they do almost the same thing (and the latter already works on Windows).

Quoted 7 lines
path.c +1 -1
@@ -438,11 +438,20 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
 		return -1;
 
 	for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-		for (colon = ceil; *colon && *colon != ':'; colon++);
+		for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
 		len = colon - ceil;

path.c int longest_ancestor_length(const char *path, const char *prefix_list) · line 452

Quoted 10 lines
path.c +7 -0
 		if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
 			continue;
 		strlcpy(buf, ceil, len+1);
+
+		if (has_dos_drive_prefix(buf)) {
+			char *p;
+			for (p = buf; *p; p++) {
+				if (*p == '\\')
+					*p = '/';
+			}

IMNSHO this is a kind of normalization and, therefore, must be done by normalize_absolute_path() (sanitary_path_copy() already does this).

path.c int longest_ancestor_length(const char *path, const char *prefix_list) · line 457

Quoted 5 lines
path.c +2 -0
+		}
+
 		len = normalize_absolute_path(buf, buf);
 		/* Strip "trailing slashes" from "/". */
 		if (len == 1)

-- Hannes

#2 lore raw
Quoted 18 lines · Johannes Sixt
Quoted 8 lines · René Scharfe
	set a=	getenv("a")
	======= ===========
	c	c
	/c	c:/
	c/	c/
	/c/	c:/
	c:c	c:c
	/c:c	c:c
Quoted 8 lines
	c:/c	c:/c
	/c:/c	c:/c
	c/:/c	c\;c:\
	/c:c/	c:c/
	/c/:c	/c/:c
	/c/:/c	c:\;c:\
	/c:/c/	c:/c/
	/c/:/c/	c:\;c:\
Quoted 4 lines

Bash translates leading single-letter path components to drive prefix notation if it invokes a non-MSYS program; and it also translates ':' to ';' if the value looks like a path list. Sometimes there is an ambiguity and bash guesses wrong.

Sure, but what rules or heuristics does it follow? Do we need to post-process the results or can we simply change the test case in t1504?

Quoted 12 lines

path.c int normalize_absolute_path(char *buf, const char *path) · line 393

Quoted 9 lines
path.c +1 -1
@@ -387,7 +387,7 @@ int normalize_absolute_path(char *buf, const char *path)
 	assert(path);
 
 	while (*comp_start) {
-		assert(*comp_start == '/');
+		assert(is_absolute_path(comp_start));
 		while (*++comp_end && *comp_end != '/')
 			; /* nothing */
 		comp_len = comp_end - comp_start;

Junio has pointed out your thinko here. Furthermore, *all* uses of '/' in this loop must be replaced by is_dir_sep().

It's not a thinko because I didn't think there. :) It's more a case of mechanical refactoring resulting in confusing code. If we inline is_absolute_path() manually there, we get the following:

	assert(*comp_start == '/' || has_dos_drive_prefix(comp_start));

The loop works because DOS drive prefixes never contain slashes.

Is is_absolute_path() too forgiving on Windows, i.e. should it stop classifying paths starting with a slash as absolute on that platform?

Quoted 3 lines

But I would really appreciate if you could unify normalize_absolute_path() with setup.c's sanitary_path_copy() because they do almost the same thing (and the latter already works on Windows).

Good idea.

Quoted 12 lines
Quoted 12 lines
path.c +3 -1
@@ -438,11 +438,20 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
 		return -1;
 
 	for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-		for (colon = ceil; *colon && *colon != ':'; colon++);
+		for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
 		len = colon - ceil;
 		if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
 			continue;
 		strlcpy(buf, ceil, len+1);
+
+		if (has_dos_drive_prefix(buf)) {
Quoted 8 lines

path.c int longest_ancestor_length(const char *path, const char *prefix_list) · line 452

Quoted 5 lines
path.c +5 -0
+			char *p;
+			for (p = buf; *p; p++) {
+				if (*p == '\\')
+					*p = '/';
+			}

IMNSHO this is a kind of normalization and, therefore, must be done by normalize_absolute_path() (sanitary_path_copy() already does this).

Makes sense.

René

#3 lore raw

torsdag 05 februari 2009 17:48:34 skrev René Scharfe:

Quoted 2 lines

Is is_absolute_path() too forgiving on Windows, i.e. should it stop classifying paths starting with a slash as absolute on that platform?

//server/share/file is an absolute path.

-- robin

#4 lore raw
In reply to René Scharfe
Quoted 8 lines · René Scharfe
Quoted 4 lines · Johannes Sixt

Bash translates leading single-letter path components to drive prefix notation if it invokes a non-MSYS program; and it also translates ':' to ';' if the value looks like a path list. Sometimes there is an ambiguity and bash guesses wrong.

Sure, but what rules or heuristics does it follow? Do we need to post-process the results or can we simply change the test case in t1504?

Mingw git assumes that it operates in a typical Windows environment - drive-letter notation for absolute paths, and ';' separates paths in PATH-like environment variables. If a test case breaks because bash guesses wrongly, and does not transform the environment or command line argument correctly, change the test case. (For example if /c:c was meant as a two paths, then change it to /foo:bar, perhaps bash gets this right.)

Everything else, I don't know. Audit how sensible the test case is, and whether it addresses a likely real-world case. If we don't care, skip it.

We try hard not to place Windows specific code outside of compat/.

Quoted 2 lines

Is is_absolute_path() too forgiving on Windows, i.e. should it stop classifying paths starting with a slash as absolute on that platform?

No. /foo/bar is a valid "absolute" path Windows - even though it is relative to the current drive. The point is that it is not relative to the current directory.

-- Hannes

#5 lore raw

PATCH 1/1 fix t1504 on Windows

In reply to René Scharfe

The test t1504 crashes on Windows due to a failed assertion in normalize_absolute_path() because this function expects absolute paths to start with a slash, while on Windows they can start with a drive letter or a backslash.

As suggested by Johannes, fix it by using sanitary_path_copy() instead, which can handle Windows-style paths just fine. This patch just exports it for usage; a later patch may move it from setup.c to path.c where it fits better.

Secondly, use the portability macro PATH_SEP instead of expecting colons to be used as path list delimiter. On Windows, semicolons are used, while colons separate drive letter and path.

Also change the test script to help bash recognize the path list variable for test case "first_of_two" as needing path conversion. git expects Windows-style paths, which bash happily creates if we turn the second path of the list into an absolute one.

---
 cache.h                 |    1 +
 path.c                  |   11 ++++++-----
 setup.c                 |    2 +-
 t/t1504-ceiling-dirs.sh |    2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)
cache.h +1 -0
index 45e713e..eeb774a 100644
@@ -626,6 +626,7 @@ const char *make_nonrelative_path(const char *path);
 const char *make_relative_path(const char *abs, const char *base);
 int normalize_absolute_path(char *buf, const char *path);
 int longest_ancestor_length(const char *path, const char *prefix_list);
+int sanitary_path_copy(char *dst, const char *src);
 
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
 extern int sha1_object_info(const unsigned char *, unsigned long *);
path.c +6 -5
index a074aea..ea1913a 100644
@@ -438,15 +438,16 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
 		return -1;
 
 	for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-		for (colon = ceil; *colon && *colon != ':'; colon++);
+		for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
 		len = colon - ceil;
 		if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
 			continue;
 		strlcpy(buf, ceil, len+1);
-		len = normalize_absolute_path(buf, buf);
-		/* Strip "trailing slashes" from "/". */
-		if (len == 1)
-			len = 0;
+		if (sanitary_path_copy(buf, buf) < 0)
+			continue;
+		len = strlen(buf);
+		if (buf[len - 1] == '/')
+			buf[--len] = '\0';
 
 		if (!strncmp(path, buf, len) &&
 		    path[len] == '/' &&
setup.c +1 -1
index dfda532..4fe438c 100644
@@ -4,7 +4,7 @@
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
 
-static int sanitary_path_copy(char *dst, const char *src)
+int sanitary_path_copy(char *dst, const char *src)
 {
 	char *dst0;
 
t/t1504-ceiling-dirs.sh +1 -1
index 91b704a..9c9c4c9 100755
@@ -96,7 +96,7 @@ test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
-GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
 GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
Signature · 1 line
1.6.1.2
#6 lore raw

Re: [PATCH] fix t1504 on Windows

Quoted 4 lines · René Scharfe

The test t1504 crashes on Windows due to a failed assertion in normalize_absolute_path() because this function expects absolute paths to start with a slash, while on Windows they can start with a drive letter or a backslash.

...

t/t1504-ceiling-dirs.sh test_prefix subdir_ceil_at_subdi_slash "sub/dir/" · line 102

Quoted 13 lines
t/t1504-ceiling-dirs.sh +1 -1
index 91b704a..9c9c4c9 100755
@@ -96,7 +96,7 @@ test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
-GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
 GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"

I also need this to complete this test:

t/t1504-ceiling-dirs.sh +2 -2
index 9c9c4c9..e377d48 100755
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three
 
 

That said, I'm in the process of preparing a series that includes your patch and that does the proper cleanup and code moving that you again didn't do :-/ But it turns out that this is non-trivial because of bash's (MSYS's) I-know-better-what-is-a-path-and-what-not behavior. It will take some time...

-- Hannes

#7 lore raw

Re: [PATCH] fix t1504 on Windows

Hi,

Quoted 5 lines · Johannes Sixt

That said, I'm in the process of preparing a series that includes your patch and that does the proper cleanup and code moving that you again didn't do :-/ But it turns out that this is non-trivial because of bash's (MSYS's) I-know-better-what-is-a-path-and-what-not behavior. It will take some time...

Please be sure to test on msysGit, too, we have some important patches affecting the bash I-know-... behavior (IMHO improving things a lot).

(I seem to remember that you use your own MSys environment rather than the msysGit environment.)

Ciao,
Dscho

#8 lore raw

Re: [PATCH] fix t1504 on Windows

Quoted 2 lines · Johannes Schindelin

Please be sure to test on msysGit, too, we have some important patches affecting the bash I-know-... behavior (IMHO improving things a lot).

Sure, I'll do.

Quoted 2 lines

(I seem to remember that you use your own MSys environment rather than the msysGit environment.)

I switched to msysGit, the build environment, soon after you published it. But I don't use rxvt or interactive bash.

-- Hannes

#9 lore raw

Re: [PATCH] fix t1504 on Windows

Hi,

Quoted 7 lines · Johannes Sixt
Quoted 2 lines · Johannes Schindelin

(I seem to remember that you use your own MSys environment rather than the msysGit environment.)

I switched to msysGit, the build environment, soon after you published it. But I don't use rxvt or interactive bash.

Ah.

So the path mangling only hits you when you run a shell script, such as the tests?

Ciao,
Dscho

#10 lore raw

Re: [PATCH] fix t1504 on Windows

Quoted 2 lines · Johannes Schindelin

So the path mangling only hits you when you run a shell script, such as the tests?

Correct.

-- Hannes

#25 lore raw
In reply to René Scharfe

path.c int normalize_absolute_path(char *buf, const char *path) · line 393

Quoted 9 lines · René Scharfe
path.c +1 -1
@@ -387,7 +387,7 @@ int normalize_absolute_path(char *buf, const char *path)
 	assert(path);
 
 	while (*comp_start) {
-		assert(*comp_start == '/');
+		assert(is_absolute_path(comp_start));
 		while (*++comp_end && *comp_end != '/')
 			; /* nothing */
 		comp_len = comp_end - comp_start;

This change does not make sense to me. The assert is about the initial iteration beginning at the "root" level, and at the same time previous iteration ended at dir_sep. On mingw you would probably need these two as separate tests. In other words, I would understand if the fix were like this:

	if (it begins with dos_prefix) {
        	/* this is never true outside windows */
		copy the dos prefix out and advance comp_start as
        	necessary;
	}
        while (*comp_start) {
        	assert(is_dir_sep(*comp_start));
                while (*++comp_end && !is_dir_sep(*comp_end))
                	; /* nothing */
		...
	}
#11 lore raw

Re: [PATCH] fix t1504 on Windows

In reply to Johannes Sixt
Quoted 10 lines · Johannes Sixt

I also need this to complete this test:

t/t1504-ceiling-dirs.sh +0 -0
index 9c9c4c9..e377d48 100755
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 
 

t/t1504-ceiling-dirs.sh GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi" · line 103

Quoted 10 lines
t/t1504-ceiling-dirs.sh +2 -2
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three

I don't, which makes me uneasy -- the tests shouldn't depend on details in our setup. :-/

Quoted 5 lines

That said, I'm in the process of preparing a series that includes your patch and that does the proper cleanup and code moving that you again didn't do :-/ But it turns out that this is non-trivial because of bash's (MSYS's) I-know-better-what-is-a-path-and-what-not behavior. It will take some time...

Glad to hear the first part, but what code moving do you mean? Something like the following?

-- snip! --
Remove the unused function normalize_absolute_path() and its tests.

---
 cache.h               |    1 -
 path.c                |   53 -------------------------------------------------
 t/t0060-path-utils.sh |   30 ---------------------------
 test-path-utils.c     |    7 ------
 4 files changed, 0 insertions(+), 91 deletions(-)
cache.h +0 -1
index eeb774a..763bce7 100644
@@ -624,7 +624,6 @@ int is_directory(const char *);
 const char *make_absolute_path(const char *path);
 const char *make_nonrelative_path(const char *path);
 const char *make_relative_path(const char *abs, const char *base);
-int normalize_absolute_path(char *buf, const char *path);
 int longest_ancestor_length(const char *path, const char *prefix_list);
 int sanitary_path_copy(char *dst, const char *src);
 
path.c +0 -53

59 lines not on this page · raw message

t/t0060-path-utils.sh +0 -30
index 6e7501f..9498f72 100755
@@ -7,41 +7,11 @@ test_description='Test various path utilities'
 
 . ./test-lib.sh
 
-norm_abs() {
-	test_expect_success "normalize absolute" \
-	"test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
-}
-
 ancestor() {
 	test_expect_success "longest ancestor" \
 	"test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
 }
 
-norm_abs "" /
-norm_abs / /
-norm_abs // /
-norm_abs /// /
-norm_abs /. /
-norm_abs /./ /
-norm_abs /./.. /
-norm_abs /../. /
-norm_abs /./../.// /
-norm_abs /dir/.. /
-norm_abs /dir/sub/../.. /
-norm_abs /dir /dir
-norm_abs /dir// /dir
-norm_abs /./dir /dir
-norm_abs /dir/. /dir
-norm_abs /dir///./ /dir
-norm_abs /dir//sub/.. /dir
-norm_abs /dir/sub/../ /dir
-norm_abs //dir/sub/../. /dir
-norm_abs /dir/s1/../s2/ /dir/s2
-norm_abs /d1/s1///s2/..//../s3/ /d1/s3
-norm_abs /d1/s1//../s2/../../d2 /d2
-norm_abs /d1/.../d2 /d1/.../d2
-norm_abs /d1/..././../d2 /d1/d2
-
 ancestor / "" -1
 ancestor / / -1
 ancestor /foo "" -1
test-path-utils.c +0 -7
index 2c0f5a3..a470ee4 100644
@@ -2,13 +2,6 @@
 
 int main(int argc, char **argv)
 {
-	if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
-		char *buf = xmalloc(PATH_MAX + 1);
-		int rv = normalize_absolute_path(buf, argv[2]);
-		assert(strlen(buf) == rv);
-		puts(buf);
-	}
-
 	if (argc >= 2 && !strcmp(argv[1], "make_absolute_path")) {
 		while (argc > 2) {
 			puts(make_absolute_path(argv[2]));
Signature · 1 line
1.6.1.2.350.g88cc
#12 lore raw

Re: [PATCH] fix t1504 on Windows

Quoted 18 lines · René Scharfe
Quoted 17 lines · Johannes Sixt

I also need this to complete this test:

t/t1504-ceiling-dirs.sh +1 -1
index 9c9c4c9..e377d48 100755
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
Quoted 6 lines

t/t1504-ceiling-dirs.sh GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi" · line 103

Quoted 3 lines
t/t1504-ceiling-dirs.sh +1 -1
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three

I don't, which makes me uneasy -- the tests shouldn't depend on details in our setup. :-/

I updated my msysgit to the current master this moment, and I still need these two changes. Do you use an older msysgit? With 31d5dfeb0 (2008-06-08) Steffen changed path mangling so that a text without a leading / or . is not converted. That's exactly what we see here.

Quoted 11 lines
Quoted 5 lines

That said, I'm in the process of preparing a series that includes your patch and that does the proper cleanup and code moving that you again didn't do :-/ But it turns out that this is non-trivial because of bash's (MSYS's) I-know-better-what-is-a-path-and-what-not behavior. It will take some time...

Glad to hear the first part, but what code moving do you mean? Something like the following?

-- snip! --
Remove the unused function normalize_absolute_path() and its tests.

No, that's not enough. I mean something more like this (but I'll not include the diff itself):

Johannes Sixt (4):
Make test-path-utils more robust against incorrect use Move sanitary_path_copy to path.c (and rename to
normalize_path_copy)
Test and fix normalize_path_copy()
Remove unused normalize_absolute_path()

René Scharfe (1):
Fix t1504 on Windows

 cache.h                 |    2 +-
 path.c                  |  124 +++++++++++++++++++++++++------------
 setup.c                 |   88 +--------------------------
 t/t0060-path-utils.sh   |   26 ++++----
 t/t1504-ceiling-dirs.sh |    2 +-
 test-path-utils.c       |   12 +++-
 6 files changed, 107 insertions(+), 147 deletions(-)

-- Hannes

#13 lore raw

Re: [PATCH] fix t1504 on Windows

Quoted 16 lines · Johannes Sixt
Quoted 8 lines · René Scharfe
Quoted 7 lines · Johannes Sixt
(quoted diff) +1 -1
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +1 -1
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three

I don't, which makes me uneasy -- the tests shouldn't depend on details in our setup. :-/

Quoted 4 lines

I updated my msysgit to the current master this moment, and I still need these two changes. Do you use an older msysgit? With 31d5dfeb0 (2008-06-08) Steffen changed path mangling so that a text without a leading / or . is not converted. That's exactly what we see here.

Oh, yes, good idea. I never updated the msys part of my installation.

My "uneasiness" doesn't mean that I'm against your changes above, in any case.

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines

That said, I'm in the process of preparing a series that includes your patch and that does the proper cleanup and code moving that you again didn't do :-/ But it turns out that this is non-trivial because of bash's
(MSYS's) I-know-better-what-is-a-path-and-what-not behavior. It will take
some time...

Quoted 6 lines

Johannes Sixt (4):
Make test-path-utils more robust against incorrect use Move sanitary_path_copy to path.c (and rename to
normalize_path_copy)
Test and fix normalize_path_copy()
Remove unused normalize_absolute_path()

Yeah, OK. I was aiming for a quick short fix, deferring cleanups to when I have more time. I wonder what patches one and three do, though.

René

#14 lore raw

cover Consolidate path normalization functions

This series:

- moves sanitary_path_copy around, which accounts for the bulk of the change;

- updates longest_ancestor_length(), the core function of GIT_CEILING_DIRECTORIES;

- adjust the test suite, uncovers a buglet in sanitary_path_copy(), and fixes it.

- removes normalize_absolute_path() that duplicated functionality of sanitary_path_copy().

As a side effect, this fixes GIT_CEILING_DIRECTORIES on Windows, where this feature is currently broken.

Johannes Sixt (4):
Make test-path-utils more robust against incorrect use Move sanitary_path_copy() to path.c and rename it to
normalize_path_copy()
Test and fix normalize_path_copy()
Remove unused normalize_absolute_path()

René Scharfe (1):
Fix t1504 on Windows

 cache.h                 |    2 +-
 path.c                  |  124 ++++++++++++++++++++++++++-------------
 setup.c                 |   88 +---------------------------
 t/t0060-path-utils.sh   |   33 +++++-----
 t/t1504-ceiling-dirs.sh |    6 +-
 test-path-utils.c       |   14 +++-
 6 files changed, 115 insertions(+), 152 deletions(-)
#15 lore raw

PATCH 1/5 Make test-path-utils more robust against incorrect use

Previously, this test utility happily returned with exit code 0 if garbage was thrown at it. Now it reports failure if an unknown function name was given on the command line.

---
 test-path-utils.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
test-path-utils.c +6 -1
index 2c0f5a3..7e6fc8d 100644
@@ -7,6 +7,7 @@ int main(int argc, char **argv)
 		int rv = normalize_absolute_path(buf, argv[2]);
 		assert(strlen(buf) == rv);
 		puts(buf);
+		return 0;
 	}
 
 	if (argc >= 2 && !strcmp(argv[1], "make_absolute_path")) {
@@ -15,12 +16,16 @@ int main(int argc, char **argv)
 			argc--;
 			argv++;
 		}
+		return 0;
 	}
 
 	if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
 		int len = longest_ancestor_length(argv[2], argv[3]);
 		printf("%d\n", len);
+		return 0;
 	}
 
-	return 0;
+	fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
+		argv[1] ? argv[1] : "(there was none)");
+	return 1;
 }
Signature · 1 line
1.6.1.297.g9b01e
#16 lore raw

PATCH 2/5 Move sanitary_path_copy() to path.c and rename it to normalize_path_copy()

This function and normalize_absolute_path() do almost the same thing. The former already works on Windows, but the latter crashes.

In subsequent changes we will remove normalize_absolute_path(). Here we make the replacement function reusable. On the way we rename it to reflect that it does some path normalization. Apart from that this is only moving around code.

---
 cache.h |    1 +
 path.c  |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 setup.c |   88 +--------------------------------------------------------------
 3 files changed, 88 insertions(+), 87 deletions(-)
cache.h +1 -0
index 2d889de..82fbb80 100644
@@ -628,6 +628,7 @@ const char *make_absolute_path(const char *path);
 const char *make_nonrelative_path(const char *path);
 const char *make_relative_path(const char *abs, const char *base);
 int normalize_absolute_path(char *buf, const char *path);
+int normalize_path_copy(char *dst, const char *src);
 int longest_ancestor_length(const char *path, const char *prefix_list);
 
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
path.c +86 -0

92 lines not on this page · raw message

setup.c +1 -87

100 lines not on this page · raw message

Signature · 1 line
1.6.1.297.g9b01e
#17 lore raw

PATCH 3/5 Fix GIT_CEILING_DIRECTORIES on Windows

From: René Scharfe <[email protected]>

Using git with GIT_CEILING_DIRECTORIES crashed on Windows due to a failed assertion in normalize_absolute_path(): This function expects absolute paths to start with a slash, while on Windows they can start with a drive letter or a backslash.

This fixes it by using the alternative, normalize_path_copy() instead, which can handle Windows-style paths just fine.

Secondly, the portability macro PATH_SEP is used instead of expecting colons to be used as path list delimiter.

The test script t1504 is also changed to help MSYS's bash recognize some program arguments as path list. (MSYS's bash must translate POSIX-style path lists to Windows-style path lists, and the heuristic did not catch some cases.)

---
I have adjusted the patch to fit into the series. I modified the commit message to pretend that the goal was to fix a feature instead of the test case ;) Hope that is fine with you.

-- Hannes

 path.c                  |   11 ++++++-----
 t/t1504-ceiling-dirs.sh |    6 +++---
 2 files changed, 9 insertions(+), 8 deletions(-)
path.c +6 -5
index d0a3519..dc3807a 100644
@@ -524,15 +524,16 @@ int longest_ancestor_length(const char *path, const char *prefix_list)
 		return -1;
 
 	for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
-		for (colon = ceil; *colon && *colon != ':'; colon++);
+		for (colon = ceil; *colon && *colon != PATH_SEP; colon++);
 		len = colon - ceil;
 		if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
 			continue;
 		strlcpy(buf, ceil, len+1);
-		len = normalize_absolute_path(buf, buf);
-		/* Strip "trailing slashes" from "/". */
-		if (len == 1)
-			len = 0;
+		if (normalize_path_copy(buf, buf) < 0)
+			continue;
+		len = strlen(buf);
+		if (len > 0 && buf[len-1] == '/')
+			buf[--len] = '\0';
 
 		if (!strncmp(path, buf, len) &&
 		    path[len] == '/' &&
t/t1504-ceiling-dirs.sh +3 -3
index 91b704a..e377d48 100755
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
-GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three
 
 
Signature · 1 line
1.6.1.297.g9b01e
#18 lore raw

PATCH 4/5 Test and fix normalize_path_copy()

This changes the test-path-utils utility to invoke normalize_path_copy() instead of normalize_absolute_path() because the latter is about to be removed.

The test cases in t0060 are adjusted in two regards:

- normalize_path_copy() more often leaves a trailing slash in the result. This has no negative side effects because the new user of this function, longest_ancester_length(), already accounts for this behavior.

- The function can fail.

The tests uncover a flaw in normalize_path_copy(): If there are sufficiently many '..' path components so that the root is reached, such as in "/d1/s1/../../d2", then the leading slash was lost. This manifested itself that (assuming there is a repository at /tmp/foo)

  $ git add /d1/../tmp/foo/some-file

reported 'pathspec is outside repository'. This is now fixed.

Moreover, the test case descriptions of t0060 now include the test data and expected outcome.

---
 path.c                |   16 +++++-----------
 t/t0060-path-utils.sh |   33 +++++++++++++++++----------------
 test-path-utils.c     |    7 ++++---
 3 files changed, 26 insertions(+), 30 deletions(-)
path.c +5 -11
index dc3807a..16628b2 100644
@@ -484,18 +484,12 @@ int normalize_path_copy(char *dst, const char *src)
 		 * dst0..dst is prefix portion, and dst[-1] is '/';
 		 * go up one level.
 		 */
-		dst -= 2; /* go past trailing '/' if any */
-		if (dst < dst0)
+		dst--;	/* go to trailing '/' */
+		if (dst <= dst0)
 			return -1;
-		while (1) {
-			if (dst <= dst0)
-				break;
-			c = *dst--;
-			if (c == '/') {	/* MinGW: cannot be '\\' anymore */
-				dst += 2;
-				break;
-			}
-		}
+		/* Windows: dst[-1] cannot be backslash anymore */
+		while (dst0 < dst && dst[-1] != '/')
+			dst--;
 	}
 	*dst = '\0';
 	return 0;
t/t0060-path-utils.sh +17 -16
index 6e7501f..4ed1f0b 100755
@@ -8,36 +8,37 @@ test_description='Test various path utilities'
 . ./test-lib.sh
 
 norm_abs() {
-	test_expect_success "normalize absolute" \
-	"test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
+	test_expect_success "normalize absolute: $1 => $2" \
+	"test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
 }
 
 ancestor() {
-	test_expect_success "longest ancestor" \
-	"test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
+	test_expect_success "longest ancestor: $1 $2 => $3" \
+	"test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'"
 }
 
-norm_abs "" /
+norm_abs "" ""
 norm_abs / /
 norm_abs // /
 norm_abs /// /
 norm_abs /. /
 norm_abs /./ /
-norm_abs /./.. /
-norm_abs /../. /
-norm_abs /./../.// /
+norm_abs /./.. ++failed++
+norm_abs /../. ++failed++
+norm_abs /./../.// ++failed++
 norm_abs /dir/.. /
 norm_abs /dir/sub/../.. /
+norm_abs /dir/sub/../../.. ++failed++
 norm_abs /dir /dir
-norm_abs /dir// /dir
+norm_abs /dir// /dir/
 norm_abs /./dir /dir
-norm_abs /dir/. /dir
-norm_abs /dir///./ /dir
-norm_abs /dir//sub/.. /dir
-norm_abs /dir/sub/../ /dir
-norm_abs //dir/sub/../. /dir
-norm_abs /dir/s1/../s2/ /dir/s2
-norm_abs /d1/s1///s2/..//../s3/ /d1/s3
+norm_abs /dir/. /dir/
+norm_abs /dir///./ /dir/
+norm_abs /dir//sub/.. /dir/
+norm_abs /dir/sub/../ /dir/
+norm_abs //dir/sub/../. /dir/
+norm_abs /dir/s1/../s2/ /dir/s2/
+norm_abs /d1/s1///s2/..//../s3/ /d1/s3/
 norm_abs /d1/s1//../s2/../../d2 /d2
 norm_abs /d1/.../d2 /d1/.../d2
 norm_abs /d1/..././../d2 /d1/d2
test-path-utils.c +4 -3
index 7e6fc8d..5168a8e 100644
@@ -2,10 +2,11 @@
 
 int main(int argc, char **argv)
 {
-	if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
+	if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
 		char *buf = xmalloc(PATH_MAX + 1);
-		int rv = normalize_absolute_path(buf, argv[2]);
-		assert(strlen(buf) == rv);
+		int rv = normalize_path_copy(buf, argv[2]);
+		if (rv)
+			buf = "++failed++";
 		puts(buf);
 		return 0;
 	}
Signature · 1 line
1.6.1.297.g9b01e
#19 lore raw

PATCH 5/5 Remove unused normalize_absolute_path()

This function is now superseded by normalize_path_copy().

---
 cache.h |    1 -
 path.c  |   51 ++++++---------------------------------------------
 2 files changed, 6 insertions(+), 46 deletions(-)
cache.h +0 -1
index 82fbb80..8dcc53c 100644
@@ -627,7 +627,6 @@ int is_directory(const char *);
 const char *make_absolute_path(const char *path);
 const char *make_nonrelative_path(const char *path);
 const char *make_relative_path(const char *abs, const char *base);
-int normalize_absolute_path(char *buf, const char *path);
 int normalize_path_copy(char *dst, const char *src);
 int longest_ancestor_length(const char *path, const char *prefix_list);
 
path.c +6 -45

64 lines not on this page · raw message

Signature · 1 line
1.6.1.297.g9b01e
#20 lore raw

Re: [PATCH 4/5] Test and fix normalize_path_copy()

In reply to Johannes Sixt

For Windows leading // is special indicating a UNC path and should not be changed to /.

//foo/bar is different from /foo/bar

-- robin

#21 lore raw

Re: [PATCH 4/5] Test and fix normalize_path_copy()

Quoted 4 lines · Robin Rosenberg

For Windows leading // is special indicating a UNC path and should not be changed to /.

//foo/bar is different from /foo/bar

Indeed. But stripping the double-dash would bite you only if you are using GIT_CEILING_DIRECTORIES or if you tend to call eg. git add with absolute paths; and that only if your repository lives in a UNC share, which is a rather odd use-case.

In particular, it does *not* affect fetch and push etc. so that you can have a remote repository on an UNC share.

-- Hannes

#22 lore raw

Re: [PATCH 4/5] Test and fix normalize_path_copy()

In reply to Johannes Sixt
Quoted 2 lines · Johannes Sixt

Moreover, the test case descriptions of t0060 now include the test data and expected outcome.

The test still fails in a lot of cases for me, because "/" is translated to the installation path of msys. E.g. with the patch at the end, which shows the results in addition to input and expected output, I get several cases like this (the first test call checks the return code):

* FAIL 2: normalize absolute: '/' => '/'

	test 0 = 0 && test 'C:/Program Files (x86)/msysgit/msysgit' = '/'

* FAIL 32: longest ancestor: '/foo' '/' => '0'

	test 0 = 0 && test '38' = '0'

I'm not sure what to do about it. Should test-path-utils translate it back into "root is / is root"? Should the test script look up "/" at the top and just append this value to all paths? Unpretty.

And then there's this:

* FAIL 7: normalize absolute: '/./..' => '++failed++'

	test 0 = 0 && test 'C:/Program Files (x86)/msysgit/msysgit' = '++failed++'

* ok 8: normalize absolute: '/../.' => '++failed++'

A printf() added to the top of normalize_path_copy() tells me that you can add as many "/.." as you want after a path starting with "/.", it will always translate into the install directory of msys regardless.

Anyway, here's the patch mentioned above:

t/t0060-path-utils.sh +8 -4
index 4ed1f0b..d5a38a6 100755
@@ -8,13 +8,17 @@ test_description='Test various path utilities'
 . ./test-lib.sh
 
 norm_abs() {
-	test_expect_success "normalize absolute: $1 => $2" \
-	"test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
+	result=$(test-path-utils normalize_path_copy "$1")
+	rc=$?
+	test_expect_success "normalize absolute: '$1' => '$2'" \
+	"test $rc = 0 && test '$result' = '$2'"
 }
 
 ancestor() {
-	test_expect_success "longest ancestor: $1 $2 => $3" \
-	"test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'"
+	result=$(test-path-utils longest_ancestor_length "$1" "$2")
+	rc=$?
+	test_expect_success "longest ancestor: '$1' '$2' => '$3'" \
+	"test $rc = 0 && test '$result' = '$3'"
 }
 
 norm_abs "" ""
#23 lore raw

Re: [PATCH 4/5] Test and fix normalize_path_copy()

Quoted 6 lines · René Scharfe
Quoted 2 lines · Johannes Sixt

Moreover, the test case descriptions of t0060 now include the test data and expected outcome.

The test still fails in a lot of cases for me, because "/" is translated to the installation path of msys.

To fix t0060 on Windows was not even on the radar of this series.

That said, I'm slowly working on a series that fixes or skips many tests on Windows. I currently have the patch below in my tree.

-- Hannes

t/t0060-path-utils.sh +81 -33
index 4ed1f0b..dd2d241 100755
@@ -7,41 +7,89 @@ test_description='Test various path utilities'
 
 . ./test-lib.sh
 
-norm_abs() {
-	test_expect_success "normalize absolute: $1 => $2" \
+norm_path() {
+	test_expect_success "normalize path: $1 => $2" \
 	"test \"\$(test-path-utils normalize_path_copy '$1')\" = '$2'"
 }
+xnorm_path() { say fix this: "$*"; }
+
+# On Windows, we are using MSYS's bash, which mangles the paths.
+# Absolute paths are anchored at the MSYS installation directory,
+# which means that the path / accounts for this many characters:
+rootoff=$(test-path-utils normalize_path_copy / | wc -c)
+# Account for the trailing LF:
+if test "$rootoff" = 2; then
+	rootoff=	# we are on Unix
+else
+	rootoff=$(($rootoff-1))
+fi
 
 ancestor() {
-	test_expect_success "longest ancestor: $1 $2 => $3" \
-	"test \"\$(test-path-utils longest_ancestor_length '$1' '$2')\" = '$3'"
+	# We do some math with the expected ancestor length.
+	expected=$3
+	if test -n "$rootoff" && ! test "$expected" = -1; then
+		expected=$(($expected+$rootoff))
+	fi
+	test_expect_success "longest ancestor: $1 $2 => $expected" \
+	"actual=\$(test-path-utils longest_ancestor_length '$1' '$2') &&
+	 test \"\$actual\" = '$expected'"
 }
 
-norm_abs "" ""
-norm_abs / /
-norm_abs // /
-norm_abs /// /
-norm_abs /. /
-norm_abs /./ /
-norm_abs /./.. ++failed++
-norm_abs /../. ++failed++
-norm_abs /./../.// ++failed++
-norm_abs /dir/.. /
-norm_abs /dir/sub/../.. /
-norm_abs /dir/sub/../../.. ++failed++
-norm_abs /dir /dir
-norm_abs /dir// /dir/
-norm_abs /./dir /dir
-norm_abs /dir/. /dir/
-norm_abs /dir///./ /dir/
-norm_abs /dir//sub/.. /dir/
-norm_abs /dir/sub/../ /dir/
-norm_abs //dir/sub/../. /dir/
-norm_abs /dir/s1/../s2/ /dir/s2/
-norm_abs /d1/s1///s2/..//../s3/ /d1/s3/
-norm_abs /d1/s1//../s2/../../d2 /d2
-norm_abs /d1/.../d2 /d1/.../d2
-norm_abs /d1/..././../d2 /d1/d2
+do_abs=t
+case $(uname -s) in
+*MINGW*) do_abs=
+esac
+
+norm_path "" ""
+norm_path . ""
+norm_path ./ ""
+norm_path ./. ""
+norm_path .. ++failed++
+norm_path ../sub ++failed++
+norm_path dir/.. ""
+norm_path dir/sub/../.. ""
+norm_path dir/sub/../../.. ++failed++
+norm_path dir dir
+norm_path dir// dir/
+norm_path ./dir dir
+norm_path dir/. dir/
+norm_path dir///./ dir/
+norm_path dir//sub/.. dir/
+norm_path dir/sub/../ dir/
+norm_path dir/sub/../. dir/
+norm_path dir/s1/../s2/ dir/s2/
+norm_path d1/s1///s2/..//../s3/ d1/s3/
+norm_path d1/s1//../s2/../../d2 d2
+norm_path d1/.../d2 d1/.../d2
+norm_path d1/..././../d2 d1/d2
+
+if test -n "$do_abs"; then
+norm_path "" ""
+norm_path / /
+norm_path // /
+norm_path /// /
+norm_path /. /
+norm_path /./ /
+norm_path /./.. ++failed++
+norm_path /../. ++failed++
+norm_path /./../.// ++failed++
+norm_path /dir/.. /
+norm_path /dir/sub/../.. /
+norm_path /dir/sub/../../.. ++failed++
+norm_path /dir /dir
+norm_path /dir// /dir/
+norm_path /./dir /dir
+norm_path /dir/. /dir/
+norm_path /dir///./ /dir/
+norm_path /dir//sub/.. /dir/
+norm_path /dir/sub/../ /dir/
+norm_path //dir/sub/../. /dir/
+norm_path /dir/s1/../s2/ /dir/s2/
+norm_path /d1/s1///s2/..//../s3/ /d1/s3/
+norm_path /d1/s1//../s2/../../d2 /d2
+norm_path /d1/.../d2 /d1/.../d2
+norm_path /d1/..././../d2 /d1/d2
+fi
 
 ancestor / "" -1
 ancestor / / -1
@@ -80,9 +128,9 @@ ancestor /foo/bar /:/foo:/bar/ 4
 ancestor /foo/bar /foo:/:/bar/ 4
 ancestor /foo/bar /:/bar/:/fo 0
 ancestor /foo/bar /:/bar/ 0
-ancestor /foo/bar :://foo/. 4
-ancestor /foo/bar :://foo/.:: 4
-ancestor /foo/bar //foo/./::/bar 4
-ancestor /foo/bar ::/bar -1
+ancestor /foo/bar .:/foo/. 4
+ancestor /foo/bar .:/foo/.:.: 4
+ancestor /foo/bar /foo/./:.:/bar 4
+ancestor /foo/bar .:/bar -1
 
 test_done
#24 lore raw

Re: [PATCH] fix t1504 on Windows

In reply to Johannes Sixt
Quoted 11 lines · Johannes Sixt

I also need this to complete this test:

t/t1504-ceiling-dirs.sh +0 -1
index 9c9c4c9..e377d48 100755
@@ -93,13 +93,13 @@ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
 test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
 
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"

t/t1504-ceiling-dirs.sh GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi" · line 104

Quoted 10 lines
t/t1504-ceiling-dirs.sh +2 -1
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub"
 test_fail second_of_two
 
 GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:/bar"
 test_fail first_of_two
 
-GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+GIT_CEILING_DIRECTORIES="/foo:$TRASH_ROOT/sub:/bar"
 test_fail second_of_three
 

Just to confirm: after updating msys, I also need this patch to make t1504 pass.

René