git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/3] sequencer: make commit options more extensible

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 24, 2017, 01:01 UTC
Message-ID
<xmqq7f3fa3oz.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<75e2c4fe839602af19811ed3e251eb583ff6c8ad.1490285210.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 23 quoted lines
> @@ -926,14 +930,14 @@ static void record_in_rewritten(struct object_id *oid,
>  static int do_pick_commit(enum todo_command command, struct commit *commit,
>  		struct replay_opts *opts, int final_fixup)
>  {
> -	int edit = opts->edit, cleanup_commit_message = 0;
> -	const char *msg_file = edit ? NULL : git_path_merge_msg();
> +	unsigned int flags = opts->edit ? EDIT_MSG : 0, allow = 0;
> +	const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
>  	unsigned char head[20];
>  	struct commit *base, *next, *parent;
>  	const char *base_label, *next_label;
>  	struct commit_message msg = { NULL, NULL, NULL, NULL };
>  	struct strbuf msgbuf = STRBUF_INIT;
> -	int res, unborn = 0, amend = 0, allow = 0;
> +	int res, unborn = 0;
> ... 
> @@ -1123,11 +1127,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
>  	if (allow < 0) {
>  		res = allow;
>  		goto leave;
> -	}
> +	} else if (allow)
> +		flags |= ALLOW_EMPTY;

Making "flags" unsigned was a correct change, but this is now wrong, as "allow" is made unsigned by accident. It still needs to receive the return value from allow_empty() that can signal an error by returning a negative value. It seems you did this deliberately (it wasn't like "flags" and "allow" were on the same line both "int" and the change to make "flags" unsigned accidentally made "allow" also unsigned; "allow" was "int" and didn't have to move when "flags" was introduced in the first place), but I failed to spot it because I was only looking at s/int/unsigned/ on the line in the interdiff, and missed that "allow" was on the same line. Compilers are better at finding these bugs.

Perhaps something like this needs to be squashed in?
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index bc2fe48e65..6c423566e6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -932,14 +932,14 @@ static void record_in_rewritten(struct object_id *oid,
 static int do_pick_commit(enum todo_command command, struct commit *commit,
 		struct replay_opts *opts, int final_fixup)
 {
-	unsigned int flags = opts->edit ? EDIT_MSG : 0, allow = 0;
+	unsigned int flags = opts->edit ? EDIT_MSG : 0;
 	const char *msg_file = opts->edit ? NULL : git_path_merge_msg();
 	unsigned char head[20];
 	struct commit *base, *next, *parent;
 	const char *base_label, *next_label;
 	struct commit_message msg = { NULL, NULL, NULL, NULL };
 	struct strbuf msgbuf = STRBUF_INIT;
-	int res, unborn = 0;
+	int allow, res, unborn = 0;
 
 	if (opts->no_commit) {
 		/*
-- 
2.12.1-432-gf364f02724
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 21 of 27 in “rebase -i (reword): call the commit-msg hook again”
  1. 0/3 rebase -i (reword): call the commit-msg hook againJohannes Schindelin, Mar 22, 2017
  2. 2/3 sequencer: make commit options more extensibleJohannes Schindelin, Mar 22, 2017
  3. Junio C HamanoMar 22, 2017
  4. Johannes SchindelinMar 23, 2017
  5. Junio C HamanoMar 23, 2017
  6. 1/3 t7504: document regression: reword no longer calls commit-msgJohannes Schindelin, Mar 22, 2017
  7. Sebastian SchuberthMar 22, 2017
  8. Johannes SchindelinMar 22, 2017
  9. Junio C HamanoMar 22, 2017
  10. Johannes SchindelinMar 23, 2017
  11. Sebastian SchuberthMar 23, 2017
  12. Johannes SchindelinMar 23, 2017
  13. Junio C HamanoMar 22, 2017
  14. Johannes SchindelinMar 23, 2017
  15. 3/3 sequencer: allow the commit-msg hooks to run during a `reword`Johannes Schindelin, Mar 22, 2017
  16. Junio C HamanoMar 22, 2017
  17. Johannes SchindelinMar 23, 2017
  18. 0/3 rebase -i (reword): call the commit-msg hook againJohannes Schindelin, Mar 23, 2017
  19. 1/3 t7504: document regression: reword no longer calls commit-msgJohannes Schindelin, Mar 23, 2017
  20. 2/3 sequencer: make commit options more extensibleJohannes Schindelin, Mar 23, 2017
  21. Junio C HamanoMar 24, 2017
  22. Johannes SchindelinMar 25, 2017
  23. Junio C HamanoMar 27, 2017
  24. Junio C HamanoMar 27, 2017
  25. Johannes SchindelinMar 29, 2017
  26. 3/3 sequencer: allow the commit-msg hooks to run during a `reword`Johannes Schindelin, Mar 23, 2017
  27. Junio C HamanoMar 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.