X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft3700-add.sh;h=68c5ddebdf565912af5f481283980169f069a7a6;hb=6d2c1c2dc064c40f6c723e0a25b5f813732fdaff;hp=b52fde8577185adf962b70ad16efbcb7bfe46042;hpb=5c054a985a5b7e758f48353ac03582c9b2a9f919;p=git.git diff --git a/t/t3700-add.sh b/t/t3700-add.sh index b52fde857..68c5ddebd 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -81,17 +81,17 @@ test_expect_success '.gitignore test setup' ' test_expect_success '.gitignore is honored' ' git add . && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'error out when attempting to add ignored ones without -f' ' ! git add a.?? && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'error out when attempting to add ignored ones without -f' ' ! git add d.?? && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'add ignored ones with -f' ' @@ -104,9 +104,33 @@ test_expect_success 'add ignored ones with -f' ' git ls-files --error-unmatch d.ig/d.if d.ig/d.ig ' +test_expect_success 'add ignored ones with -f' ' + rm -f .git/index && + git add -f d.?? && + git ls-files --error-unmatch d.ig/d.if d.ig/d.ig +' + +test_expect_success '.gitignore with subdirectory' ' + + rm -f .git/index && + mkdir -p sub/dir && + echo "!dir/a.*" >sub/.gitignore && + >sub/a.ig && + >sub/dir/a.ig && + git add sub/dir && + git ls-files --error-unmatch sub/dir/a.ig && + rm -f .git/index && + ( + cd sub/dir && + git add . + ) && + git ls-files --error-unmatch sub/dir/a.ig +' + mkdir 1 1/2 1/3 touch 1/2/a 1/3/b 1/2/c test_expect_success 'check correct prefix detection' ' + rm -f .git/index && git add 1/2/a 1/3/b 1/2/c ' @@ -131,8 +155,8 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st ( echo "100644 $(git hash-object -w stage1) 1 file" echo "100755 $(git hash-object -w stage2) 2 file" - echo "100644 $(printf $s | git hash-object -w -t blob --stdin) 1 symlink" - echo "120000 $(printf $s | git hash-object -w -t blob --stdin) 2 symlink" + echo "100644 $(printf 1 | git hash-object -w -t blob --stdin) 1 symlink" + echo "120000 $(printf 2 | git hash-object -w -t blob --stdin) 2 symlink" ) | git update-index --index-info && git config core.filemode 0 && git config core.symlinks 0 && @@ -143,4 +167,16 @@ test_expect_success 'git add with filemode=0, symlinks=0 prefers stage 2 over st git ls-files --stage | grep "^120000 .* 0 symlink$" ' +test_expect_success 'git add --refresh' ' + >foo && git add foo && git commit -a -m "commit all" && + test -z "`git diff-index HEAD -- foo`" && + git read-tree HEAD && + case "`git diff-index HEAD -- foo`" in + :100644" "*"M foo") echo ok;; + *) echo fail; (exit 1);; + esac && + git add --refresh -- foo && + test -z "`git diff-index HEAD -- foo`" +' + test_done