summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 621f1b4)
raw | patch | inline | side by side (parent: 621f1b4)
author | Johannes Schindelin <johannes.schindelin@gmx.de> | |
Sat, 7 Feb 2009 13:43:03 +0000 (14:43 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Feb 2009 20:49:50 +0000 (12:49 -0800) |
Tab completion makes it easy to add a trailing slash to a submodule path.
As it is completely clear what the user actually wanted to say, be nice
and strip that slash at the end.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
As it is completely clear what the user actually wanted to say, be nice
and strip that slash at the end.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-ls-files.c | patch | blob | history | |
t/t7400-submodule-basic.sh | patch | blob | history |
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 34340312953867fdcb4ae62d530bdae3162744a5..9dec282fba6ba22e37d13bdc5e35fa4a031433b5 100644 (file)
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
return max ? xmemdupz(prev, max) : NULL;
}
+static void strip_trailing_slash_from_submodules(void)
+{
+ const char **p;
+
+ for (p = pathspec; *p != NULL; p++) {
+ int len = strlen(*p), pos;
+
+ if (len < 1 || (*p)[len - 1] != '/')
+ continue;
+ pos = cache_name_pos(*p, len - 1);
+ if (pos >= 0 && S_ISGITLINK(active_cache[pos]->ce_mode))
+ *p = xstrndup(*p, len - 1);
+ }
+}
+
/*
* Read the tree specified with --with-tree option
* (typically, HEAD) into stage #1 and then
pathspec = get_pathspec(prefix, argv + i);
+ /* be nice with submodule patsh ending in a slash */
+ read_cache();
+ if (pathspec)
+ strip_trailing_slash_from_submodules();
+
/* Verify that the pathspec matches the prefix */
if (pathspec)
prefix = verify_pathspec(prefix);
show_killed | show_modified))
show_cached = 1;
- read_cache();
if (prefix)
prune_cache(prefix);
if (with_tree) {
index 2ec7ac6a510c5b83bc1ee6ce428379beb7a8b5ef..a74f24c0db69aa964aaf0e83f8ab978ffc0cc7a2 100755 (executable)
'
+test_expect_success 'ls-files gracefully handles trailing slash' '
+
+ test "init" = "$(git ls-files init/)"
+
+'
+
test_done