Skip to content

Commit

Permalink
Advertise the ability to abort a commit
Browse files Browse the repository at this point in the history
This treats aborting a commit more like a feature.

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Anders Melchiorsen authored and Junio C Hamano committed Jul 30, 2008
1 parent ae7c5dc commit bd2574c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
fprintf(fp,
"\n"
"# Please enter the commit message for your changes.\n"
"# To abort the commit, use an empty commit message.\n"
"# (Comment lines starting with '#' will ");
if (cleanup_mode == CLEANUP_ALL)
fprintf(fp, "not be included)\n");
Expand Down
7 changes: 4 additions & 3 deletions t/t7502-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ test_expect_success 'cleanup commit messages (strip,-F)' '
echo "sample
# Please enter the commit message for your changes.
# To abort the commit, use an empty commit message.
# (Comment lines starting with '#' will not be included)" >expect

test_expect_success 'cleanup commit messages (strip,-F,-e)' '
echo >>negative &&
{ echo;echo sample;echo; } >text &&
git commit -e -F text -a &&
head -n 4 .git/COMMIT_EDITMSG >actual &&
head -n 5 .git/COMMIT_EDITMSG >actual &&
test_cmp expect actual
'
Expand All @@ -162,7 +163,7 @@ test_expect_success 'author different from committer' '
echo >>negative &&
git commit -e -m "sample"
head -n 7 .git/COMMIT_EDITMSG >actual &&
head -n 8 .git/COMMIT_EDITMSG >actual &&
test_cmp expect actual
'

Expand All @@ -181,7 +182,7 @@ test_expect_success 'committer is automatic' '
# must fail because there is no change
test_must_fail git commit -e -m "sample"
) &&
head -n 8 .git/COMMIT_EDITMSG | \
head -n 9 .git/COMMIT_EDITMSG | \
sed "s/^# Committer: .*/# Committer:/" >actual &&
test_cmp expect actual
'
Expand Down

0 comments on commit bd2574c

Please sign in to comment.