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

[PATCH 2/2] branch: don't fail listing branches if one of the commits wasn't found

From
SMSimo Melenius <simo.melenius@iki.fi>
Date
Jun 3, 2010, 07:48 UTC
Message-ID
<1275551282-21557-2-git-send-email-simo.melenius@iki.fi>
In-Reply-To
<20100603065527.GA23439@progeny.tock>

When listing branches with ref lookups, if one of the known raw refs doesn't point to a commit then "git branch" would return error(), terminating the whole for_each_rawref() iteration and possibly hiding any remaining refs.

Signed-off-by: Simo Melenius <simo.melenius@iki.fi>
---
 builtin/branch.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index 46ca59c..2242743 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -303,7 +303,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
 		if (!commit)
 		{
 			cb->ret = error("branch '%s' does not point at a commit", refname);
-			return cb->ret;
+			return 0;
 		}
 
 		/* Filter with with_commit if specified */
@@ -541,6 +541,9 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru
 
 	free_ref_list(&ref_list);
 
+	if (cb.ret)
+		error("some refs could not be read, review stderr");
+
 	return cb.ret;
 }
 
-- 
1.7.0.4
Previous: Jonathan NiederNext: Sverre Rabbelier
Message 7 of 9 in “Bug? "git branch" failing to list all branches”
  1. Simo MeleniusJun 2, 2010
  2. Jonathan NiederJun 3, 2010
  3. Simo MeleniusJun 3, 2010
  4. Jonathan NiederJun 3, 2010
  5. 1/2 branch: exit status now reflects if branch listing finds an errorSimo Melenius, Jun 3, 2010
  6. Jonathan NiederJun 4, 2010
  7. 2/2 branch: don't fail listing branches if one of the commits wasn't foundSimo Melenius, Jun 3, 2010
  8. Sverre RabbelierJun 3, 2010
  9. Jonathan NiederJun 4, 2010

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.