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

Re: git rebase --root bug

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
May 12, 2023, 15:18 UTC
Message-ID
<a6c6d3a4-433d-f275-e31c-4eece062722c@gmail.com>
In-Reply-To
<ZF0U6tneDjLfGxf1@nand.local>
Hi Taylor
On 11/05/2023 17:16, Taylor Blau wrote:
Show 11 quoted lines
> On Thu, May 11, 2023 at 03:21:11PM +0100, Phillip Wood wrote:
>> The cause of the problem is that --root creates an empty commit (known as
>> "squash_onto" in the code) which it uses as the "onto" commit. When it picks
>> the first commit in the todo list the "onto" commit is amended and so is
>> unreachable when the reflog is expired above. I think the best fix would be
>> to stop pretending that we have a real "onto" commit when --root is used
>> without --onto and either store "new root" .git/rebase-merge/onto or not
>> create that file at all.
> 
> Wouldn't it suffice to consider the squash_onto commit as reachable the
> same way we do for `--indexed-objects`?

We could do that rather than clean up the implementation of --root. We should definitely consider the commit stored in .git/rebase-merge/orig-head to be reachable as the following test fails

diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ff0afad63e..8ac5e2eec6 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -66,6 +66,19 @@ test_expect_success 'setup' '
  SHELL=
  export SHELL

+test_expect_success 'orig-head is not garbage collected' '
+        git checkout --detach &&
+        test_commit --no-tag x &&
+        (
+                set_fake_editor &&
+                FAKE_LINES="1 edit 2" git rebase -i @~2
+        ) &&
+        git reset @^ &&
+        git reflog expire --expire-unreachable=now &&
+        git gc --prune=now &&
+        git rebase --abort
+'
+
  test_expect_success 'rebase --keep-empty' '
          git checkout -b emptybranch primary &&
          git commit --allow-empty -m "empty" &&

I'm not familiar with the gc code, does it use the --indexed-objects 
option of "git rev-list"?

Best Wishes

Phillip
Previous: Christopher Fretz
Message 7 of 7 in “git rebase --root bug”
  1. Christopher FretzMay 10, 2023
  2. Kristoffer HaugsbakkMay 10, 2023
  3. Christopher FretzMay 11, 2023
  4. Phillip WoodMay 11, 2023
  5. Taylor BlauMay 11, 2023
  6. Christopher FretzMay 11, 2023
  7. Phillip WoodMay 12, 2023

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.