git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Cherry-picking commits with empty messages
@ 2012-08-01 11:16 Chris Webb
  2012-08-01 17:52 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Chris Webb @ 2012-08-01 11:16 UTC (permalink / raw)
  To: git

Whilst doing some extra sanity checking of my git-rebase--interactive.sh
patch yesterday, I came across a behaviour which has been present for some
time, but seems surprising. You can reproduce with

  $ git init -q foo && cd foo
  $ touch one && git add one && git commit -q -m one
  $ touch two && git add two && git commit -q -m two
  $ touch three && git add three && git commit -q -m '' --allow-empty-message
  $ touch four && git add four && git commit -q -m '' --allow-empty-message
  $ git rebase -i HEAD~3 # and swap the two commits with empty messages
  Aborting commit due to empty commit message.
  Could not apply 59a8fde... 

This happens on my ancient laptop which is apparently running 1.7.8.3, as well
as current master, so is unconnected to recent changes.

The reason is that git cherry-pick won't pick a commit with an empty commit
message, even when that message is unmodified from the original:

  $ git rebase --abort
  $ git checkout -q HEAD~2
  $ git cherry-pick 59a8fde
  Aborting commit due to empty commit message.

I can see that this check could make sense when the message has been
modified, but it seems strange when it hasn't, and isn't ideal behaviour
when called from rebase -i. (We otherwise make sure we call git commit with
--allow-empty-message to avoid problems with reordering or editing empty
commits.)

I could just remove the check in the 'message unmodified' case with
something like

diff --git a/sequencer.c b/sequencer.c
index bf078f2..cf8bc05 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -306,6 +306,7 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 	if (!opts->edit) {
 		argv_array_push(&array, "-F");
 		argv_array_push(&array, defmsg);
+		argv_array_push(&array, "--allow-empty-message");
 	}
 
 	if (allow_empty)

but perhaps there are other users of the sequencer for whom this check is
desirable? If so, would an --allow-empty-message to git cherry-pick be a
better plan, which git rebase -i can use where appropriate?

Best wishes,

Chris.

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-08-06 11:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 11:16 Cherry-picking commits with empty messages Chris Webb
2012-08-01 17:52 ` Junio C Hamano
2012-08-01 18:15   ` Angus Hammond
2012-08-01 22:26     ` Junio C Hamano
2012-08-02 10:10       ` Angus Hammond
2012-08-02  8:55   ` Chris Webb
2012-08-02 10:38     ` [PATCH] cherry-pick: add --allow-empty-message option Chris Webb
2012-08-06 10:57       ` Neil Horman
2012-08-06 11:00         ` Chris Webb
2012-08-06 11:11           ` Neil Horman
2012-08-03  0:22   ` Cherry-picking commits with empty messages Neil Horman

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).