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

Re: [PATCH] branch: don't assume the merge filter ref exists

From
Jeff King <peff@peff.net>
Date
Feb 27, 2012, 19:30 UTC
Message-ID
<20120227193044.GD1600@sigill.intra.peff.net>
In-Reply-To
<1330355513-22351-1-git-send-email-cmn@elego.de>
On Mon, Feb 27, 2012 at 04:11:53PM +0100, Carlos Martín Nieto wrote:
Show 18 quoted lines
> print_ref_list looks up the merge_filter_ref and assumes that a valid
> pointer is returned. When the object doesn't exist, it tries to
> dereference a NULL pointer. This can be the case when git branch
> --merged is given an argument that isn't a valid commit name.
> 
> Check whether the lookup returns a NULL pointer and die with an error
> if it does. Add a test, while we're at it.
> 
> Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
> ---
> 
> It certainly looks like --merged was only ever supposed to be used
> with branch names, as it assumed that get_sha1() would catch the
> errors.
> 
> I'm not sure if "bad object" or "invalid object" fits better. "bad
> object" might have a stronger implication that it exists but is
> corrupt.
You would also get NULL if the object exists but is not a commit. Maybe:
  die("object '%s' does not point to a commit", ...)

would be better? It covers the wrong-type case, and is still technically true when the object does not exist.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 8 in “[BUG] git branch --merged $unknown_checksum segfaults”
  1. Bernhard Reutner-FischerFeb 27, 2012
  2. branch: don't assume the merge filter ref existsCarlos Martín Nieto, Feb 27, 2012
  3. Junio C HamanoFeb 27, 2012
  4. Jeff KingFeb 27, 2012
  5. Junio C HamanoFeb 27, 2012
  6. Jeff KingFeb 27, 2012
  7. Carlos Martín NietoFeb 28, 2012
  8. Junio C HamanoFeb 28, 2012

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.