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

Re: [PATCH] git cherry-pick: Add NULL check to sequencer parsing of HEAD

From
Neil Horman <nhorman@tuxdriver.com>
Date
May 3, 2012, 12:08 UTC
Message-ID
<20120503120857.GA3085@hmsreliant.think-freely.org>
In-Reply-To
<4FA26FF2.2050607@lsrfire.ath.cx>
On Thu, May 03, 2012 at 01:45:54PM +0200, René Scharfe wrote:
Show 31 quoted lines
> Am 03.05.2012 13:20, schrieb Neil Horman:
> >Michael Mueller noted that a feature I recently added failed to check the return
> >of lookup_commit to ensure that it was not NULL.  I don't think a NULL can
> >actually happen in the this particular use case, but regardless it seems a good
> >idea to check.
> >
> >Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> >---
> >  sequencer.c |   11 ++++++++++-
> >  1 files changed, 10 insertions(+), 1 deletions(-)
> >
> >diff --git a/sequencer.c b/sequencer.c
> >index f83cdfd..ad4d781 100644
> >--- a/sequencer.c
> >+++ b/sequencer.c
> >@@ -261,7 +261,16 @@ static int is_index_unchanged(void)
> >  		return error(_("Could not resolve HEAD commit\n"));
> >
> >  	head_commit = lookup_commit(head_sha1);
> >-	if (!head_commit || parse_commit(head_commit))
> >+
> >+	/*
> >+	 * If head_commit is NULL, just return, as check_commit,
> >+	 * called from lookup_commit, would have indicated that
> >+	 * head_commit is not a commit object already.
> >+	 */
> >+	if (!head_commit)
> >+		return;
> 
> A return value is missing.  Perhaps -1?
> 
Yeah, sorry, not sure how I missed the compiler warning.
Show 7 quoted lines
> >+
> >+	if (parse_commit(head_commit))
> >  		return error(_("could not parse commit %s\n"),
> >  			     sha1_to_hex(head_commit->object.sha1));
> 
> Note: parse_commit() can handle NULL, and it already reports error
> details itself.

No, it doesn't. parse_commit checks NULL already, true, but it just returns -1. No error message is provided to the user Neil

> 
> René
> 
Previous: René ScharfeNext: René Scharfe
Message 3 of 9 in “git cherry-pick: Add NULL check to sequencer parsing of HEAD”
  1. git cherry-pick: Add NULL check to sequencer parsing of HEADNeil Horman, May 3, 2012
  2. René ScharfeMay 3, 2012
  3. Neil HormanMay 3, 2012
  4. René ScharfeMay 3, 2012
  5. git cherry-pick: Add NULL check to sequencer parsing of HEADNeil Horman, May 3, 2012
  6. git cherry-pick: Add NULL check to sequencer parsing of HEADNeil Horman, May 3, 2012
  7. Matthieu MoyMay 3, 2012
  8. Junio C HamanoMay 3, 2012
  9. Neil HormanMay 3, 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.