git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git cherry-pick: Add NULL check to sequencer parsing of HEAD
@ 2012-05-03 11:20 Neil Horman
  2012-05-03 11:45 ` René Scharfe
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Neil Horman @ 2012-05-03 11:20 UTC (permalink / raw)
  To: git; +Cc: mmueller, rene.scharfe, Matthieu.Moy, gitster, 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;
+
+	if (parse_commit(head_commit))
 		return error(_("could not parse commit %s\n"),
 			     sha1_to_hex(head_commit->object.sha1));
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-05-03 17:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-03 11:20 [PATCH] git cherry-pick: Add NULL check to sequencer parsing of HEAD Neil Horman
2012-05-03 11:45 ` René Scharfe
2012-05-03 12:08   ` Neil Horman
2012-05-03 12:26     ` René Scharfe
2012-05-03 12:10 ` [PATCH v2] " Neil Horman
2012-05-03 14:09 ` [PATCH v3] " Neil Horman
2012-05-03 16:48   ` Matthieu Moy
2012-05-03 17:13     ` Junio C Hamano
     [not found]   ` <7vsjfhfbko.fsf@alter.siamese.dyndns.org>
2012-05-03 17:34     ` Neil Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).