Thread (12 messages) flat view 12 messages, 3 authors, 2016-06-15

Bug? "git branch" failing to list all branches

From: Simo Melenius <hidden>
Date: 2016-06-15 22:48:54
Subsystem: the rest · Maintainer: Linus Torvalds

I consider this a bug and wrote a fix. I would now like to ask the git
maintainers' opinion with regard to it.

When listing branches, "git branch" will in certain cases terminate
iteration at the first broken ref that doesn't point to a commit. This
will silently hide any remaining refs from the output listing.
However, this failure is not communicated upwards either, so I think
append_ref() goes wrong to terminate the whole loop because of this.

I noticed this because "git branch -a" and "git branch -av"
unexpectedly gave a very different output.


Simo
diff --git a/builtin/branch.c b/builtin/branch.c
index 6cf7e72..1a8e3d3 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -294,7 +294,10 @@ static int append_ref(const char *refname, const
unsigned char *sha1, int flags,
        if (ref_list->verbose || ref_list->with_commit || merge_filter
!= NO_FILTER) {
                commit = lookup_commit_reference_gently(sha1, 1);
                if (!commit)
-                       return error("branch '%s' does not point at a
commit", refname);
+               {
+                       error("branch '%s' does not point at a
commit", refname);
+                       return 0;
+               }

                /* Filter with with_commit if specified */
                if (!is_descendant_of(commit, ref_list->with_commit))

-- 
() Today is the car of the cdr of your life.
/\ http://arc.pasp.de/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help