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

Should notes handle replace commits?

From
Mike Hommey <mh@glandium.org>
Date
Jan 8, 2016, 01:28 UTC
Message-ID
<20160108012830.GA2110@glandium.org>
Hi,
Take the following dummy repo:
  $ git init
  $ git commit --allow-empty -m 'first'
  $ git notes add -m 'first note'
  $ git commit --allow-empty -m 'second'
  $ git notes add -m 'second note'
  $ git commit --allow-empty -m 'third'
  $ git notes add -m 'third note'
  $ git log --format='%s - %N'
  third - third note
  second - second note
  first - first note
Now, let's say you have some other history that you want to graft:
  $ git checkout --orphan old
  $ git commit --allow-empty -m 'real first'
  $ git notes add -m 'real first note'
  $ git commit --allow-empty -m 'real second'
  $ git notes add -m 'real second note'
  $ git commit --allow-empty -m 'real third'
  $ git notes add -m 'real third note'
  $ git log --format='%s - %N'
  real third - real third note
  real second - real second note
  real first - real first note

Assuming that the "first" commit on master is the same as the "real third" on old, you can graft with:

  $ git rev-parse master~ old | xargs > .git/info/grafts
And then:
  $ git log master --format='%s - %N'
  third - third note
  second - second note
  real third - real third note
  real second - real second note
  real first - real first note
Now, if you try to do the same with replace:
  $ rm .git/info/grafts
  $ git replace master~2 old
  $ git log master --format='%s - %N'
  third - third note
  second - second note
  real third - first note
  real second - real second note
  real first - real first note

Note how "real third" now has "first note", instead of "real third note".

So the question is, is this the behavior this should have?
Cheers,
Mike
Next: Junio C Hamano
Message 1 of 12 in “Should notes handle replace commits?”
  1. Mike HommeyJan 8, 2016
  2. Junio C HamanoJan 8, 2016
  3. Mike HommeyJan 8, 2016
  4. Junio C HamanoJan 8, 2016
  5. Junio C HamanoJan 9, 2016
  6. Mike HommeyJan 9, 2016
  7. Mike HommeyJan 9, 2016
  8. Junio C HamanoJan 9, 2016
  9. Mike HommeyJan 9, 2016
  10. Junio C HamanoJan 11, 2016
  11. Philip OakleyJan 9, 2016
  12. Junio C HamanoJan 11, 2016

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.