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

Re: What's cooking in git.git (Apr 2018, #04; Mon, 30)

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 1, 2018, 13:46 UTC
Message-ID
<nycvar.QRO.7.76.6.1805011439580.79@tvgsbejvaqbjf.bet>
In-Reply-To
<CAM0VKjmkn7eyooKheOEQnS=6HMZSTbhejoxQdKB7W+n=7D5KuQ@mail.gmail.com>
Hi,
On Mon, 30 Apr 2018, SZEDER Gábor wrote:
Show 19 quoted lines
> On Mon, Apr 30, 2018 at 5:25 AM, Junio C Hamano <gitster@pobox.com> wrote:
> > * js/rebase-i-clean-msg-after-fixup-continue (2018-04-30) 4 commits
> >   - rebase --skip: clean up commit message after a failed fixup/squash
> >   - sequencer: always commit without editing when asked for
> >   - rebase -i: Handle "combination of <n> commits" with GETTEXT_POISON
> >   - rebase -i: demonstrate bugs with fixup!/squash! commit messages
> 
> >   "git rebase -i" sometimes left intermediate "# This is a
> >   combination of N commits" message meant for the human consumption
> >   inside an editor in the final result in certain corner cases, which
> >   has been fixed.
> 
> >   Will merge to 'next'.
> 
> This topic branches off from v2.16.3.  However, its last patch uses
> the sequencer's parse_head() function, which was only added in
> v2.17.0-rc0~110^2~6 (sequencer: try to commit without forking 'git
> commit', 2017-11-24), in topic 'pw/sequencer-in-process-commit',
> leading to compilation errors.
Great find.

As luck has it, I recently played with tbdiff and compared what Junio applied vs what I have, and found only context line changes (and Junio's extra Signed-off-by: lines).

So the problem you found is not a problem with *my* branch, of course, as I did not fork off of v2.16.3 (which is a bit arbitrary, I must say: if you want to fix these bugs for reals, you'd have to go all the way back to where fixup!/squash! support was introduced).

However, as a maintainer I am sympathetic to the goal of wanting to have *one* branch that does not need to be backported.

The patch to make all of this work is most likely this:

-- snip -- sequencer: backport parse_head()

This function exists in v2.17.0, and will be used in the upcoming fixes for bugs when running `git rebase --skip` after a fixup/squash failed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
--
diff --git a/sequencer.c b/sequencer.c
index a766796d1a7..f9c478a4d79 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -695,6 +695,29 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 	return run_command(&cmd);
 }
 
+static int parse_head(struct commit **head)
+{
+	struct commit *current_head;
+	struct object_id oid;
+
+	if (get_oid("HEAD", &oid)) {
+		current_head = NULL;
+	} else {
+		current_head = lookup_commit_reference(&oid);
+		if (!current_head)
+			return error(_("could not parse HEAD"));
+		if (oidcmp(&oid, &current_head->object.oid)) {
+			warning(_("HEAD %s is not a commit!"),
+				oid_to_hex(&oid));
+		}
+		if (parse_commit(current_head))
+			return error(_("could not parse HEAD commit"));
+	}
+	*head = current_head;
+
+	return 0;
+}
+
 static int is_original_commit_empty(struct commit *commit)
 {
 	const struct object_id *ptree_oid;
-- snap --

I also had to apply this to make things compile with DEVELOPER=1:

-- snip --
diff --git a/sequencer.c b/sequencer.c
index f9c478a4d79..44b1874f459 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2345,7 +2345,7 @@ static int commit_staged_changes(struct replay_opts *opts,
 				 * We need to update the squash message to skip
 				 * the latest commit message.
 				 */
-				struct commit *commit;
+				struct commit *commit = NULL;
 				const char *path = rebase_path_squash_msg();
 
 				if (parse_head(&commit) ||
-- snap --

This should most likely be squashed into "rebase --skip: clean up commit
message after a failed fixup/squash".

Junio, for your convenience, I pushed what I have here to the
`clean-msg-after-fixup-continue-backport-v2.16.3` branch on
https://github.com/dscho/git

For shiggles, I also looked how far back I could push this, and backported
to v2.15.1, v2.14.3, v2.13.6, v2.12.5

Things got painful only really with v2.12.5. Like, really painful. And in
the end not even worth it... I managed to backport the changes, sure, but
that code path is not even used ;-)

For your convenience, I pushed all of the backports, just in case you want
to use them. I did leave a couple of fixup! commits in place, to show a
*little* better what I did and where.

Ciao,
Dscho
Previous: SZEDER GáborNext: Junio C Hamano
Message 3 of 16 in “What's cooking in git.git (Apr 2018, #04; Mon, 30)”
  1. Junio C HamanoApr 30, 2018
  2. SZEDER GáborApr 30, 2018
  3. Johannes SchindelinMay 1, 2018
  4. Junio C HamanoMay 2, 2018
  5. Johannes SchindelinMay 2, 2018
  6. Junio C HamanoMay 2, 2018
  7. Junio C HamanoMay 2, 2018
  8. js/no-pager-shorthand [was: What's cooking in git.git (Apr 2018, #04; Mon, 30)]Johannes Sixt, Apr 30, 2018
  9. Johannes SchindelinMay 1, 2018
  10. Johannes SixtMay 1, 2018
  11. Eric SunshineMay 1, 2018
  12. Junio C HamanoMay 2, 2018
  13. Ævar Arnfjörð BjarmasonMay 1, 2018
  14. Brandon WilliamsMay 2, 2018
  15. Elijah NewrenMay 4, 2018
  16. Junio C HamanoMay 7, 2018

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.