test-path-utils.c: remove incorrect assumption
authorRay Donnelly <mingw.android@gmail.com>
Thu, 1 Oct 2015 19:04:17 +0000 (20:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Oct 2015 01:03:50 +0000 (18:03 -0700)
In normalize_ceiling_entry(), we test that normalized paths end with
slash, *unless* the path to be normalized was already the root
directory.

However, normalize_path_copy() does not even enforce this condition.

Even worse: on Windows, the root directory gets translated into a
Windows directory by the Bash before being passed to `git.exe` (or
`test-path-utils.exe`), which means that we cannot even know whether
the path that was passed to us was the root directory to begin with.

This issue has already caused endless hours of trying to "fix" the
MSYS2 runtime, only to break other things due to MSYS2 ensuring that
the converted path maintains the same state as the input path with
respect to any final '/'.

So let's just forget about this test. It is non-essential to Git's
operation, anyway.

Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ray Donnelly <mingw.android@gmail.com>
path.c
test-path-utils.c
diff --git a/path.c b/path.c
index 95acbafa6883b4418f19a208cb9889f5642f3925..58d5620b98c22f85e252f48817e8cf58ffcf4dd3 100644 (file)
--- a/path.c
+++ b/path.c
@@ -676,6 +676,11 @@ const char *remove_leading_path(const char *in, const char *prefix)
  * normalized, any time "../" eats up to the prefix_len part,
  * prefix_len is reduced. In the end prefix_len is the remaining
  * prefix that has not been overridden by user pathspec.
  * normalized, any time "../" eats up to the prefix_len part,
  * prefix_len is reduced. In the end prefix_len is the remaining
  * prefix that has not been overridden by user pathspec.
+ *
+ * NEEDSWORK: This function doesn't perform normalization w.r.t. trailing '/'.
+ * For everything but the root folder itself, the normalized path should not
+ * end with a '/', then the callers need to be fixed up accordingly.
+ *
  */
 int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
 {
  */
 int normalize_path_copy_len(char *dst, const char *src, int *prefix_len)
 {
index 3dd3744a57cffd2a98be5cd551cda475c746e646..c67bf65b347810c576f80a0ac33e3b84f42e1516 100644 (file)
@@ -21,8 +21,6 @@ static int normalize_ceiling_entry(struct string_list_item *item, void *unused)
        if (normalize_path_copy(buf, ceil) < 0)
                die("Path \"%s\" could not be normalized", ceil);
        len = strlen(buf);
        if (normalize_path_copy(buf, ceil) < 0)
                die("Path \"%s\" could not be normalized", ceil);
        len = strlen(buf);
-       if (len > 1 && buf[len-1] == '/')
-               die("Normalized path \"%s\" ended with slash", buf);
        free(item->string);
        item->string = xstrdup(buf);
        return 1;
        free(item->string);
        item->string = xstrdup(buf);
        return 1;