git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simo Melenius <simo.melenius@iki.fi>
To: git@vger.kernel.org
Subject: Bug? "git branch" failing to list all branches
Date: Wed, 2 Jun 2010 17:47:41 +0300	[thread overview]
Message-ID: <AANLkTimTOucIfzSxsYNvmML7MALwj0E3BUASIIKIN1lN@mail.gmail.com> (raw)

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/

             reply	other threads:[~2010-06-02 14:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 14:47 Simo Melenius [this message]
2010-06-03  4:22 ` Bug? "git branch" failing to list all branches Jonathan Nieder
2010-06-03  6:00   ` Simo Melenius
2010-06-03  6:55     ` Jonathan Nieder
2010-06-03  7:48       ` [PATCH 1/2] branch: exit status now reflects if branch listing finds an error Simo Melenius
2010-06-04  2:24         ` Jonathan Nieder
2010-06-03  7:48       ` [PATCH 2/2] branch: don't fail listing branches if one of the commits wasn't found Simo Melenius
2010-06-03 17:42         ` Sverre Rabbelier
2010-06-04  2:43         ` Jonathan Nieder
2010-06-04  9:48           ` Simo Melenius
2010-06-04  9:50             ` [PATCH 1/2] branch: exit status now reflects if branch listing finds an error Simo Melenius
2010-06-04  9:50             ` [PATCH 2/2] branch: don't fail listing branches if one of the commits wasn't found Simo Melenius

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimTOucIfzSxsYNvmML7MALwj0E3BUASIIKIN1lN@mail.gmail.com \
    --to=simo.melenius@iki.fi \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).