summaryrefslogtreecommitdiff
path: root/t/t3700-add.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-04-23 10:21:25 +0200
committerJunio C Hamano <junkio@cox.net>2007-04-23 01:44:00 -0700
commitc7f34c180b7117cf60ad12a8b180eed33716e390 (patch)
treec5851c48ba95fd20ddc99c8e11e3ecc223e7c65c /t/t3700-add.sh
parent97317061c6799765c7f2f83d8e3f4f74df469793 (diff)
downloadgit-c7f34c180b7117cf60ad12a8b180eed33716e390.tar.gz
dir.c(common_prefix): Fix two bugs
The function common_prefix() is used to find the common subdirectory of a couple of pathnames. When checking if the next pathname matches up with the prefix, it incorrectly checked the whole path, not just the prefix (including the slash). Thus, the expensive part of the loop was executed always. The other bug is more serious: if the first and the last pathname in the list have a longer common prefix than the common prefix for _all_ pathnames in the list, the longer one would be chosen. This bug was probably hidden by the fact that bash's wildcard expansion sorts the results, and the code just so happens to work with sorted input. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 't/t3700-add.sh')
-rwxr-xr-xt/t3700-add.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 08e035220c..ad8cc7d4ae 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -104,4 +104,10 @@ test_expect_success 'add ignored ones with -f' '
git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig
'
+mkdir 1 1/2 1/3
+touch 1/2/a 1/3/b 1/2/c
+test_expect_success 'check correct prefix detection' '
+ git add 1/2/a 1/3/b 1/2/c
+'
+
test_done