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

[PATCH 0/2] Fix a refname trimming problem in `log --bisect`

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jun 14, 2017, 09:07 UTC
Message-ID
<cover.1497430232.git.mhagger@alum.mit.edu>
In-Reply-To
<5a3f6af6-f936-50e7-5fca-c41b3aeefdce@alum.mit.edu>

The code for `git log --bisect` was calling `for_each_ref_in_submodule()` with prefix set to "refs/bisect/bad", which is the actual name of the reference that it wants. This resulted in the refname being trimmed completely away and the empty string being passed to the callback. That became impermissible after

    b9c8e7f2fb prefix_ref_iterator: don't trim too much, 2017-05-22
, so the command was failing.
Fix the problem in two orthogonal ways:
1. Add a new function, `for_each_fullref_in_submodule()`, that doesn't
   trim the refnames that it passes to callbacks, and us that instead.
   I *think* that this is a strict improvement, though I don't know
   the `git log` code well enough to be sure that it won't have bad
   side-effects.
2. Relax the "trimming too many characters" check to allow the full
   length of the refname to be trimmed away (though not more than
   that).

In an ideal world the second patch shouldn't be necessary, because this calling pattern is questionable and it might be better that we learn about any other offenders. But if we'd rather be conservative and not break any other code that might rely on the old behavior, patch 2 is my suggestion for how to do it.

This patch series can be applied on top of branch `mh/packed-ref-store-prep`, but it also applies cleanly to master. It is also available as branch `fix-bisect-trim-check` from my GitHub fork [1].

Michael
[1] https://github.com/mhagger/git
Michael Haggerty (2):
  for_each_bisect_ref(): don't trim refnames
  prefix_ref_iterator_advance(): relax the check of trim length
 refs.c          | 12 ++++++++++++
 refs.h          |  5 ++++-
 refs/iterator.c |  8 ++++----
 revision.c      |  2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)
-- 
2.11.0
Previous: Michael HaggertyNext: Michael Haggerty
Message 3 of 12 in “[BUG] b9c8e7f2fb6e breaks git bisect visualize”
  1. Øyvind A. HolmJun 14, 2017
  2. Michael HaggertyJun 14, 2017
  3. 0/2 Fix a refname trimming problem in `log --bisect`Michael Haggerty, Jun 14, 2017
  4. 2/2 prefix_ref_iterator_advance(): relax the check of trim lengthMichael Haggerty, Jun 14, 2017
  5. 1/2 for_each_bisect_ref(): don't trim refnamesMichael Haggerty, Jun 14, 2017
  6. Jeff KingJun 14, 2017
  7. Jeff KingJun 14, 2017
  8. Junio C HamanoJun 14, 2017
  9. Junio C HamanoJun 15, 2017
  10. Jeff KingJun 14, 2017
  11. Junio C HamanoJun 14, 2017
  12. Jeff KingJun 14, 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.