Code

branch: don't fail listing branches if one of the commits wasn't found
authorSimo Melenius <simo.melenius@iki.fi>
Fri, 4 Jun 2010 09:50:11 +0000 (12:50 +0300)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jun 2010 22:50:00 +0000 (15:50 -0700)
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>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c

index 5f0873ab689ac805f24c749709ed314419e35c08..a92de9a066892ef98c7a33232c83532edf94973a 100644 (file)
@@ -301,7 +301,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
                commit = lookup_commit_reference_gently(sha1, 1);
                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 */
@@ -539,6 +539,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");
+
        return cb.ret;
 }