diff options
Diffstat (limited to 't')
35 files changed, 828 insertions, 299 deletions
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 3c12b05d60..de3762e247 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -52,8 +52,15 @@ Alias /auth/ www/auth/ <Location /smart_noexport/> SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} </Location> +<Location /smart_custom_env/> + SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} + SetEnv GIT_HTTP_EXPORT_ALL + SetEnv GIT_COMMITTER_NAME "Custom User" + SetEnv GIT_COMMITTER_EMAIL custom@example.com +</Location> ScriptAlias /smart/ ${GIT_EXEC_PATH}/git-http-backend/ ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/ +ScriptAlias /smart_custom_env/ ${GIT_EXEC_PATH}/git-http-backend/ <Directory ${GIT_EXEC_PATH}> Options None </Directory> diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 8d4938f019..17e969df60 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -34,4 +34,17 @@ test_expect_success POSIXPERM 'run_command reports EACCES' ' grep "fatal: cannot exec.*hello.sh" err ' +test_expect_success POSIXPERM 'unreadable directory in PATH' ' + mkdir local-command && + test_when_finished "chmod u+rwx local-command && rm -fr local-command" && + git config alias.nitfol "!echo frotz" && + chmod a-rx local-command && + ( + PATH=./local-command:$PATH && + git nitfol >actual + ) && + echo frotz >expect && + test_cmp expect actual +' + test_done diff --git a/t/t0303-credential-external.sh b/t/t0303-credential-external.sh index 267f4c8ba3..f028fd1418 100755 --- a/t/t0303-credential-external.sh +++ b/t/t0303-credential-external.sh @@ -1,39 +1,60 @@ #!/bin/sh -test_description='external credential helper tests' -. ./test-lib.sh -. "$TEST_DIRECTORY"/lib-credential.sh +test_description='external credential helper tests -pre_test() { - test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" || - eval "$GIT_TEST_CREDENTIAL_HELPER_SETUP" +This is a tool for authors of external helper tools to sanity-check +their helpers. If you have written the "git-credential-foo" helper, +you check it with: + + make GIT_TEST_CREDENTIAL_HELPER=foo t0303-credential-external.sh + +This assumes that your helper is capable of both storing and +retrieving credentials (some helpers may be read-only, and they will +fail these tests). + +Please note that the individual tests do not verify all of the +preconditions themselves, but rather build on each other. A failing +test means that tests later in the sequence can return false "OK" +results. + +If your helper supports time-based expiration with a configurable +timeout, you can test that feature with: + + make GIT_TEST_CREDENTIAL_HELPER=foo \ + GIT_TEST_CREDENTIAL_HELPER_TIMEOUT="foo --timeout=1" \ + t0303-credential-external.sh - # clean before the test in case there is cruft left - # over from a previous run that would impact results - helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER" -} +If your helper requires additional setup before the tests are started, +you can set GIT_TEST_CREDENTIAL_HELPER_SETUP to a sequence of shell +commands. +' -post_test() { - # clean afterwards so that we are good citizens - # and don't leave cruft in the helper's storage, which - # might be long-term system storage - helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER" -} +. ./test-lib.sh +. "$TEST_DIRECTORY"/lib-credential.sh if test -z "$GIT_TEST_CREDENTIAL_HELPER"; then - say "# skipping external helper tests (set GIT_TEST_CREDENTIAL_HELPER)" -else - pre_test - helper_test "$GIT_TEST_CREDENTIAL_HELPER" - post_test + skip_all="used to test external credential helpers" + test_done fi +test -z "$GIT_TEST_CREDENTIAL_HELPER_SETUP" || + eval "$GIT_TEST_CREDENTIAL_HELPER_SETUP" + +# clean before the test in case there is cruft left +# over from a previous run that would impact results +helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER" + +helper_test "$GIT_TEST_CREDENTIAL_HELPER" + if test -z "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT"; then - say "# skipping external helper timeout tests" + say "# skipping timeout tests (GIT_TEST_CREDENTIAL_HELPER_TIMEOUT not set)" else - pre_test helper_test_timeout "$GIT_TEST_CREDENTIAL_HELPER_TIMEOUT" - post_test fi +# clean afterwards so that we are good citizens +# and don't leave cruft in the helper's storage, which +# might be long-term system storage +helper_test_clean "$GIT_TEST_CREDENTIAL_HELPER" + test_done diff --git a/t/t1050-large.sh b/t/t1050-large.sh index 29d6024b7f..4d127f19b7 100755 --- a/t/t1050-large.sh +++ b/t/t1050-large.sh @@ -6,11 +6,15 @@ test_description='adding and checking out large blobs' . ./test-lib.sh test_expect_success setup ' - git config core.bigfilethreshold 200k && + # clone does not allow us to pass core.bigfilethreshold to + # new repos, so set core.bigfilethreshold globally + git config --global core.bigfilethreshold 200k && echo X | dd of=large1 bs=1k seek=2000 && echo X | dd of=large2 bs=1k seek=2000 && echo X | dd of=large3 bs=1k seek=2000 && - echo Y | dd of=huge bs=1k seek=2500 + echo Y | dd of=huge bs=1k seek=2500 && + GIT_ALLOC_LIMIT=1500 && + export GIT_ALLOC_LIMIT ' test_expect_success 'add a large file or two' ' @@ -100,4 +104,34 @@ test_expect_success 'packsize limit' ' ) ' +test_expect_success 'diff --raw' ' + git commit -q -m initial && + echo modified >>large1 && + git add large1 && + git commit -q -m modified && + git diff --raw HEAD^ +' + +test_expect_success 'hash-object' ' + git hash-object large1 +' + +test_expect_success 'cat-file a large file' ' + git cat-file blob :large1 >/dev/null +' + +test_expect_success 'cat-file a large file from a tag' ' + git tag -m largefile largefiletag :large1 && + git cat-file blob largefiletag >/dev/null +' + +test_expect_success 'git-show a large file' ' + git show :large1 >/dev/null + +' + +test_expect_success 'repack' ' + git repack -ad +' + test_done diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index 9f00ada5f7..c53c9f65eb 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -15,184 +15,204 @@ p0='no-funny' p1='tabs ," (dq) and spaces' p2='just space' -cat >"$p0" <<\EOF -1. A quick brown fox jumps over the lazy cat, oops dog. -2. A quick brown fox jumps over the lazy cat, oops dog. -3. A quick brown fox jumps over the lazy cat, oops dog. -EOF - -cat 2>/dev/null >"$p1" "$p0" -echo 'Foo Bar Baz' >"$p2" +test_expect_success 'setup' ' + cat >"$p0" <<-\EOF && + 1. A quick brown fox jumps over the lazy cat, oops dog. + 2. A quick brown fox jumps over the lazy cat, oops dog. + 3. A quick brown fox jumps over the lazy cat, oops dog. + EOF + + { cat "$p0" >"$p1" || :; } && + { echo "Foo Bar Baz" >"$p2" || :; } && + + if test -f "$p1" && cmp "$p0" "$p1" + then + test_set_prereq TABS_IN_FILENAMES + fi +' -if test -f "$p1" && cmp "$p0" "$p1" +if ! test_have_prereq TABS_IN_FILENAMES then - test_set_prereq TABS_IN_FILENAMES -else # since FAT/NTFS does not allow tabs in filenames, skip this test - say 'Your filesystem does not allow tabs in filenames' + skip_all='Your filesystem does not allow tabs in filenames' + test_done fi -test_expect_success TABS_IN_FILENAMES 'setup expect' " -echo 'just space -no-funny' >expected -" +test_expect_success 'setup: populate index and tree' ' + git update-index --add "$p0" "$p2" && + t0=$(git write-tree) +' -test_expect_success TABS_IN_FILENAMES 'git ls-files no-funny' \ - 'git update-index --add "$p0" "$p2" && +test_expect_success 'ls-files prints space in filename verbatim' ' + printf "%s\n" "just space" no-funny >expected && git ls-files >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -t0=`git write-tree` && -echo "$t0" >t0 && + test_cmp expected current +' -cat > expected <<\EOF -just space -no-funny -"tabs\t,\" (dq) and spaces" -EOF +test_expect_success 'setup: add funny filename' ' + git update-index --add "$p1" && + t1=$(git write-tree) ' -test_expect_success TABS_IN_FILENAMES 'git ls-files with-funny' \ - 'git update-index --add "$p1" && +test_expect_success 'ls-files quotes funny filename' ' + cat >expected <<-\EOF && + just space + no-funny + "tabs\t,\" (dq) and spaces" + EOF git ls-files >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' " -echo 'just space -no-funny -tabs ,\" (dq) and spaces' >expected -" - -test_expect_success TABS_IN_FILENAMES 'git ls-files -z with-funny' \ - 'git ls-files -z | perl -pe y/\\000/\\012/ >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -t1=`git write-tree` && -echo "$t1" >t1 && - -cat > expected <<\EOF -just space -no-funny -"tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git ls-tree with funny' \ - 'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat > expected <<\EOF -A "tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-index with-funny' \ - 'git diff-index --name-status $t0 >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree with-funny' \ - 'git diff-tree --name-status $t0 $t1 >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' " -echo 'A -tabs ,\" (dq) and spaces' >expected -" - -test_expect_success TABS_IN_FILENAMES 'git diff-index -z with-funny' \ - 'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree -z with-funny' \ - 'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat > expected <<\EOF -CNUM no-funny "tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree -C with-funny' \ - 'git diff-tree -C --find-copies-harder --name-status \ - $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat > expected <<\EOF -RNUM no-funny "tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \ - 'git update-index --force-remove "$p0" && - git diff-index -M --name-status \ - $t0 | sed -e 's/^R[0-9]*/RNUM/' >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat > expected <<\EOF -diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" -similarity index NUM% -rename from no-funny -rename to "tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \ - 'git diff-index -M -p $t0 | - sed -e "s/index [0-9]*%/index NUM%/" >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -chmod +x "$p1" && -cat > expected <<\EOF -diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" -old mode 100644 -new mode 100755 -similarity index NUM% -rename from no-funny -rename to "tabs\t,\" (dq) and spaces" -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny' \ - 'git diff-index -M -p $t0 | - sed -e "s/index [0-9]*%/index NUM%/" >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat >expected <<\EOF - "tabs\t,\" (dq) and spaces" - 1 file changed, 0 insertions(+), 0 deletions(-) -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree rename with-funny applied' \ - 'git diff-index -M -p $t0 | - git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'setup expect' ' -cat > expected <<\EOF - no-funny - "tabs\t,\" (dq) and spaces" - 2 files changed, 3 insertions(+), 3 deletions(-) -EOF -' - -test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny applied' \ - 'git diff-index -p $t0 | - git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - test_cmp expected current' - -test_expect_success TABS_IN_FILENAMES 'git apply non-git diff' \ - 'git diff-index -p $t0 | - sed -ne "/^[-+@]/p" | - git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current && - test_cmp expected current' + test_cmp expected current +' + +test_expect_success 'ls-files -z does not quote funny filename' ' + cat >expected <<-\EOF && + just space + no-funny + tabs ," (dq) and spaces + EOF + git ls-files -z >ls-files.z && + perl -pe "y/\000/\012/" <ls-files.z >current && + test_cmp expected current +' + +test_expect_success 'ls-tree quotes funny filename' ' + cat >expected <<-\EOF && + just space + no-funny + "tabs\t,\" (dq) and spaces" + EOF + git ls-tree -r $t1 >ls-tree && + sed -e "s/^[^ ]* //" <ls-tree >current && + test_cmp expected current +' + +test_expect_success 'diff-index --name-status quotes funny filename' ' + cat >expected <<-\EOF && + A "tabs\t,\" (dq) and spaces" + EOF + git diff-index --name-status $t0 >current && + test_cmp expected current +' + +test_expect_success 'diff-tree --name-status quotes funny filename' ' + cat >expected <<-\EOF && + A "tabs\t,\" (dq) and spaces" + EOF + git diff-tree --name-status $t0 $t1 >current && + test_cmp expected current +' + +test_expect_success 'diff-index -z does not quote funny filename' ' + cat >expected <<-\EOF && + A + tabs ," (dq) and spaces + EOF + git diff-index -z --name-status $t0 >diff-index.z && + perl -pe "y/\000/\012/" <diff-index.z >current && + test_cmp expected current +' + +test_expect_success 'diff-tree -z does not quote funny filename' ' + cat >expected <<-\EOF && + A + tabs ," (dq) and spaces + EOF + git diff-tree -z --name-status $t0 $t1 >diff-tree.z && + perl -pe y/\\000/\\012/ <diff-tree.z >current && + test_cmp expected current +' + +test_expect_success 'diff-tree --find-copies-harder quotes funny filename' ' + cat >expected <<-\EOF && + CNUM no-funny "tabs\t,\" (dq) and spaces" + EOF + git diff-tree -C --find-copies-harder --name-status $t0 $t1 >out && + sed -e "s/^C[0-9]*/CNUM/" <out >current && + test_cmp expected current +' + +test_expect_success 'setup: remove unfunny index entry' ' + git update-index --force-remove "$p0" +' + +test_expect_success 'diff-tree -M quotes funny filename' ' + cat >expected <<-\EOF && + RNUM no-funny "tabs\t,\" (dq) and spaces" + EOF + git diff-index -M --name-status $t0 >out && + sed -e "s/^R[0-9]*/RNUM/" <out >current && + test_cmp expected current +' + +test_expect_success 'diff-index -M -p quotes funny filename' ' + cat >expected <<-\EOF && + diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" + similarity index NUM% + rename from no-funny + rename to "tabs\t,\" (dq) and spaces" + EOF + git diff-index -M -p $t0 >diff && + sed -e "s/index [0-9]*%/index NUM%/" <diff >current && + test_cmp expected current +' + +test_expect_success 'setup: mode change' ' + chmod +x "$p1" +' + +test_expect_success 'diff-index -M -p with mode change quotes funny filename' ' + cat >expected <<-\EOF && + diff --git a/no-funny "b/tabs\t,\" (dq) and spaces" + old mode 100644 + new mode 100755 + similarity index NUM% + rename from no-funny + rename to "tabs\t,\" (dq) and spaces" + EOF + git diff-index -M -p $t0 >diff && + sed -e "s/index [0-9]*%/index NUM%/" <diff >current && + test_cmp expected current +' + +test_expect_success 'diffstat for rename quotes funny filename' ' + cat >expected <<-\EOF && + "tabs\t,\" (dq) and spaces" + 1 file changed, 0 insertions(+), 0 deletions(-) + EOF + git diff-index -M -p $t0 >diff && + git apply --stat <diff >diffstat && + sed -e "s/|.*//" -e "s/ *\$//" <diffstat >current && + test_i18ncmp expected current +' + +test_expect_success 'numstat for rename quotes funny filename' ' + cat >expected <<-\EOF && + 0 0 "tabs\t,\" (dq) and spaces" + EOF + git diff-index -M -p $t0 >diff && + git apply --numstat <diff >current && + test_cmp expected current +' + +test_expect_success 'numstat without -M quotes funny filename' ' + cat >expected <<-\EOF && + 0 3 no-funny + 3 0 "tabs\t,\" (dq) and spaces" + EOF + git diff-index -p $t0 >diff && + git apply --numstat <diff >current && + test_cmp expected current +' + +test_expect_success 'numstat for non-git rename diff quotes funny filename' ' + cat >expected <<-\EOF && + 0 3 no-funny + 3 0 "tabs\t,\" (dq) and spaces" + EOF + git diff-index -p $t0 >git-diff && + sed -ne "/^[-+@]/p" <git-diff >diff && + git apply --numstat <diff >current && + test_cmp expected current +' test_done diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 4367197953..195bb97f85 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -324,7 +324,7 @@ y and z notes on 4th commit EOF git notes merge --commit && # No .git/NOTES_MERGE_* files left - test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && + test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && @@ -386,7 +386,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol test_expect_success 'abort notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left - test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && + test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && @@ -453,7 +453,7 @@ EOF # Finalize merge git notes merge --commit && # No .git/NOTES_MERGE_* files left - test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && + test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && @@ -542,7 +542,7 @@ EOF test_expect_success 'resolve situation by aborting the notes merge' ' git notes merge --abort && # No .git/NOTES_MERGE_* files left - test_must_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && + test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && test_cmp /dev/null output && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && @@ -553,4 +553,23 @@ test_expect_success 'resolve situation by aborting the notes merge' ' verify_notes z ' +cat >expect_notes <<EOF +foo +bar +EOF + +test_expect_success 'switch cwd before committing notes merge' ' + git notes add -m foo HEAD && + git notes --ref=other add -m bar HEAD && + test_must_fail git notes merge refs/notes/other && + ( + cd .git/NOTES_MERGE_WORKTREE && + echo "foo" > $(git rev-parse HEAD) && + echo "bar" >> $(git rev-parse HEAD) && + git notes merge --commit + ) && + git notes show HEAD > actual_notes && + test_cmp expect_notes actual_notes +' + test_done diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh index 1b3a344158..75f7ff4f2f 100755 --- a/t/t3508-cherry-pick-many-commits.sh +++ b/t/t3508-cherry-pick-many-commits.sh @@ -35,6 +35,16 @@ test_expect_success setup ' ' test_expect_success 'cherry-pick first..fourth works' ' + git checkout -f master && + git reset --hard first && + test_tick && + git cherry-pick first..fourth && + git diff --quiet other && + git diff --quiet HEAD other && + check_head_differs_from fourth +' + +test_expect_success 'output to keep user entertained during multi-pick' ' cat <<-\EOF >expected && [master OBJID] second Author: A U Thor <author@example.com> @@ -51,15 +61,22 @@ test_expect_success 'cherry-pick first..fourth works' ' git reset --hard first && test_tick && git cherry-pick first..fourth >actual && + sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && + test_line_count -ge 3 actual.fuzzy && + test_i18ncmp expected actual.fuzzy +' + +test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' + git checkout -f master && + git reset --hard first && + test_tick && + git cherry-pick --strategy resolve first..fourth && git diff --quiet other && git diff --quiet HEAD other && - - sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && - test_cmp expected actual.fuzzy && check_head_differs_from fourth ' -test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' +test_expect_success 'output during multi-pick indicates merge strategy' ' cat <<-\EOF >expected && Trying simple merge. [master OBJID] second @@ -79,11 +96,8 @@ test_expect_success 'cherry-pick --strategy resolve first..fourth works' ' git reset --hard first && test_tick && git cherry-pick --strategy resolve first..fourth >actual && - git diff --quiet other && - git diff --quiet HEAD other && sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy && - test_cmp expected actual.fuzzy && - check_head_differs_from fourth + test_i18ncmp expected actual.fuzzy ' test_expect_success 'cherry-pick --ff first..fourth works' ' diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 9e236f9cc0..098a6ae4a0 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -330,4 +330,30 @@ test_expect_success PERL 'split hunk "add -p (edit)"' ' ! grep "^+15" actual ' +test_expect_success 'patch mode ignores unmerged entries' ' + git reset --hard && + test_commit conflict && + test_commit non-conflict && + git checkout -b side && + test_commit side conflict.t && + git checkout master && + test_commit master conflict.t && + test_must_fail git merge side && + echo changed >non-conflict.t && + echo y | git add -p >output && + ! grep a/conflict.t output && + cat >expected <<-\EOF && + * Unmerged path conflict.t + diff --git a/non-conflict.t b/non-conflict.t + index f766221..5ea2ed4 100644 + --- a/non-conflict.t + +++ b/non-conflict.t + @@ -1 +1 @@ + -non-conflict + +changed + EOF + git diff --cached >diff && + test_cmp expected diff +' + test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 663c60a12e..3addb804d5 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -432,7 +432,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' ' test $(git ls-files --modified | wc -l) -eq 1 ' -test_expect_success 'stash show - stashes on stack, stash-like argument' ' +test_expect_success 'stash show format defaults to --stat' ' git stash clear && test_when_finished "git reset --hard HEAD" && git reset --hard && @@ -447,6 +447,21 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' ' 1 file changed, 1 insertion(+) EOF git stash show ${STASH_ID} >actual && + test_i18ncmp expected actual +' + +test_expect_success 'stash show - stashes on stack, stash-like argument' ' + git stash clear && + test_when_finished "git reset --hard HEAD" && + git reset --hard && + echo foo >> file && + git stash && + test_when_finished "git stash drop" && + echo bar >> file && + STASH_ID=$(git stash create) && + git reset --hard && + echo "1 0 file" >expected && + git stash show --numstat ${STASH_ID} >actual && test_cmp expected actual ' @@ -480,11 +495,8 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' ' echo foo >> file && STASH_ID=$(git stash create) && git reset --hard && - cat >expected <<-EOF && - file | 1 + - 1 file changed, 1 insertion(+) - EOF - git stash show ${STASH_ID} >actual && + echo "1 0 file" >expected && + git stash show --numstat ${STASH_ID} >actual && test_cmp expected actual ' diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index 2d9f9a0cf1..ed24ddd88a 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -8,6 +8,13 @@ test_description='Binary diff and apply . ./test-lib.sh +cat >expect.binary-numstat <<\EOF +1 1 a +- - b +1 1 c +- - d +EOF + test_expect_success 'prepare repository' \ 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d && git update-index --add a b c d && @@ -23,13 +30,23 @@ cat > expected <<\EOF d | Bin 4 files changed, 2 insertions(+), 2 deletions(-) EOF -test_expect_success 'diff without --binary' \ - 'git diff | git apply --stat --summary >current && - test_cmp expected current' +test_expect_success '"apply --stat" output for binary file change' ' + git diff >diff && + git apply --stat --summary <diff >current && + test_i18ncmp expected current +' -test_expect_success 'diff with --binary' \ - 'git diff --binary | git apply --stat --summary >current && - test_cmp expected current' +test_expect_success 'apply --numstat notices binary file change' ' + git diff >diff && + git apply --numstat <diff >current && + test_cmp expect.binary-numstat current +' + +test_expect_success 'apply --numstat understands diff --binary format' ' + git diff --binary >diff && + git apply --numstat <diff >current && + test_cmp expect.binary-numstat current +' # apply needs to be able to skip the binary material correctly # in order to report the line number of a corrupt patch. diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 93a6f20871..e77c09c37e 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -128,7 +128,12 @@ do } >"$actual" && if test -f "$expect" then - test_cmp "$expect" "$actual" && + case $cmd in + *format-patch* | *-stat*) + test_i18ncmp "$expect" "$actual";; + *) + test_cmp "$expect" "$actual";; + esac && rm -f "$actual" else # this is to help developing new tests. diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 7dfe716cf9..b473b6d6eb 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -518,11 +518,6 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' ' cat > expect << EOF ---- - file | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/file b/file index 40f36c6..2dc5c23 100644 --- a/file +++ b/file @@ -537,7 +532,9 @@ EOF test_expect_success 'format-patch respects -U' ' git format-patch -U4 -2 && - sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + sed -e "1,/^diff/d" -e "/^+5/q" \ + <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \ + >output && test_cmp expect output ' diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index ab0c2f0574..3ec71184ba 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -57,22 +57,33 @@ test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' ' test_cmp expect actual ' -test_expect_success TABS_IN_FILENAMES 'setup expected files' ' -cat >expect <<\EOF - pathname.1 => "Rpathname\twith HT.0" | 0 - pathname.3 => "Rpathname\nwith LF.0" | 0 - "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0 - pathname.2 => Rpathname with SP.0 | 0 - "pathname\twith HT.2" => Rpathname with SP.1 | 0 - pathname.0 => Rpathname.0 | 0 - "pathname\twith HT.0" => Rpathname.1 | 0 - 7 files changed, 0 insertions(+), 0 deletions(-) -EOF +test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' ' + cat >expect <<-\EOF && + 0 0 pathname.1 => "Rpathname\twith HT.0" + 0 0 pathname.3 => "Rpathname\nwith LF.0" + 0 0 "pathname\twith HT.3" => "Rpathname\nwith LF.1" + 0 0 pathname.2 => Rpathname with SP.0 + 0 0 "pathname\twith HT.2" => Rpathname with SP.1 + 0 0 pathname.0 => Rpathname.0 + 0 0 "pathname\twith HT.0" => Rpathname.1 + EOF + git diff --numstat -M HEAD >actual && + test_cmp expect actual ' test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' ' + cat >expect <<-\EOF && + pathname.1 => "Rpathname\twith HT.0" | 0 + pathname.3 => "Rpathname\nwith LF.0" | 0 + "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0 + pathname.2 => Rpathname with SP.0 | 0 + "pathname\twith HT.2" => Rpathname with SP.1 | 0 + pathname.0 => Rpathname.0 | 0 + "pathname\twith HT.0" => Rpathname.1 | 0 + 7 files changed, 0 insertions(+), 0 deletions(-) + EOF git diff --stat -M HEAD >actual && - test_cmp expect actual + test_i18ncmp expect actual ' test_done diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh index 4ac162cfcf..06b05df848 100755 --- a/t/t4030-diff-textconv.sh +++ b/t/t4030-diff-textconv.sh @@ -91,7 +91,11 @@ EOF test_expect_success 'diffstat does not run textconv' ' echo file diff=fail >.gitattributes && git diff --stat HEAD^ HEAD >actual && - test_cmp expect.stat actual + test_i18ncmp expect.stat actual && + + head -n1 <expect.stat >expect.line1 && + head -n1 <actual >actual.line1 && + test_cmp expect.line1 actual.line1 ' # restore working setup echo file diff=foo >.gitattributes diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh index 7d7470f21b..c8296fa4fc 100755 --- a/t/t4031-diff-rewrite-binary.sh +++ b/t/t4031-diff-rewrite-binary.sh @@ -44,10 +44,16 @@ test_expect_success 'rewrite diff can show binary patch' ' grep "GIT binary patch" diff ' -test_expect_success 'rewrite diff --stat shows binary changes' ' +test_expect_success 'rewrite diff --numstat shows binary changes' ' + git diff -B --numstat --summary >diff && + grep -e "- - " diff && + grep " rewrite file" diff +' + +test_expect_success 'diff --stat counts binary rewrite as 0 lines' ' git diff -B --stat --summary >diff && grep "Bin" diff && - grep "0 insertions.*0 deletions" diff && + test_i18ngrep "0 insertions.*0 deletions" diff && grep " rewrite file" diff ' diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 5c2012111c..30d42cb3bf 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -3,6 +3,7 @@ test_description='word diff colors' . ./test-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh cat >pre.simple <<-\EOF h(4) @@ -293,6 +294,10 @@ test_expect_success '--word-diff=none' ' word_diff --word-diff=plain --word-diff=none ' +test_expect_success 'unset default driver' ' + test_unconfig diff.wordregex +' + test_language_driver bibtex test_language_driver cpp test_language_driver csharp @@ -348,4 +353,35 @@ test_expect_success 'word-diff with no newline at EOF' ' word_diff --word-diff=plain ' +test_expect_success 'setup history with two files' ' + echo "a b; c" >a.tex && + echo "a b; c" >z.txt && + git add a.tex z.txt && + git commit -minitial && + + # modify both + echo "a bx; c" >a.tex && + echo "a bx; c" >z.txt && + git commit -mmodified -a +' + +test_expect_success 'wordRegex for the first file does not apply to the second' ' + echo "*.tex diff=tex" >.gitattributes && + git config diff.tex.wordRegex "[a-z]+|." && + cat >expect <<-\EOF && + diff --git a/a.tex b/a.tex + --- a/a.tex + +++ b/a.tex + @@ -1 +1 @@ + a [-b-]{+bx+}; c + diff --git a/z.txt b/z.txt + --- a/z.txt + +++ b/z.txt + @@ -1 +1 @@ + a [-b;-]{+bx;+} c + EOF + git diff --word-diff HEAD~ >actual && + compare_diff_patch expect actual +' + test_done diff --git a/t/t4043-diff-rename-binary.sh b/t/t4043-diff-rename-binary.sh index 06012811a1..2a2cf91352 100755 --- a/t/t4043-diff-rename-binary.sh +++ b/t/t4043-diff-rename-binary.sh @@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' ' ' cat > expected <<\EOF - bar => sub/bar | Bin 5 -> 5 bytes - foo => sub/foo | 0 - 2 files changed, 0 insertions(+), 0 deletions(-) +- - bar => sub/bar +0 0 foo => sub/foo diff --git a/bar b/sub/bar similarity index 100% @@ -38,7 +37,8 @@ rename to sub/foo EOF test_expect_success 'git show -C -C report renames' ' - git show -C -C --raw --binary --stat | tail -n 12 > current && + git show -C -C --raw --binary --numstat >patch-with-stat && + tail -n 11 patch-with-stat >current && test_cmp expected current ' diff --git a/t/t4045-diff-relative.sh b/t/t4045-diff-relative.sh index bd119be106..18fadcf06e 100755 --- a/t/t4045-diff-relative.sh +++ b/t/t4045-diff-relative.sh @@ -29,6 +29,18 @@ test_expect_success "-p $*" " " } +check_numstat() { +expect=$1; shift +cat >expected <<EOF +1 0 $expect +EOF +test_expect_success "--numstat $*" " + echo '1 0 $expect' >expected && + git diff --numstat $* HEAD^ >actual && + test_cmp expected actual +" +} + check_stat() { expect=$1; shift cat >expected <<EOF @@ -37,7 +49,7 @@ cat >expected <<EOF EOF test_expect_success "--stat $*" " git diff --stat $* HEAD^ >actual && - test_cmp expected actual + test_i18ncmp expected actual " } @@ -52,7 +64,7 @@ test_expect_success "--raw $*" " " } -for type in diff stat raw; do +for type in diff numstat stat raw; do check_$type file2 --relative=subdir/ check_$type file2 --relative=subdir check_$type dir/file2 --relative=sub diff --git a/t/t4047-diff-dirstat.sh b/t/t4047-diff-dirstat.sh index 29e80a58cd..ed7e093366 100755 --- a/t/t4047-diff-dirstat.sh +++ b/t/t4047-diff-dirstat.sh @@ -252,50 +252,47 @@ EOF ' cat <<EOF >expect_diff_stat - changed/text | 2 +- - dst/copy/changed/text | 10 ++++++++++ - dst/copy/rearranged/text | 10 ++++++++++ - dst/copy/unchanged/text | 10 ++++++++++ - dst/move/changed/text | 10 ++++++++++ - dst/move/rearranged/text | 10 ++++++++++ - dst/move/unchanged/text | 10 ++++++++++ - rearranged/text | 2 +- - src/move/changed/text | 10 ---------- - src/move/rearranged/text | 10 ---------- - src/move/unchanged/text | 10 ---------- - 11 files changed, 62 insertions(+), 32 deletions(-) +1 1 changed/text +10 0 dst/copy/changed/text +10 0 dst/copy/rearranged/text +10 0 dst/copy/unchanged/text +10 0 dst/move/changed/text +10 0 dst/move/rearranged/text +10 0 dst/move/unchanged/text +1 1 rearranged/text +0 10 src/move/changed/text +0 10 src/move/rearranged/text +0 10 src/move/unchanged/text EOF cat <<EOF >expect_diff_stat_M - changed/text | 2 +- - dst/copy/changed/text | 10 ++++++++++ - dst/copy/rearranged/text | 10 ++++++++++ - dst/copy/unchanged/text | 10 ++++++++++ - {src => dst}/move/changed/text | 2 +- - {src => dst}/move/rearranged/text | 2 +- - {src => dst}/move/unchanged/text | 0 - rearranged/text | 2 +- - 8 files changed, 34 insertions(+), 4 deletions(-) +1 1 changed/text +10 0 dst/copy/changed/text +10 0 dst/copy/rearranged/text +10 0 dst/copy/unchanged/text +1 1 {src => dst}/move/changed/text +1 1 {src => dst}/move/rearranged/text +0 0 {src => dst}/move/unchanged/text +1 1 rearranged/text EOF cat <<EOF >expect_diff_stat_CC - changed/text | 2 +- - {src => dst}/copy/changed/text | 2 +- - {src => dst}/copy/rearranged/text | 2 +- - {src => dst}/copy/unchanged/text | 0 - {src => dst}/move/changed/text | 2 +- - {src => dst}/move/rearranged/text | 2 +- - {src => dst}/move/unchanged/text | 0 - rearranged/text | 2 +- - 8 files changed, 6 insertions(+), 6 deletions(-) -EOF - -test_expect_success 'sanity check setup (--stat)' ' - git diff --stat HEAD^..HEAD >actual_diff_stat && +1 1 changed/text +1 1 {src => dst}/copy/changed/text +1 1 {src => dst}/copy/rearranged/text +0 0 {src => dst}/copy/unchanged/text +1 1 {src => dst}/move/changed/text +1 1 {src => dst}/move/rearranged/text +0 0 {src => dst}/move/unchanged/text +1 1 rearranged/text +EOF + +test_expect_success 'sanity check setup (--numstat)' ' + git diff --numstat HEAD^..HEAD >actual_diff_stat && test_cmp expect_diff_stat actual_diff_stat && - git diff --stat -M HEAD^..HEAD >actual_diff_stat_M && + git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M && test_cmp expect_diff_stat_M actual_diff_stat_M && - git diff --stat -C -C HEAD^..HEAD >actual_diff_stat_CC && + git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC && test_cmp expect_diff_stat_CC actual_diff_stat_CC ' diff --git a/t/t4049-diff-stat-count.sh b/t/t4049-diff-stat-count.sh index a6d1887536..591ffbc075 100755 --- a/t/t4049-diff-stat-count.sh +++ b/t/t4049-diff-stat-count.sh @@ -19,7 +19,7 @@ test_expect_success setup ' 2 files changed, 2 insertions(+) EOF git diff --stat --stat-count=2 >actual && - test_cmp expect actual + test_i18ncmp expect actual ' test_done diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh index 9b433de836..744b8e51be 100755 --- a/t/t4100-apply-stat.sh +++ b/t/t4100-apply-stat.sh @@ -17,13 +17,13 @@ do test_expect_success "$title" ' git apply --stat --summary \ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current && - test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current + test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' test_expect_success "$title with recount" ' sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" | git apply --recount --stat --summary >current && - test_cmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current + test_i18ncmp "$TEST_DIRECTORY"/t4100/t-apply-$num.expect current ' done <<\EOF rename diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index 2af8947eeb..432f98c357 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -216,7 +216,7 @@ test_expect_success 'pull request format' ' git request-pull initial "$downstream_url" >../request ) && <request sed -nf fuzz.sed >request.fuzzy && - test_cmp expect request.fuzzy + test_i18ncmp expect request.fuzzy ' diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh new file mode 100755 index 0000000000..c334c51a07 --- /dev/null +++ b/t/t5528-push-default.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +test_description='check various push.default settings' +. ./test-lib.sh + +test_expect_success 'setup bare remotes' ' + git init --bare repo1 && + git remote add parent1 repo1 && + git init --bare repo2 && + git remote add parent2 repo2 && + test_commit one && + git push parent1 HEAD && + git push parent2 HEAD +' + +test_expect_success '"upstream" pushes to configured upstream' ' + git checkout master && + test_config branch.master.remote parent1 && + test_config branch.master.merge refs/heads/foo && + test_config push.default upstream && + test_commit two && + git push && + echo two >expect && + git --git-dir=repo1 log -1 --format=%s foo >actual && + test_cmp expect actual +' + +test_expect_success '"upstream" does not push on unconfigured remote' ' + git checkout master && + test_unconfig branch.master.remote && + test_config push.default upstream && + test_commit three && + test_must_fail git push +' + +test_expect_success '"upstream" does not push on unconfigured branch' ' + git checkout master && + test_config branch.master.remote parent1 && + test_unconfig branch.master.merge && + test_config push.default upstream + test_commit four && + test_must_fail git push +' + +test_expect_success '"upstream" does not push when remotes do not match' ' + git checkout master && + test_config branch.master.remote parent1 && + test_config branch.master.merge refs/heads/foo && + test_config push.default upstream && + test_commit five && + test_must_fail git push parent2 +' + +test_done diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh index 57c3e48dda..5b170be2c0 100755 --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@ -30,6 +30,7 @@ test_expect_success 'setup remote repository' ' git clone --bare test_repo test_repo.git && cd test_repo.git && git config http.receivepack true && + git config core.logallrefupdates true && ORIG_HEAD=$(git rev-parse --verify HEAD) && cd - && mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH" @@ -222,5 +223,25 @@ test_expect_success TTY 'quiet push' ' test_cmp /dev/null output ' +test_expect_success 'http push gives sane defaults to reflog' ' + cd "$ROOT_PATH"/test_repo_clone && + test_commit reflog-test && + git push "$HTTPD_URL"/smart/test_repo.git && + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \ + log -g -1 --format="%gn <%ge>" >actual && + echo "anonymous <anonymous@http.127.0.0.1>" >expect && + test_cmp expect actual +' + +test_expect_success 'http push respects GIT_COMMITTER_* in reflog' ' + cd "$ROOT_PATH"/test_repo_clone && + test_commit custom-reflog-test && + git push "$HTTPD_URL"/smart_custom_env/test_repo.git && + git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \ + log -g -1 --format="%gn <%ge>" >actual && + echo "Custom User <custom@example.com>" >expect && + test_cmp expect actual +' + stop_httpd test_done diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 9d8584e957..1104249182 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -884,4 +884,20 @@ test_expect_success 'no spurious "refusing to lose untracked" message' ' ! grep "refusing to lose untracked file" errors.txt ' +test_expect_success 'do not follow renames for empty files' ' + git checkout -f -b empty-base && + >empty1 && + git add empty1 && + git commit -m base && + echo content >empty1 && + git add empty1 && + git commit -m fill && + git checkout -b empty-topic HEAD^ && + git mv empty1 empty2 && + git commit -m rename && + test_must_fail git merge empty-base && + >expect && + test_cmp expect empty2 +' + test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 9a16806921..9b50f54cc2 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -35,15 +35,18 @@ test_expect_success setup ' echo "l3" >two && test_tick && - git commit -a -m "Left #3" && + GIT_COMMITTER_NAME="Another Committer" \ + GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #3" && echo "l4" >two && test_tick && - git commit -a -m "Left #4" && + GIT_COMMITTER_NAME="Another Committer" \ + GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #4" && echo "l5" >two && test_tick && - git commit -a -m "Left #5" && + GIT_COMMITTER_NAME="Another Committer" \ + GIT_AUTHOR_NAME="Another Author" git commit -a -m "Left #5" && git tag tag-l5 && git checkout right && @@ -99,6 +102,8 @@ test_expect_success '[merge] summary/log configuration' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: Left #5 Left #4 @@ -144,6 +149,8 @@ test_expect_success 'merge.log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: (5 commits) Left #5 Left #4 @@ -159,6 +166,8 @@ test_expect_success 'merge.log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: Left #5 Left #4 @@ -181,6 +190,8 @@ test_expect_success '--log=3 limits shortlog length' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: (5 commits) Left #5 Left #4 @@ -196,6 +207,8 @@ test_expect_success '--log=5 shows all 5 commits' ' cat >expected <<-EOF && Merge branch ${apos}left${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: Left #5 Left #4 @@ -225,6 +238,8 @@ test_expect_success 'fmt-merge-msg -m' ' cat >expected.log <<-EOF && Sync with left + By Another Author (3) and A U Thor (2) + via Another Committer * ${apos}left${apos} of $(pwd): Left #5 Left #4 @@ -256,6 +271,8 @@ test_expect_success 'setup: expected shortlog for two branches' ' cat >expected <<-EOF Merge branches ${apos}left${apos} and ${apos}right${apos} + By Another Author (3) and A U Thor (2) + via Another Committer * left: Left #5 Left #4 @@ -379,6 +396,8 @@ test_expect_success 'merge-msg two tags' ' Common #2 Common #1 + By Another Author (3) and A U Thor (2) + via Another Committer * tag ${apos}tag-l5${apos}: Left #5 Left #4 @@ -407,6 +426,8 @@ test_expect_success 'merge-msg tag and branch' ' Common #2 Common #1 + By Another Author (3) and A U Thor (2) + via Another Committer * left: Left #5 Left #4 diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 800b5368a5..ccfb54de7a 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -399,8 +399,8 @@ test_expect_success SANITY 'removal failure' ' ' test_expect_success 'nested git work tree' ' - rm -fr foo bar && - mkdir foo bar && + rm -fr foo bar baz && + mkdir -p foo bar baz/boo && ( cd foo && git init && @@ -412,15 +412,24 @@ test_expect_success 'nested git work tree' ' cd bar && >goodbye.people ) && + ( + cd baz/boo && + git init && + >deeper.world + git add . && + git commit -a -m deeply.nested + ) && git clean -f -d && test -f foo/.git/index && test -f foo/hello.world && + test -f baz/boo/.git/index && + test -f baz/boo/deeper.world && ! test -d bar ' test_expect_success 'force removal of nested git work tree' ' - rm -fr foo bar && - mkdir foo bar && + rm -fr foo bar baz && + mkdir -p foo bar baz/boo && ( cd foo && git init && @@ -432,9 +441,17 @@ test_expect_success 'force removal of nested git work tree' ' cd bar && >goodbye.people ) && + ( + cd baz/boo && + git init && + >deeper.world + git add . && + git commit -a -m deeply.nested + ) && git clean -f -f -d && ! test -d foo && - ! test -d bar + ! test -d bar && + ! test -d baz ' test_expect_success 'git clean -e' ' diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 8bb38337a9..b20ca0eace 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -30,10 +30,12 @@ test_expect_success 'setup: initial commit' ' ' test_expect_success '-m and -F do not mix' ' + git checkout HEAD file && echo >>file && git add file && test_must_fail git commit -m foo -m bar -F file ' test_expect_success '-m and -C do not mix' ' + git checkout HEAD file && echo >>file && git add file && test_must_fail git commit -C HEAD -m illegal ' @@ -79,7 +81,19 @@ test_expect_success 'empty commit message' ' test_must_fail git commit -F msg -a ' +test_expect_success 'template "emptyness" check does not kick in with -F' ' + git checkout HEAD file && echo >>file && git add file && + git commit -t file -F file +' + +test_expect_success 'template "emptyness" check' ' + git checkout HEAD file && echo >>file && git add file && + test_must_fail git commit -t file 2>err && + test_i18ngrep "did not edit" err +' + test_expect_success 'setup: commit message from file' ' + git checkout HEAD file && echo >>file && git add file && echo this is the commit message, coming from a file >msg && git commit -F msg -a ' diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh index ee7f0cd459..984889b39d 100755 --- a/t/t7503-pre-commit-hook.sh +++ b/t/t7503-pre-commit-hook.sh @@ -118,4 +118,22 @@ test_expect_success 'with failing hook requiring GIT_PREFIX' ' git checkout -- file ' +test_expect_success 'check the author in hook' ' + write_script "$HOOK" <<-\EOF && + test "$GIT_AUTHOR_NAME" = "New Author" && + test "$GIT_AUTHOR_EMAIL" = "newauthor@example.com" + EOF + test_must_fail git commit --allow-empty -m "by a.u.thor" && + ( + GIT_AUTHOR_NAME="New Author" && + GIT_AUTHOR_EMAIL="newauthor@example.com" && + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL && + git commit --allow-empty -m "by new.author via env" && + git show -s + ) && + git commit --author="New Author <newauthor@example.com>" \ + --allow-empty -m "by new.author via command line" && + git show -s +' + test_done diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh index 5783ebf3ab..bce0bd37cb 100755 --- a/t/t7602-merge-octopus-many.sh +++ b/t/t7602-merge-octopus-many.sh @@ -66,7 +66,7 @@ EOF test_expect_success 'merge output uses pretty names' ' git reset --hard c1 && git merge c2 c3 c4 >actual && - test_cmp actual expected + test_i18ncmp expected actual ' cat >expected <<\EOF @@ -80,7 +80,7 @@ EOF test_expect_success 'merge up-to-date output uses pretty names' ' git merge c4 c5 >actual && - test_cmp actual expected + test_i18ncmp expected actual ' cat >expected <<\EOF @@ -97,7 +97,7 @@ EOF test_expect_success 'merge fast-forward output uses pretty names' ' git reset --hard c0 && git merge c1 c2 >actual && - test_cmp actual expected + test_i18ncmp expected actual ' test_done diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh index aa74184c31..6547eb8f54 100755 --- a/t/t7607-merge-overwrite.sh +++ b/t/t7607-merge-overwrite.sh @@ -92,6 +92,15 @@ test_expect_success 'will not overwrite removed file with staged changes' ' test_cmp important c1.c ' +test_expect_failure 'will not overwrite unstaged changes in renamed file' ' + git reset --hard c1 && + git mv c1.c other.c && + git commit -m rename && + cp important other.c && + git merge c1a && + test_cmp important other.c +' + test_expect_success 'will not overwrite untracked subtree' ' git reset --hard c0 && rm -rf sub && diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 4fb4c9384a..2763d795f0 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -83,6 +83,17 @@ test_expect_success PERL 'difftool ignores bad --tool values' ' test "$diff" = "" ' +test_expect_success PERL 'difftool forwards arguments to diff' ' + >for-diff && + git add for-diff && + echo changes>for-diff && + git add for-diff && + diff=$(git difftool --cached --no-prompt -- for-diff) && + test "$diff" = "" && + git reset -- for-diff && + rm for-diff +' + test_expect_success PERL 'difftool honors --gui' ' git config merge.tool bogus-tool && git config diff.tool bogus-tool && diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 438aaf6b14..0f5b5e5964 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1307,6 +1307,45 @@ test_expect_success \ INPUT_END' test_expect_success \ + 'N: reject foo/ syntax in copy source' \ + 'test_must_fail git fast-import <<-INPUT_END + commit refs/heads/N5C + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + copy with invalid syntax + COMMIT + + from refs/heads/branch^0 + C file2/ file3 + INPUT_END' + +test_expect_success \ + 'N: reject foo/ syntax in rename source' \ + 'test_must_fail git fast-import <<-INPUT_END + commit refs/heads/N5D + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + rename with invalid syntax + COMMIT + + from refs/heads/branch^0 + R file2/ file3 + INPUT_END' + +test_expect_success \ + 'N: reject foo/ syntax in ls argument' \ + 'test_must_fail git fast-import <<-INPUT_END + commit refs/heads/N5E + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <<COMMIT + copy with invalid syntax + COMMIT + + from refs/heads/branch^0 + ls "file2/" + INPUT_END' + +test_expect_success \ 'N: copy to root by id and modify' \ 'echo "hello, world" >expect.foo && echo hello >expect.bar && diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh index 31076edc5b..fa2f65f6be 100755 --- a/t/t9501-gitweb-standalone-http-status.sh +++ b/t/t9501-gitweb-standalone-http-status.sh @@ -92,7 +92,7 @@ test_debug 'cat gitweb.output' test_expect_success 'snapshots: bad tree-ish id (tagged object)' ' echo object > tag-object && git add tag-object && - git commit -m "Object to be tagged" && + test_tick && git commit -m "Object to be tagged" && git tag tagged-object `git hash-object tag-object` && gitweb_run "p=.git;a=snapshot;h=tagged-object;sf=tgz" && grep "400 - Object is not a tree-ish" gitweb.output @@ -112,6 +112,64 @@ test_expect_success 'snapshots: bad object id' ' ' test_debug 'cat gitweb.output' +# ---------------------------------------------------------------------- +# modification times (Last-Modified and If-Modified-Since) + +test_expect_success 'modification: feed last-modified' ' + gitweb_run "p=.git;a=atom;h=master" && + grep "Status: 200 OK" gitweb.headers && + grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: feed if-modified-since (modified)' ' + export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && + test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && + gitweb_run "p=.git;a=atom;h=master" && + grep "Status: 200 OK" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: feed if-modified-since (unmodified)' ' + export HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && + test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && + gitweb_run "p=.git;a=atom;h=master" && + grep "Status: 304 Not Modified" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: snapshot last-modified' ' + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + grep "Status: 200 OK" gitweb.headers && + grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: snapshot if-modified-since (modified)' ' + export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && + test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + grep "Status: 200 OK" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: snapshot if-modified-since (unmodified)' ' + export HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && + test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + grep "Status: 304 Not Modified" gitweb.headers +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: tree snapshot' ' + ID=`git rev-parse --verify HEAD^{tree}` && + export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && + test_when_finished "unset HTTP_IF_MODIFIED_SINCE" && + gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" && + grep "Status: 200 OK" gitweb.headers && + ! grep -i "last-modified" gitweb.headers +' +test_debug 'cat gitweb.headers' # ---------------------------------------------------------------------- # load checking diff --git a/t/test-lib.sh b/t/test-lib.sh index 30ed4d74bb..b7d7100c4e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -46,7 +46,7 @@ EDITOR=: # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets # deriving from the command substitution clustered with the other # ones. -unset VISUAL EMAIL LANGUAGE $(perl -e ' +unset VISUAL EMAIL LANGUAGE COLUMNS $(perl -e ' my @env = keys %ENV; my $ok = join("|", qw( TRACE |