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

Re: Bug with rebase and commit hashes

From
Michael McClimon <michael@mcclimon.org>
Date
Mar 12, 2022, 03:10 UTC
Message-ID
<YiwPJD39+/hnu36j@newk>
In-Reply-To
<036EAEE4-D957-41F2-8B17-3AD7B2E49611@gmail.com>

Thanks both! I had a look at this on the couch this evening, and with the caveat that I am not at all a C programmer, I think have a patch that fixes it:

diff --git a/builtin/rebase.c b/builtin/rebase.c
index b29ad2b6..82fb5e2c 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -829,6 +829,8 @@ static int checkout_up_to_date(struct rebase_options *options)
        ropts.oid = &options->orig_head;
        ropts.branch = options->head_name;
        ropts.flags = RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
+       if (!ropts.branch)
+               ropts.flags |= RESET_HEAD_DETACH;
        ropts.head_msg = buf.buf;
        if (reset_head(the_repository, &ropts) < 0)
                ret = error(_("could not switch to %s"), options->switch_to);


I haven't yet run the entire test suite, but I did run all the t*-rebase*
tests, which passed, including Junio's up-thread here. If this seems not
totally off-base, then I'll actually read the "my first contribution" docs and
send in a proper patch and whatnot.
-- 
Michael McClimon
michael@mcclimon.org
Previous: John CaiNext: John Cai
Message 4 of 7 in “Bug with rebase and commit hashes”
  1. Michael McClimonMar 10, 2022
  2. John CaiMar 10, 2022
  3. John CaiMar 10, 2022
  4. Michael McClimonMar 12, 2022
  5. John CaiMar 12, 2022
  6. Michael McClimonMar 12, 2022
  7. Junio C HamanoMar 10, 2022

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.