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

Re: [PATCH 2/2] rev-parse: verify that commit looked up is not NULL

From
Todd Zullinger <tmz@pobox.com>
Date
May 23, 2018, 22:23 UTC
Message-ID
<20180523222358.GW26695@zaya.teonanacatl.net>
In-Reply-To
<20180523221901.GV26695@zaya.teonanacatl.net>
I wrote:
> Thanks.  This fixes the segfault.  While I was testing this,
> I wondered if the following cases should differ:

Nevermind me. Jeff beat me to a reply and included much more useful details about why this occurs and suggestions for fixing it. :)

Show 29 quoted lines
> #          f*40
> $ ./git-rev-parse ffffffffffffffffffffffffffffffffffffffff^@ ; echo $?
> 0
> 
> #          f*39
> $ ./git-rev-parse fffffffffffffffffffffffffffffffffffffff^@ ; echo $?
> fffffffffffffffffffffffffffffffffffffff^@
> fatal: ambiguous argument 'fffffffffffffffffffffffffffffffffffffff^@': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> 128
> 
> Looking a little further, this is deeper than the rev-parse
> handling.  The difference in how these invalid refs are
> handled appears in 'git show' as well.  With 'git show' a
> (different) fatal error is returned in both cases.
> 
> #          f*40
> $ git show ffffffffffffffffffffffffffffffffffffffff
> fatal: bad object ffffffffffffffffffffffffffffffffffffffff
> 
> #          39*f
> $ git show fffffffffffffffffffffffffffffffffffffff
> fatal: ambiguous argument 'fffffffffffffffffffffffffffffffffffffff': unknown revision or path not in the working tree.
> Use '--' to separate paths from revisions, like this:
> 'git <command> [<revision>...] -- [<file>...]'
> 
> Should rev-parse return an error as well, rather than
> silenty succeeding?
-- 
Todd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How can I tell that the past isn't a fiction designed to account for
the discrepancy between my immediate physical sensation and my state
of mind?
    -- Douglas Adams
Previous: Todd ZullingerNext: Jeff King
Message 13 of 14 in “BUG: rev-parse segfault with invalid input”
  1. Todd ZullingerMay 23, 2018
  2. Elijah NewrenMay 23, 2018
  3. Todd ZullingerMay 23, 2018
  4. 1/2 t6101: add a test for rev-parse $garbage^@Elijah Newren, May 23, 2018
  5. 2/2 rev-parse: verify that commit looked up is not NULLElijah Newren, May 23, 2018
  6. Jeff KingMay 23, 2018
  7. rev-parse: check lookup'ed commit references for NULLElijah Newren, May 24, 2018
  8. Todd ZullingerMay 24, 2018
  9. Florian WeimerMay 24, 2018
  10. Jeff KingMay 24, 2018
  11. Junio C HamanoMay 25, 2018
  12. Todd ZullingerMay 23, 2018
  13. Todd ZullingerMay 23, 2018
  14. Jeff KingMay 23, 2018

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.