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

Re: How to rebase when some commit hashes are in some commit messages

From
Jacob Keller <jacob.keller@gmail.com>
Date
Oct 13, 2015, 17:07 UTC
Message-ID
<CA+P7+xoDia6PC+qJeVn3sD5g4jk7KRuDAPOcEHvrntd+ndUraA@mail.gmail.com>
In-Reply-To
<AD64941D9533442AB025BE27FF8F08AF@PhilipOakley>
On Tue, Oct 13, 2015 at 6:29 AM, Philip Oakley <philipoakley@iee.org> wrote:
Show 5 quoted lines
> My tuppence is that the only sha1's that could/would be rewritten would be
> those for the commits within the rebase. During rebasing it is expected that
> the user is re-adjusting things for later upstream consumption, with social
> controls and understandings with colleagues.
>

Agreed here. There would be no need to change any sha1s that didn't change during the rebase. This limits the scope. Alright.

> Thus the only sha1 numbers that could be used are those that are within the
> (possibly implied) instruction sheet (which will list the current sha1s that
> will be converted by rebase to new sha1's).
>
Correct, you would be able to limit the number of sha1s to search for.

However, (see below), any reasonable reference to a sha1 should be relatively stable.

Show 13 quoted lines
> It should be clear that the sha1's are always backward references (because
> of the impossibility of including a forward reference to an as yet
> un-created future commit's sha1).
>
> The key question (for me) is whether short sha1s are accepted, or if they
> must be full 40 char sha1's (perhaps an option). There are already options
> for making sure that short refs are not ambiguous.
>
> It sound to me like a sensible small project for those that have such a
> workflow. I'm not sure if it should work with a patch based flow when
> submitting upstream - I'm a little fuzzy on how would the upstream
> maintainer know which sha1 referred to which patch.
>

My issue: the only sha1s in commit messages are *generally* things which will NOT be changed in general. Supporting a work flow that wants to change these is definitely crazy.

Essentially: I don't see a reason that you would be rebasing a commit
and needing to change any references in it. You can reference a commit
which isn't changing, but here's the possible situations I see:

a) you are rebasing a commit which references in the message a commit that is not being changed (it is ancient)

In this case, nothing needs to be done.
b) you are rebasing a commit which references another commit in the same rebase

I see no valid reason to reference a sha1 in this case. If you're referencing as a "fixes", then you are being silly since you can just squash the fix into the original commit and thus prevent introduction of bug at all.

What other reason? If you are referencing such as "thix extends implementation from sha1" then your commit message is probably poorly formatted. I don't see a reason to support this flow.

c) you are rebasing a commit which is referencing a commit that has already been changed. (?)

I think (maybe) this is your interesting case, but here are some caveats.

Let's say you are fixing some old commit such as "Fixes: <sha1, summary, date>" or something.

If you do a "git pull --rebase", your commit might be updated to play ontop of more new work, but the sha1 should still be valid, *unless* the remote history did some rewind, at which point I don't think any algorithm will work, see the issues above.

It may be something worth doing in git-filter-branch, but then you're looking at losing the two assumptions above making it really hard to get right.

Regards, Jake

Previous: Philip OakleyNext: Mike Rappazzo
Message 6 of 17 in “How to rebase when some commit hashes are in some commit messages”
  1. Francois-Xavier Le BailOct 12, 2015
  2. Matthieu MoyOct 12, 2015
  3. Francois-Xavier Le BailOct 13, 2015
  4. Konstantin KhomoutovOct 13, 2015
  5. Philip OakleyOct 13, 2015
  6. Jacob KellerOct 13, 2015
  7. Mike RappazzoOct 13, 2015
  8. Philip OakleyOct 13, 2015
  9. Jacob KellerOct 13, 2015
  10. Philip OakleyOct 13, 2015
  11. Francois-Xavier Le BailOct 15, 2015
  12. Francois-Xavier Le BailOct 15, 2015
  13. Francois-Xavier Le BailOct 15, 2015
  14. Johannes SchindelinOct 15, 2015
  15. Philip OakleyOct 16, 2015
  16. Thomas KochOct 18, 2015
  17. Ævar Arnfjörð BjarmasonOct 18, 2015

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.