diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-06-21 06:02:46 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-21 06:02:46 -0700 |
commit | 1a5296cb92691c5656bbc6aacaf49ca31b1ee8c0 (patch) | |
tree | 4dc18b247c7d38af4537de97f5711e83657914a1 /t | |
parent | Merge branch 'tr/receive-pack-aliased-update-fix' (diff) | |
parent | commit::print_summary(): don't use format_commit_message() (diff) | |
download | tgif-1a5296cb92691c5656bbc6aacaf49ca31b1ee8c0.tar.xz |
Merge branch 'tc/commit-abbrev-fix'
* tc/commit-abbrev-fix:
commit::print_summary(): don't use format_commit_message()
t7502-commit: add summary output tests for empty and merge commits
t7502-commit: add tests for summary output
Diffstat (limited to 't')
-rwxr-xr-x | t/t7502-commit.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 95044668ee..ac2e187a57 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -4,8 +4,76 @@ test_description='git commit porcelain-ish' . ./test-lib.sh +# Arguments: [<prefix] [<commit message>] [<commit options>] +check_summary_oneline() { + test_tick && + git commit ${3+"$3"} -m "$2" | head -1 > act && + + # branch name + SUMMARY_PREFIX="$(git name-rev --name-only HEAD)" && + + # append the "special" prefix, like "root-commit", "detached HEAD" + if test -n "$1" + then + SUMMARY_PREFIX="$SUMMARY_PREFIX ($1)" + fi + + # abbrev SHA-1 + SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')" + echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp && + + test_cmp exp act +} + +test_expect_success 'output summary format' ' + + echo new >file1 && + git add file1 && + check_summary_oneline "root-commit" "initial" && + + echo change >>file1 && + git add file1 && + check_summary_oneline "" "a change" +' + +test_expect_success 'output summary format for commit with an empty diff' ' + + check_summary_oneline "" "empty" "--allow-empty" +' + +test_expect_success 'output summary format for merges' ' + + git checkout -b recursive-base && + test_commit base file1 && + + git checkout -b recursive-a recursive-base && + test_commit commit-a file1 && + + git checkout -b recursive-b recursive-base && + test_commit commit-b file1 && + + # conflict + git checkout recursive-a && + test_must_fail git merge recursive-b && + # resolve the conflict + echo commit-a > file1 && + git add file1 && + check_summary_oneline "" "Merge" +' + +output_tests_cleanup() { + # this is needed for "do not fire editor in the presence of conflicts" + git checkout master && + + # this is needed for the "partial removal" test to pass + git rm file1 && + git commit -m "cleanup" +} + test_expect_success 'the basics' ' + output_tests_cleanup && + echo doing partial >"commit is" && mkdir not && echo very much encouraged but we should >not/forbid && |