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

Re: Truncating HEAD reflog on branch move

From
Jeff King <peff@peff.net>
Date
Jun 22, 2017, 21:52 UTC
Message-ID
<20170622215235.to6yleo3adt5klv2@sigill.intra.peff.net>
In-Reply-To
<xmqqd19vix03.fsf@gitster.mtv.corp.google.com>
On Thu, Jun 22, 2017 at 01:32:44PM -0700, Junio C Hamano wrote:
> I do not think command line parser does not allow "log -g
> maint..master" so all the "limited" processing the remainder of
> get_revision_1() does shouldn't matter.

Yeah, I don't think negative endpoints work at all, and "foo...bar" seems to also break (though with a confusing message). It seems clear to me that multiple positive endpoints don't work well either, if they have overlapping commits.

> I however think pathspec will affect simplify_commit() and suspect
> that "git log -g -20 HEAD path" will behave differently.  Perhaps
> the difference is "it used to use path in an unexplainable way, now
> it ignores", in which case this is an improvement.

The current behavior there does seem like nonsense, because it's based on the fake parents. For instance, if I set up a simple two-branch case:

  commit() {
	echo "$1" >"$1" && git add "$1" && git commit -m "$1"
  }
  git init repo
  cd repo
  commit base
  commit master
  git checkout -b side HEAD^
  commit side
  git merge --no-edit master
  commit combined
Then I get:
  $ git log -g --oneline --name-status -- master
  f06c3cd HEAD@{1}: merge master: Merge made by the 'recursive' strategy.
  5bf12c4 HEAD@{3}: checkout: moving from master to side
  dfa408b HEAD@{4}: commit: master
  A       master

Even though only one of those commits touched master. But with my patch, it's also somewhat confusing. We ignore the pathspec when picking which commits to show, but still apply it for diffing. So:

  03cf1ad HEAD@{0}: commit: combined
  f06c3cd HEAD@{1}: merge master: Merge made by the 'recursive' strategy.
  277042b HEAD@{2}: commit: side
  5bf12c4 HEAD@{3}: checkout: moving from master to side
  dfa408b HEAD@{4}: commit: master
  A       master
  5bf12c4 HEAD@{5}: commit (initial): base

I think we'd want to just omit any entries that are TREESAME to their parents. We don't actually care about true parent rewriting (since we're not walking the parents), but if it happened as a side effect that would probably be OK.

It looks like simplify_commit() is also where we apply bits like --no-merges, which doesn't work with my patch. It _also_ behaves nonsensically in the current code, because of course the fake reflog parents are never merges.

Which really makes me feel like this patch is going in the right direction, as it makes all of this behave conceptually like:

  while read old new etc ...
  do
    git show $new
  done <.git/logs/$ref

which is simple to explain and is what I'd expect (and is certainly the direction we went with the "diff uses real parents" commit).

We just need to hit the simplify_commit() code path here.
-Peff
Previous: Junio C HamanoNext: Jeff King
Message 11 of 69 in “Truncating HEAD reflog on branch move”
  1. brian m. carlsonJun 21, 2017
  2. Junio C HamanoJun 21, 2017
  3. Kyle MeyerJun 21, 2017
  4. Kyle MeyerJun 21, 2017
  5. Jeff KingJun 22, 2017
  6. Junio C HamanoJun 22, 2017
  7. Jeff KingJun 22, 2017
  8. Junio C HamanoJun 22, 2017
  9. Jeff KingJun 22, 2017
  10. Junio C HamanoJun 22, 2017
  11. Jeff KingJun 22, 2017
  12. Jeff KingJun 22, 2017
  13. Jeff KingJun 23, 2017
  14. brian m. carlsonJul 4, 2017
  15. Jeff KingJul 4, 2017
  16. brian m. carlsonJul 4, 2017
  17. Jeff KingJul 4, 2017
  18. Junio C HamanoJul 5, 2017
  19. 0/6 fixing reflog-walk odditiesJeff King, Jul 5, 2017
  20. 1/6 reflog-walk: skip over double-null oid due to HEAD renameJeff King, Jul 5, 2017
  21. Junio C HamanoJul 5, 2017
  22. Jeff KingJul 5, 2017
  23. 2/6 t1414: document some reflog-walk odditiesJeff King, Jul 5, 2017
  24. Junio C HamanoJul 5, 2017
  25. Jeff KingJul 5, 2017
  26. Junio C HamanoJul 5, 2017
  27. Jeff KingJul 6, 2017
  28. Jeff KingJul 6, 2017
  29. Junio C HamanoJul 6, 2017
  30. Jeff KingJul 7, 2017
  31. Junio C HamanoJul 7, 2017
  32. Jeff KingJul 7, 2017
  33. Ramsay JonesJul 5, 2017
  34. Jeff KingJul 5, 2017
  35. 3/6 log: do not free parents when walking reflogJeff King, Jul 5, 2017
  36. 4/6 get_revision_1(): replace do-while with an early returnJeff King, Jul 5, 2017
  37. 5/6 rev-list: check reflog_info before showing usageJeff King, Jul 5, 2017
  38. Junio C HamanoJul 5, 2017
  39. Jeff KingJul 5, 2017
  40. 6/6 reflog-walk: stop using fake parentsJeff King, Jul 5, 2017
  41. Eric WongJul 7, 2017
  42. Jeff KingJul 7, 2017
  43. Jeff KingJul 7, 2017
  44. Eric WongJul 10, 2017
  45. Jeff KingJul 10, 2017
  46. Junio C HamanoJul 10, 2017
  47. 0/4 reflog-walk fixes for maintJeff King, Jul 7, 2017
  48. 1/4 reflog-walk: skip over double-null oid due to HEAD renameJeff King, Jul 7, 2017
  49. 2/4 reflog-walk: duplicate strings in complete_reflogs listJeff King, Jul 7, 2017
  50. 3/4 reflog-walk: don't free reflogs added to cacheJeff King, Jul 7, 2017
  51. 4/4 reflog-walk: include all fields when freeing complete_reflogsJeff King, Jul 7, 2017
  52. 0/7 fixing reflog-walk odditiesJeff King, Jul 7, 2017
  53. 1/7 t1414: document some reflog-walk odditiesJeff King, Jul 7, 2017
  54. Jeff KingJul 7, 2017
  55. Kyle MeyerJul 7, 2017
  56. 2/7 revision: disallow reflog walking with revs->limitedJeff King, Jul 7, 2017
  57. 4/7 get_revision_1(): replace do-while with an early returnJeff King, Jul 7, 2017
  58. 5/7 rev-list: check reflog_info before showing usageJeff King, Jul 7, 2017
  59. 3/7 log: do not free parents when walking reflogJeff King, Jul 7, 2017
  60. Junio C HamanoJul 7, 2017
  61. Jeff KingJul 9, 2017
  62. Junio C HamanoJul 9, 2017
  63. Jeff KingJul 10, 2017
  64. 6/7 reflog-walk: stop using fake parentsJeff King, Jul 7, 2017
  65. Jeff KingJul 7, 2017
  66. Kyle MeyerJul 7, 2017
  67. Jeff KingJul 9, 2017
  68. 7/7 reflog-walk: apply --since/--until to reflog datesJeff King, Jul 7, 2017
  69. Junio C HamanoJul 7, 2017

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.