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

Re: Using Origin hashes to improve rebase behavior

From
JWJohn Wiegley <johnw@boostpro.com>
Date
Feb 11, 2011, 03:14 UTC
Message-ID
<m2oc6jtg8o.fsf@hermes.luannocracy.com>
In-Reply-To
<20110210225428.GA21335@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Now, in step 2 we could record "X" as an origin ID of X'' and during the
> rebase in step 3, calculate the intersection of the origins of X'' and X',
> and see that they are both just X. And I think maybe you already realize
> that, since you talk about Origin-IDs as sets.
Right.
Show 6 quoted lines
> And there are lots of other cases. What about "git cherry-pick -n"? What
> about rebasing? If there are no conflicts, is it OK to copy the origin
> field? How about if there are conflicts? How about in a "git rebase -i",
> where we may stop and the user can arbitrarily split, amend, or add new
> commits. How do the old commits map to the new ones with respect to
> origin fields?

During rebasing, any commits which can be rebased without conflict have their origin transferred (and each time it would cause the origin id list to grow by one), but any commits which are squashed or edited would not transfer.

For cherry-pick -n, if the index is empty at the time the cherry-pick is done (is this required?), then a file is created under .git/ with the SHA of the changes placed in the index, so that when git-commit is later run and the index has not been changed, then the Origin-Id for that originating commit gets placed at the bottom of the commit message.

Show 6 quoted lines
> So there are lots of corner cases where it won't work, because git is
> more than happy to give you lots of ways to tweak tree state and
> history, and it fundamentally doesn't care as much about process as it
> does about the end states that you reach. That's part of what makes git
> so flexible, but it also makes niceties like "did I already apply this
> commit on this branch" much harder to make sense of.

I think we'd want to restrict this system to those commits which were automatically rewritten without conflicts. Any user intervention in the process would invalidate the meaning of the Origin-Id.

> It probably shouldn't be a new header field, but rather a text-style
> pseudo-header at the end of the commit.
I understand.
Show 6 quoted lines
> But consider for a moment whether you actually want this field in the
> resulting commit at all, or whether it should be an external annotation.
> For example, let's say I cherry-pick from a private branch that is going
> to end up rebased anyway. Now the history for all time will have a
> commit that refers to some totally useless sha1 that nobody even knows
> about.

The problem with an external annotation is that if developers are sharing feature branches, as a branch maintainer I want to know whether commits coming from those feature branches are already in the branch I'm maintaining.

> There may be reasons why that isn't a good idea, and I haven't thought it
> through. But I think you should consider it as an alternate implementation
> and tell me why I'm dumb in that case. ;)
I'll give it a bit more thought as I consider the implementation of this.
Show 5 quoted lines
> Whew, that turned out long. I hope it's helpful. I think the problem
> you're trying to solve is a real one, and I think your approach is the
> right direction. I just think we can leverage existing git features to
> do most of it, and because it is sort of a heuristic, we should be
> conservative in how it's introduced.

That's all extremely helpful, thank you! You've brought up several use cases I hadn't thought of, and perhaps this feature will indeed never cover everything, but if it can reliably ease maintenance 80% of the time, I think it's a relatively simple addition.

John
Previous: Jeff KingNext: Jeff King
Message 4 of 14 in “Using Origin hashes to improve rebase behavior”
  1. John WiegleyFeb 10, 2011
  2. Johan HerlandFeb 10, 2011
  3. Jeff KingFeb 10, 2011
  4. John WiegleyFeb 11, 2011
  5. Jeff KingFeb 11, 2011
  6. John WiegleyFeb 11, 2011
  7. Thomas RastFeb 12, 2011
  8. skillzero@gmail.comFeb 11, 2011
  9. Johan HerlandFeb 11, 2011
  10. Jeff KingFeb 11, 2011
  11. Junio C HamanoFeb 11, 2011
  12. Jeff KingFeb 11, 2011
  13. Enrico WeigeltFeb 20, 2011
  14. Dave AbrahamsFeb 21, 2011

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.