# [PATCH] branch: only print upstream relationship with -v -v

4 messages from 2010-03-17 to 2010-03-18. Participants: Nguyễn Thái Ngọc Duy, Michael J Gruber, Junio C Hamano, Nguyen Thai Ngoc Duy.
Thread: https://gitlist.dev/t/23050

## Nguyễn Thái Ngọc Duy, 2010-03-17 15:05

Subject: [PATCH] branch: only print upstream relationship with -v -v
Message-ID: <1268838344-8581-1-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1268838344-8581-1-git-send-email-pclouds%40gmail.com

```
"git branch -v" is unusable for me because it's too slow. After this
patch:

pclouds@do ~/w/git $ time ./git branch -v > /dev/null
real    0m0.016s
user    0m0.011s
sys     0m0.004s

pclouds@do ~/w/git $ time ./git branch -v -v > /dev/null
real    0m8.960s
user    0m8.854s
sys     0m0.029s

This is on a repository with ~30 branches, some are hundreds of
patches behind upstream.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Maybe it's just me, with my old branches...

 Documentation/git-branch.txt |    6 +++---
 builtin/branch.c             |    4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 903a690..4380846 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -101,9 +101,9 @@ OPTIONS
 
 -v::
 --verbose::
-	Show sha1 and commit subject line for each head, along with
-	relationship to upstream branch (if any). If given twice, print
-	the name of the upstream branch, as well.
+	Show sha1 and commit subject line for each head. If given twice,
+	also the relationship to upstream branch (if any). If given
+	three times, print the name of the upstream branch, as well.
 
 --abbrev=<length>::
 	Alter the sha1's minimum display length in the output listing.
diff --git a/builtin/branch.c b/builtin/branch.c
index 6cf7e72..eb407f0 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -439,8 +439,8 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 			sub = subject.buf;
 		}
 
-		if (item->kind == REF_LOCAL_BRANCH)
-			fill_tracking_info(&stat, item->name, verbose > 1);
+		if (item->kind == REF_LOCAL_BRANCH && verbose > 1)
+			fill_tracking_info(&stat, item->name, verbose > 2);
 
 		strbuf_addf(&out, " %s %s%s",
 			find_unique_abbrev(item->commit->object.sha1, abbrev),
-- 
1.7.0.1.390.g67bca

```

## Michael J Gruber, 2010-03-17 16:21

Subject: Re: [PATCH] branch: only print upstream relationship with -v -v
Message-ID: <4BA1017E.1010404@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4BA1017E.1010404%40drmicha.warpmail.net
In-Reply-To: <1268838344-8581-1-git-send-email-pclouds@gmail.com>

```
Nguyễn Thái Ngọc Duy venit, vidit, dixit 17.03.2010 16:05:
> "git branch -v" is unusable for me because it's too slow. After this
> patch:
> 
> pclouds@do ~/w/git $ time ./git branch -v > /dev/null
> real    0m0.016s
> user    0m0.011s
> sys     0m0.004s
> 
> pclouds@do ~/w/git $ time ./git branch -v -v > /dev/null
> real    0m8.960s
> user    0m8.854s
> sys     0m0.029s
> 

Well, but also, after your patch the old output format of "git branch
-v" is not available any more at all! I mean, what is wrong with

git log --oneline --no-walk --branches --decorate

or

git rev-list --oneline --no-walk --branches

depending on what it is that you're really after? (Not to mention
for-each-ref.)

Michael

```

## Junio C Hamano, 2010-03-17 16:53

Subject: Re: [PATCH] branch: only print upstream relationship with -v -v
Message-ID: <7vwrxavqig.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwrxavqig.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1268838344-8581-1-git-send-email-pclouds@gmail.com>

```
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> "git branch -v" is unusable for me because it's too slow.
> ...
> This is on a repository with ~30 branches, some are hundreds of
> patches behind upstream.

Perhaps you have an overeager branch.autosetupmerge configuration?

I dunno.  I seem to have a lot more branches than you do (currently
56), but most of them are topics that, once they forked from a
particular commit, never merge other random commits, only because they
have new commits that are unrelated to the objective of the topic, so
most of my branches do not have "upstream" in that sense.

```

## Nguyen Thai Ngoc Duy, 2010-03-18 00:06

Subject: Re: [PATCH] branch: only print upstream relationship with -v -v
Message-ID: <fcaeb9bf1003171706s31870438kc69606389495876d@mail.gmail.com>
URL: https://gitlist.dev/e/fcaeb9bf1003171706s31870438kc69606389495876d%40mail.gmail.com
In-Reply-To: <7vwrxavqig.fsf@alter.siamese.dyndns.org>

```
On 3/17/10, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>  > "git branch -v" is unusable for me because it's too slow.
>
> > ...
>
> > This is on a repository with ~30 branches, some are hundreds of
>  > patches behind upstream.
>
>
> Perhaps you have an overeager branch.autosetupmerge configuration?

No. Never heard of it.

>  I dunno.  I seem to have a lot more branches than you do (currently
>  56), but most of them are topics that, once they forked from a
>  particular commit, never merge other random commits, only because they
>  have new commits that are unrelated to the objective of the topic, so
>  most of my branches do not have "upstream" in that sense.

I did sysprof and it seems half the time was spent inside
merge_bases_many(). Being a complete ignorant about merging stuff, I
put "return NULL;" at the beginning of that function, "git branch -v"
now goes down to 2 seconds. Don't know if that could tell anything.
-- 
Duy

```
