git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anders Melchiorsen <mail@cup.kalibalik.dk>
To: git@vger.kernel.org
Cc: Anders Melchiorsen <mail@cup.kalibalik.dk>
Subject: [PATCH v2] Advertise the ability to abort a commit
Date: Tue, 29 Jul 2008 22:12:22 +0200	[thread overview]
Message-ID: <1217362342-30370-1-git-send-email-mail@cup.kalibalik.dk> (raw)
In-Reply-To: <1217359925-30130-1-git-send-email-mail@cup.kalibalik.dk>

This treats aborting a commit more like a feature.

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---

Now includes updates to test file.

Incidentally, this change was proposed by pasky in #git.


 builtin-commit.c  |    3 ++-
 t/t7502-commit.sh |    7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 9a11ca0..75eeb4b 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -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");
@@ -1003,7 +1004,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		stripspace(&sb, cleanup_mode == CLEANUP_ALL);
 	if (sb.len < header_len || message_is_empty(&sb, header_len)) {
 		rollback_index_files();
-		die("no commit message?  aborting commit.");
+		die("no commit message.  aborting commit.");
 	}
 	strbuf_addch(&sb, '\0');
 	if (is_encoding_utf8(git_commit_encoding) && !is_utf8(sb.buf))
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 4f2682e..f111263 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -142,6 +142,7 @@ 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)' '
@@ -149,7 +150,7 @@ 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
 
 '
@@ -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
 '
 
@@ -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
 '
-- 
1.5.6.4

  reply	other threads:[~2008-07-29 20:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29 19:32 [PATCH] Advertise the ability to abort a commit Anders Melchiorsen
2008-07-29 20:12 ` Anders Melchiorsen [this message]
2008-07-29 20:51   ` [PATCH v2] " Junio C Hamano
2008-07-29 21:19     ` Anders Melchiorsen
2008-07-30  5:07   ` Jeff King
2008-07-30  5:11     ` Jeff King
2008-07-30 17:53       ` [PATCH v3] " Anders Melchiorsen
2008-07-30 19:01         ` Brian Gernhardt
2008-07-30 21:09           ` Avery Pennarun
2008-07-30 21:16             ` Brian Gernhardt
2008-07-30 21:53             ` Anders Melchiorsen
2008-07-31  5:50         ` Jeff King
2008-07-31  5:58           ` Junio C Hamano
2008-07-31  6:36             ` [PATCH] " Jeff King
2008-07-31  7:36             ` [PATCH v3] " Jeff King
2008-07-31 10:55               ` Petr Baudis
2008-07-31 11:09                 ` Jeff King
2008-07-31  7:28           ` Anders Melchiorsen
2008-07-31  7:32             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1217362342-30370-1-git-send-email-mail@cup.kalibalik.dk \
    --to=mail@cup.kalibalik.dk \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).