From ea335b56d44a92b9b8be40b1465d7df65a4f736b Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 13 Aug 2008 15:34:34 -0700 Subject: [PATCH 1/2] Fix escaping of glob special characters in pathspecs match_one implements an optimized pathspec match where it only uses fnmatch if it detects glob special characters in the pattern. Unfortunately it didn't treat \ as a special character, so attempts to escape a glob special character would fail even though fnmatch() supports it. Signed-off-by: Kevin Ballard Signed-off-by: Junio C Hamano --- dir.c | 2 +- t/t3700-add.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dir.c b/dir.c index 29d1d5ba31..109e05b013 100644 --- a/dir.c +++ b/dir.c @@ -54,7 +54,7 @@ int common_prefix(const char **pathspec) static inline int special_char(unsigned char c1) { - return !c1 || c1 == '*' || c1 == '[' || c1 == '?'; + return !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\'; } /* diff --git a/t/t3700-add.sh b/t/t3700-add.sh index e83fa1f689..fcbc203e71 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -222,4 +222,12 @@ test_expect_success 'git add (add.ignore-errors = false)' ' ! ( git ls-files foo1 | grep foo1 ) ' +test_expect_success 'git add '\''fo\?bar'\'' ignores foobar' ' + git reset --hard && + touch fo\?bar foobar && + git add '\''fo\?bar'\'' && + git ls-files fo\?bar | grep -F fo\?bar && + ! ( git ls-files foobar | grep foobar ) +' + test_done From 21926fe885aa6579f7aa0e89fcb6a9064f8aa516 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 13 Aug 2008 19:49:30 -0500 Subject: [PATCH 2/2] t5304-prune: adjust file mtime based on system time rather than file mtime test-chmtime can adjust the mtime of a file based on the file's mtime, or based on the system time. For files accessed over NFS, the file's mtime is set by the NFS server, and as such may vary a great deal from the NFS client's system time if the clocks of the client and server are out of sync. Since these tests are testing the expire feature of git-prune, an incorrect mtime could cause a file to be expired or not expired incorrectly and produce a test failure. Avoid this NFS pitfall by modifying the calls to test-chmtime so that the mtime is adjusted based on the system time, rather than the file's mtime. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t5304-prune.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh index 9fd9d07000..771c0a06a4 100755 --- a/t/t5304-prune.sh +++ b/t/t5304-prune.sh @@ -21,7 +21,7 @@ test_expect_success 'prune stale packs' ' orig_pack=$(echo .git/objects/pack/*.pack) && : > .git/objects/tmp_1.pack && : > .git/objects/tmp_2.pack && - test-chmtime -86501 .git/objects/tmp_1.pack && + test-chmtime =-86501 .git/objects/tmp_1.pack && git prune --expire 1.day && test -f $orig_pack && test -f .git/objects/tmp_2.pack && @@ -39,7 +39,7 @@ test_expect_success 'prune --expire' ' git prune --expire=1.hour.ago && test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test -f $BLOB_FILE && - test-chmtime -86500 $BLOB_FILE && + test-chmtime =-86500 $BLOB_FILE && git prune --expire 1.day && test $before = $(git count-objects | sed "s/ .*//") && ! test -f $BLOB_FILE @@ -53,11 +53,11 @@ test_expect_success 'gc: implicit prune --expire' ' BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") && test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test -f $BLOB_FILE && - test-chmtime -$((86400*14-30)) $BLOB_FILE && + test-chmtime =-$((86400*14-30)) $BLOB_FILE && git gc && test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && test -f $BLOB_FILE && - test-chmtime -$((86400*14+1)) $BLOB_FILE && + test-chmtime =-$((86400*14+1)) $BLOB_FILE && git gc && test $before = $(git count-objects | sed "s/ .*//") && ! test -f $BLOB_FILE