git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
@ 2008-07-01  9:13 Ingo Molnar
  2008-07-01  9:26 ` Bruce Stephens
  2008-07-01  9:32 ` Junio C Hamano
  0 siblings, 2 replies; 28+ messages in thread
From: Ingo Molnar @ 2008-07-01  9:13 UTC (permalink / raw)
  To: git


i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:

  Switched to branch "master"
  Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.

it's a very useful detail! It's especially useful when two branches 
diverge in a non-trivial way.

I used to have ad-hoc scripts to discover this in the past:

 earth4:~/tip> tip-compare-remote
 master                        : differs from remote (-50 commits)
 tip                           : differs from remote (-1 commits)
 x86/ptrace                    : differs from remote (-1 commits)
 x86/unify-setup               : differs from remote (-2 commits)
 x86/xen-64bit                 : differs from remote (-1 commits)

but having a reminder at checkout time is even better (and faster as 
well). Kudos.

	Ingo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01  9:13 [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Ingo Molnar
@ 2008-07-01  9:26 ` Bruce Stephens
  2008-07-01 10:14   ` Ingo Molnar
  2008-07-01 12:44   ` [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Jakub Narebski
  2008-07-01  9:32 ` Junio C Hamano
  1 sibling, 2 replies; 28+ messages in thread
From: Bruce Stephens @ 2008-07-01  9:26 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: git

Ingo Molnar <mingo@elte.hu> writes:

> i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
>
>   Switched to branch "master"
>   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
>
> it's a very useful detail! It's especially useful when two branches 
> diverge in a non-trivial way.

I agree, it's a really nice little feature.  Indeed, I occasionally do
"git checkout master" just to get the message (to see where I am).

It feels logical for "git status" to offer the same information (when
the information is appropriate).

[...]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01  9:13 [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Ingo Molnar
  2008-07-01  9:26 ` Bruce Stephens
@ 2008-07-01  9:32 ` Junio C Hamano
  2008-07-01 10:07   ` Ingo Molnar
  1 sibling, 1 reply; 28+ messages in thread
From: Junio C Hamano @ 2008-07-01  9:32 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: git

Ingo Molnar <mingo@elte.hu> writes:

> i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
>
>   Switched to branch "master"
>   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
>
> it's a very useful detail! It's especially useful when two branches 
> diverge in a non-trivial way.
> ...
> but having a reminder at checkout time is even better (and faster as 
> well). Kudos.

Thanks for a rare positive usability feedback.  When I started reading
your message, I almost expected that I'd hear you say "I am getting this
useless cruft and it wastes extra cycles."

Somebody must have had a very bright idea that day in late February this
year.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01  9:32 ` Junio C Hamano
@ 2008-07-01 10:07   ` Ingo Molnar
  2008-07-01 11:16     ` Miklos Vajna
                       ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Ingo Molnar @ 2008-07-01 10:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

* Junio C Hamano <gitster@pobox.com> wrote:

> Ingo Molnar <mingo@elte.hu> writes:
> 
> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
> >
> >   Switched to branch "master"
> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
> >
> > it's a very useful detail! It's especially useful when two branches 
> > diverge in a non-trivial way.
> > ...
> > but having a reminder at checkout time is even better (and faster as 
> > well). Kudos.
> 
> Thanks for a rare positive usability feedback.  When I started reading 
> your message, I almost expected that I'd hear you say "I am getting 
> this useless cruft and it wastes extra cycles."

Git usability is certainly very good. (And what matters even more to me 
than absolute usability, Git's usability is improving in a monotonic 
way.)

[ You normally only hear from me if i find one of those rare outliers
  that confuse me somewhere. So by reading my feedback you must be
  getting an impression of problems only - that is far from the truth :) ]

> Somebody must have had a very bright idea that day in late February 
> this year.

:)

There's a small detail i was thinking about: is there a way to get this 
extra output without actually switching branches? Right now i do this:

 earth4:~/tip> git-checkout tip; git-checkout master
 Checking out files: 100% (2437/2437), done.
 Switched to branch "tip"
 Switched to branch "master"
 Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.

(Which is an admitted lame solution but the best i could figure.)

Also, and let me hijack this thread, i sometimes feel adventurous and 
try out git/pu for kicks. I tried it two days ago and it was quite OK, 
with some fallout:

- the git-dash changes broke half of our scripts around git. (We've got
  about 50 tip-* scripts around various git details, about 2200 lines). 

I did a mass changeover:

   31 files changed, 150 insertions(+), 150 deletions(-)

... and that broke things too - see the two fixes below. I can 
understand your desire for a git-dash-less world though, but it's 
causing some pain :-) Also, i kept typoing "git-" commands all the time 
so i switched back to git/master. Maybe there should be a transition 
period where the dash scripts warn if used interactively? Dunno.

[ and there's also a git-rerere Heisenbug i have been fighting with a 
  lot with git-1.5.5. It's quite hard to reproduce and unfortunately i 
  cannot create a reproducer: but it resulted in git-rerere confusing 
  conflict resolutions and putting arch/x86/kernel/process_64.c 
  postimage entry into the entry for arch/x86/kernel/process_32.c's 
  postimage file, corrupting the integration run on the _next_ run.

  Was there a bug in this area fixed recently that would show up with 
  such symptoms? The weirdness first showed up when i did a git-rerere 
  after having done a git-add arch/x86/kernel/process_64.c, git-rerere 
  printed that it added a new resolution for 
  arch/x86/kernel/process_32.c. ]

and i like this warning at the end of master/pu make install:

!! You have installed git-* commands to new gitexecdir.
!! Old version git-* commands still remain in bindir.
!! Mixing two versions of Git will lead to problems.
!! Please remove old version commands in bindir now.

that's an easily overlooked detail.

	Ingo

--------------->
commit e87616175691dd7154cad049aae2b1bc1385bb7a
Author: Ingo Molnar <mingo@elte.hu>
Date:   Mon Jun 30 09:29:36 2008 +0200

    - fix more git-dash fallout
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

diff --git a/.tip/bin/tip-backup b/.tip/bin/tip-backup
index edd7991..682d68d 100755
--- a/.tip/bin/tip-backup
+++ b/.tip/bin/tip-backup
@@ -7,7 +7,7 @@ check_master
 echo "backing up the full -tip repo ..."
 mkdir -p ~/tip-backups || exit -1
 
-FILE=~/tip-backups/tip-git $(get_date_for_tag).tar.bz2
+FILE=~/tip-backups/tip-git-$(get_date_for_tag).tar.bz2
 
 tar cjf $FILE .git || exit -1
 
commit 1bcce26cf0ba00ea62c051772f66d3e1c616e165
Author: H. Peter Anvin <hpa@zytor.com>
Date:   Fri Jun 27 17:05:59 2008 -0700

    tip-sync-remote: quote multiword commands in variables
    
    When assigning a multiword command to a variable, it needs to be
    quoted.

diff --git a/.tip/bin/tip-sync-remote b/.tip/bin/tip-sync-remote
index 6421e55..aeeb883 100755
--- a/.tip/bin/tip-sync-remote
+++ b/.tip/bin/tip-sync-remote
@@ -65,9 +65,9 @@ do
     then
 	echo "Branch "$B" has local modifications"
 	echo "Rebasing local modifications to remote"
-	CMD=git rebase
+	CMD='git rebase'
     else
-	CMD=git merge
+	CMD='git merge'
     fi
 
     $CMD origin/$B || {

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01  9:26 ` Bruce Stephens
@ 2008-07-01 10:14   ` Ingo Molnar
  2008-07-01 11:41     ` SZEDER Gábor
  2008-07-01 19:16     ` Junio C Hamano
  2008-07-01 12:44   ` [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Jakub Narebski
  1 sibling, 2 replies; 28+ messages in thread
From: Ingo Molnar @ 2008-07-01 10:14 UTC (permalink / raw)
  To: Bruce Stephens; +Cc: git

* Bruce Stephens <bruce.stephens@isode.com> wrote:

> Ingo Molnar <mingo@elte.hu> writes:
> 
> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
> >
> >   Switched to branch "master"
> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
> >
> > it's a very useful detail! It's especially useful when two branches 
> > diverge in a non-trivial way.
> 
> I agree, it's a really nice little feature.  Indeed, I occasionally do 
> "git checkout master" just to get the message (to see where I am).
> 
> It feels logical for "git status" to offer the same information (when 
> the information is appropriate).
> 
> [...]

i have a tip-curr (shortcut: 'tc') scriptlet to answer the "where I am 
amongst 100+ branches" question:

  earth4:~/tip> tc
  tip/master 200a86b: Merge branch 'x86/unify-setup'

which is just a thin wrapper around git-log:

  earth4:~/tip> cat ~/bin/tip/tip-curr
  #!/bin/bash

  . ~/bin/tip/tip-lib

  echo "tip/"$(get_current_branch)" "$(git log -1 --pretty=format:"%h: %s")

	Ingo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 10:07   ` Ingo Molnar
@ 2008-07-01 11:16     ` Miklos Vajna
  2008-07-01 11:22       ` Ingo Molnar
  2008-07-01 12:46     ` Mikael Magnusson
  2008-07-01 18:01     ` Björn Steinbrink
  2 siblings, 1 reply; 28+ messages in thread
From: Miklos Vajna @ 2008-07-01 11:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Junio C Hamano, git

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

On Tue, Jul 01, 2008 at 12:07:25PM +0200, Ingo Molnar <mingo@elte.hu> wrote:
> !! You have installed git-* commands to new gitexecdir.
> !! Old version git-* commands still remain in bindir.
> !! Mixing two versions of Git will lead to problems.
> !! Please remove old version commands in bindir now.
> 
> that's an easily overlooked detail.

There is a 10-lines-length note about this in RelNotes, but I think
removing the old version is a task of the package manager. At least till
the git Makefile does not have an 'uninstall' target.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 11:16     ` Miklos Vajna
@ 2008-07-01 11:22       ` Ingo Molnar
  2008-07-01 11:41         ` Miklos Vajna
  2008-07-04  8:35         ` Pedro Melo
  0 siblings, 2 replies; 28+ messages in thread
From: Ingo Molnar @ 2008-07-01 11:22 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Junio C Hamano, git


* Miklos Vajna <vmiklos@frugalware.org> wrote:

> On Tue, Jul 01, 2008 at 12:07:25PM +0200, Ingo Molnar <mingo@elte.hu> wrote:
> > !! You have installed git-* commands to new gitexecdir.
> > !! Old version git-* commands still remain in bindir.
> > !! Mixing two versions of Git will lead to problems.
> > !! Please remove old version commands in bindir now.
> > 
> > that's an easily overlooked detail.
> 
> There is a 10-lines-length note about this in RelNotes, but I think 
> removing the old version is a task of the package manager. At least 
> till the git Makefile does not have an 'uninstall' target.

random (likely stupid) idea: perhaps git could use ... a separate Git 
repo to track gitexecdir installations in $HOME/bin/? That could be 
tagged appropriately so you'd always know what to uninstall and whether 
there are clashes or incompatibilities.

[ Oh, and i could switch between git versions without having to rebuild
  ;-) ]

	Ingo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 11:22       ` Ingo Molnar
@ 2008-07-01 11:41         ` Miklos Vajna
  2008-07-01 23:55           ` Junio C Hamano
  2008-07-04  8:35         ` Pedro Melo
  1 sibling, 1 reply; 28+ messages in thread
From: Miklos Vajna @ 2008-07-01 11:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Junio C Hamano, git

[-- Attachment #1: Type: text/plain, Size: 373 bytes --]

On Tue, Jul 01, 2008 at 01:22:35PM +0200, Ingo Molnar <mingo@elte.hu> wrote:
> [ Oh, and i could switch between git versions without having to rebuild
>   ;-) ]

I remember about a mail from Junio where he wrote he has a lot of
versions installed under ~/git/git-version. So usually he has git from
next as default and he can try ~/git/git-1.5.4/git if he want 1.5.4,
etc.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 10:14   ` Ingo Molnar
@ 2008-07-01 11:41     ` SZEDER Gábor
  2008-07-01 12:47       ` Jakub Narebski
  2008-07-01 19:16     ` Junio C Hamano
  1 sibling, 1 reply; 28+ messages in thread
From: SZEDER Gábor @ 2008-07-01 11:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

Hi Ingo,

On Tue, Jul 01, 2008 at 12:14:15PM +0200, Ingo Molnar wrote:
> i have a tip-curr (shortcut: 'tc') scriptlet to answer the "where I am 
> amongst 100+ branches" question:
> 
>   earth4:~/tip> tc
>   tip/master 200a86b: Merge branch 'x86/unify-setup'
> 
> which is just a thin wrapper around git-log:
> 
>   earth4:~/tip> cat ~/bin/tip/tip-curr
>   #!/bin/bash
> 
>   . ~/bin/tip/tip-lib
> 
>   echo "tip/"$(get_current_branch)" "$(git log -1 --pretty=format:"%h: %s")
how about displaying the current branch in the command prompt?

>From contrib/completion/git-completion.bash:

  #    4) Consider changing your PS1 to also show the current branch:
  #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
  #
  #       The argument to __git_ps1 will be displayed only if you
  #       are currently in a git repository.  The %s token will be
  #       the name of the current branch.

Regards,
Gábor

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01  9:26 ` Bruce Stephens
  2008-07-01 10:14   ` Ingo Molnar
@ 2008-07-01 12:44   ` Jakub Narebski
  1 sibling, 0 replies; 28+ messages in thread
From: Jakub Narebski @ 2008-07-01 12:44 UTC (permalink / raw)
  To: Bruce Stephens; +Cc: Ingo Molnar, git

Bruce Stephens <bruce.stephens@isode.com> writes:

> Ingo Molnar <mingo@elte.hu> writes:
> 
> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
> >
> >   Switched to branch "master"
> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
> >
> > it's a very useful detail! It's especially useful when two branches 
> > diverge in a non-trivial way.
> 
> I agree, it's a really nice little feature.  Indeed, I occasionally do
> "git checkout master" just to get the message (to see where I am).
> 
> It feels logical for "git status" to offer the same information (when
> the information is appropriate).

I agree that having this information in git-status would be useful,
especially that it would make having this reminder in buffer/editor
when editing commit message.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 10:07   ` Ingo Molnar
  2008-07-01 11:16     ` Miklos Vajna
@ 2008-07-01 12:46     ` Mikael Magnusson
  2008-07-01 18:01     ` Björn Steinbrink
  2 siblings, 0 replies; 28+ messages in thread
From: Mikael Magnusson @ 2008-07-01 12:46 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Junio C Hamano, git

2008/7/1 Ingo Molnar <mingo@elte.hu>:
> * Junio C Hamano <gitster@pobox.com> wrote:
>
>> Ingo Molnar <mingo@elte.hu> writes:
>>
>> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:
>> >
>> >   Switched to branch "master"
>> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
>> >
>> > it's a very useful detail! It's especially useful when two branches
>> > diverge in a non-trivial way.
>> > ...
>> > but having a reminder at checkout time is even better (and faster as
>> > well). Kudos.
[snippy]
> There's a small detail i was thinking about: is there a way to get this
> extra output without actually switching branches? Right now i do this:
>
>  earth4:~/tip> git-checkout tip; git-checkout master
>  Checking out files: 100% (2437/2437), done.
>  Switched to branch "tip"
>  Switched to branch "master"
>  Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
>
> (Which is an admitted lame solution but the best i could figure.)

{14:44:16|~code/git}% git checkout master
Checking out files: 100% (180/180), done.
Switched to branch "master"
{14:44:24|~code/git}% git shard HEAD\~5
HEAD is now at 8e69d78 Merge branch 'maint'
{14:44:28|~code/git}% git checkout HEAD
Your branch is behind the tracked remote branch 'origin/master' by 6 commits,
and can be fast-forwarded.

-- 
Mikael Magnusson

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 11:41     ` SZEDER Gábor
@ 2008-07-01 12:47       ` Jakub Narebski
  0 siblings, 0 replies; 28+ messages in thread
From: Jakub Narebski @ 2008-07-01 12:47 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Ingo Molnar, Bruce Stephens, git

SZEDER Gábor <szeder@ira.uka.de> writes:

> how about displaying the current branch in the command prompt?
> 
> >From contrib/completion/git-completion.bash:
> 
>   #    4) Consider changing your PS1 to also show the current branch:
>   #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
>   #
>   #       The argument to __git_ps1 will be displayed only if you
>   #       are currently in a git repository.  The %s token will be
>   #       the name of the current branch.

Because I alos use StGit, I have added to my prompt visual
differentiation if the branch is under StGit control.

But I have my own git prompt function, based on git-completion.bash
but different.  It shows current branch (or "HEAD" if on detached
HEAD), current repository, and current working directory.  It laso has
number of command in history, the same as in my ordinary prompt.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 10:07   ` Ingo Molnar
  2008-07-01 11:16     ` Miklos Vajna
  2008-07-01 12:46     ` Mikael Magnusson
@ 2008-07-01 18:01     ` Björn Steinbrink
  2 siblings, 0 replies; 28+ messages in thread
From: Björn Steinbrink @ 2008-07-01 18:01 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Junio C Hamano, git

On 2008.07.01 12:07:25 +0200, Ingo Molnar wrote:
> There's a small detail i was thinking about: is there a way to get this 
> extra output without actually switching branches? Right now i do this:
> 
>  earth4:~/tip> git-checkout tip; git-checkout master
>  Checking out files: 100% (2437/2437), done.
>  Switched to branch "tip"
>  Switched to branch "master"
>  Your branch is ahead of the tracked remote branch 'origin/master' by
>  50 commits.
> 
> (Which is an admitted lame solution but the best i could figure.)

Just "git checkout" works for me:
git (master) $ git checkout
Your branch is behind the tracked remote branch 'origin/master' by 6 commits,
and can be fast-forwarded.

Björn

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 10:14   ` Ingo Molnar
  2008-07-01 11:41     ` SZEDER Gábor
@ 2008-07-01 19:16     ` Junio C Hamano
  2008-07-02  7:50       ` [PATCH 0/3] Making remote tracking statistics available to other tools Junio C Hamano
                         ` (3 more replies)
  1 sibling, 4 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-01 19:16 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

Ingo Molnar <mingo@elte.hu> writes:

> * Bruce Stephens <bruce.stephens@isode.com> wrote:
> ...
>> It feels logical for "git status" to offer the same information (when 
>> the information is appropriate).
>> 
>> [...]
>
> i have a tip-curr (shortcut: 'tc') scriptlet to answer the "where I am 
> amongst 100+ branches" question:

Perhaps like this, but be warned this is untested except for compilation
testing.

 builtin-checkout.c |   39 +++++++++++++++++++++------------------
 wt-status.c        |   22 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 18 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 93ea69b..2cbc39c 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -305,7 +305,7 @@ static int merge_working_tree(struct checkout_opts *opts,
 	return 0;
 }
 
-static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
+void report_tracking(FILE *fp, const char *name, struct commit *commit)
 {
 	/*
 	 * We have switched to a new branch; is it building on
@@ -321,7 +321,7 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
 	int rev_argc;
 	int num_ours, num_theirs;
 	const char *remote_msg;
-	struct branch *branch = branch_get(new->name);
+	struct branch *branch = branch_get(name);
 
 	/*
 	 * Nothing to report unless we are marked to build on top of
@@ -339,7 +339,7 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
 		return;
 
 	theirs = lookup_commit(sha1);
-	ours = new->commit;
+	ours = commit;
 	if (!hashcmp(sha1, ours->object.sha1))
 		return; /* we are the same */
 
@@ -380,22 +380,25 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
 	}
 
 	if (!num_theirs)
-		printf("Your branch is ahead of the tracked%s branch '%s' "
-		       "by %d commit%s.\n",
-		       remote_msg, base,
-		       num_ours, (num_ours == 1) ? "" : "s");
+		fprintf(fp,
+			"Your branch is ahead of the tracked%s branch '%s' "
+			"by %d commit%s.\n",
+			remote_msg, base,
+			num_ours, (num_ours == 1) ? "" : "s");
 	else if (!num_ours)
-		printf("Your branch is behind the tracked%s branch '%s' "
-		       "by %d commit%s,\n"
-		       "and can be fast-forwarded.\n",
-		       remote_msg, base,
-		       num_theirs, (num_theirs == 1) ? "" : "s");
+		fprintf(fp,
+			"Your branch is behind the tracked%s branch '%s' "
+			"by %d commit%s,\n"
+			"and can be fast-forwarded.\n",
+			remote_msg, base,
+			num_theirs, (num_theirs == 1) ? "" : "s");
 	else
-		printf("Your branch and the tracked%s branch '%s' "
-		       "have diverged,\nand respectively "
-		       "have %d and %d different commit(s) each.\n",
-		       remote_msg, base,
-		       num_ours, num_theirs);
+		fprintf(fp,
+			"Your branch and the tracked%s branch '%s' "
+			"have diverged,\nand respectively "
+			"have %d and %d different commit(s) each.\n",
+			remote_msg, base,
+			num_ours, num_theirs);
 }
 
 static void update_refs_for_switch(struct checkout_opts *opts,
@@ -441,7 +444,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 	remove_branch_state();
 	strbuf_release(&msg);
 	if (!opts->quiet && (new->path || !strcmp(new->name, "HEAD")))
-		report_tracking(new, opts);
+		report_tracking(stdout, new->name, new->commit);
 }
 
 static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
diff --git a/wt-status.c b/wt-status.c
index 28c9e63..e02171a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -315,6 +315,26 @@ static void wt_status_print_verbose(struct wt_status *s)
 	run_diff_index(&rev, 1);
 }
 
+/* NEEDSWORK */
+extern void report_tracking(FILE *fp, const char *name, struct commit *commit);
+
+static void wt_status_print_tracking(struct wt_status *s)
+{
+	unsigned char sha1[20];
+	struct commit *commit;
+
+	assert(s->branch && !s->is_initial);
+
+	if (prefixcmp(s->branch, "refs/heads/") ||
+	    !resolve_ref(s->branch, sha1, 1, NULL))
+		return;
+	commit = lookup_commit(sha1);
+	if (!commit)
+		return;
+	fprintf(s->fp, "# ");
+	report_tracking(s->fp, s->branch + 11, commit);
+}
+
 void wt_status_print(struct wt_status *s)
 {
 	unsigned char sha1[20];
@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)
 		}
 		color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
 		color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+		if (!s->is_initial)
+			wt_status_print_tracking(s);
 	}
 
 	if (s->is_initial) {

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 11:41         ` Miklos Vajna
@ 2008-07-01 23:55           ` Junio C Hamano
  0 siblings, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-01 23:55 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Ingo Molnar, git

Miklos Vajna <vmiklos@frugalware.org> writes:

> On Tue, Jul 01, 2008 at 01:22:35PM +0200, Ingo Molnar <mingo@elte.hu> wrote:
>> [ Oh, and i could switch between git versions without having to rebuild
>>   ;-) ]
>
> I remember about a mail from Junio where he wrote he has a lot of
> versions installed under ~/git/git-version. So usually he has git from
> next as default and he can try ~/git/git-1.5.4/git if he want 1.5.4,
> etc.

Yup.

I have $HOME/git-active/bin on my $PATH and then these:

lrwxrwxrwx 1 junio junio   10 2008-05-25 18:13 /home/junio/git-active -> git-master
drwxr-sr-x 6 junio junio 4096 2007-04-04 02:49 /home/junio/git-maint
drwxr-sr-x 5 junio junio 4096 2007-12-14 22:46 /home/junio/git-master
drwxr-sr-x 6 junio junio 4096 2008-06-23 22:02 /home/junio/git-next
drwxr-sr-x 7 junio junio 4096 2007-12-02 02:52 /home/junio/git-pu
drwxr-sr-x 4 junio junio 4096 2006-10-14 22:43 /home/junio/git-snap-v1.0.0
drwxr-sr-x 4 junio junio 4096 2007-01-11 22:27 /home/junio/git-snap-v1.1.0
drwxr-sr-x 4 junio junio 4096 2007-01-11 22:26 /home/junio/git-snap-v1.2.0
drwxr-sr-x 4 junio junio 4096 2007-01-11 22:24 /home/junio/git-snap-v1.3.0
...
drwxr-sr-x 5 junio junio 4096 2008-06-07 12:11 /home/junio/git-snap-v1.5.5.4
drwxr-sr-x 5 junio junio 4096 2008-06-26 17:33 /home/junio/git-snap-v1.5.5.5
drwxr-sr-x 5 junio junio 4096 2008-06-25 14:41 /home/junio/git-test

my "Make" and "Doit" scripts that arrange the $(prefix) for these builds
are found in my 'todo' branch.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 0/3] Making remote tracking statistics available to other tools
  2008-07-01 19:16     ` Junio C Hamano
@ 2008-07-02  7:50       ` Junio C Hamano
  2008-07-03 16:26         ` Olivier Marin
  2008-07-02  7:51       ` [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout" Junio C Hamano
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 28+ messages in thread
From: Junio C Hamano @ 2008-07-02  7:50 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

The one I sent out was a bit hacky as the existing implementation inside
git-checkout was not designed to be cleanly reusable.

Here is a cleaned up series that could be applied.

[PATCH 1/3] Refactor "tracking statistics" code used by "git checkout"
[PATCH 2/3] git-status: show the remote tracking statistics
[PATCH 3/3] git-branch -v: show the remote tracking statistics

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout"
  2008-07-01 19:16     ` Junio C Hamano
  2008-07-02  7:50       ` [PATCH 0/3] Making remote tracking statistics available to other tools Junio C Hamano
@ 2008-07-02  7:51       ` Junio C Hamano
  2008-07-02  7:52       ` [PATCH 2/3] git-status: show the remote tracking statistics Junio C Hamano
  2008-07-02  7:52       ` [PATCH 3/3] git-branch -v: " Junio C Hamano
  3 siblings, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-02  7:51 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

People seem to like "Your branch is ahead by N commit" report made by
"git checkout", but the interface into the statistics function was a bit
clunky.  This splits the function into three parts:

 * The core "commit counting" function that takes "struct branch" and
   returns number of commits to show if we are ahead, behind or forked;

 * Convenience "stat formating" function that takes "struct branch" and
   formats the report into a given strbuf, using the above function;

 * "checkout" specific function that takes "branch_info" (type that is
   internal to checkout implementation), calls the above function and
   print the formatted result.

in the hope that the former two can be more easily reusable.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-checkout.c |   94 +++----------------------------------------
 remote.c           |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 remote.h           |    4 ++
 3 files changed, 123 insertions(+), 88 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 93ea69b..d6641c2 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -305,97 +305,15 @@ static int merge_working_tree(struct checkout_opts *opts,
 	return 0;
 }
 
-static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
+static void report_tracking(struct branch_info *new)
 {
-	/*
-	 * We have switched to a new branch; is it building on
-	 * top of another branch, and if so does that other branch
-	 * have changes we do not have yet?
-	 */
-	char *base;
-	unsigned char sha1[20];
-	struct commit *ours, *theirs;
-	char symmetric[84];
-	struct rev_info revs;
-	const char *rev_argv[10];
-	int rev_argc;
-	int num_ours, num_theirs;
-	const char *remote_msg;
+	struct strbuf sb = STRBUF_INIT;
 	struct branch *branch = branch_get(new->name);
 
-	/*
-	 * Nothing to report unless we are marked to build on top of
-	 * somebody else.
-	 */
-	if (!branch || !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
-		return;
-
-	/*
-	 * If what we used to build on no longer exists, there is
-	 * nothing to report.
-	 */
-	base = branch->merge[0]->dst;
-	if (!resolve_ref(base, sha1, 1, NULL))
+	if (!format_tracking_info(branch, &sb))
 		return;
-
-	theirs = lookup_commit(sha1);
-	ours = new->commit;
-	if (!hashcmp(sha1, ours->object.sha1))
-		return; /* we are the same */
-
-	/* Run "rev-list --left-right ours...theirs" internally... */
-	rev_argc = 0;
-	rev_argv[rev_argc++] = NULL;
-	rev_argv[rev_argc++] = "--left-right";
-	rev_argv[rev_argc++] = symmetric;
-	rev_argv[rev_argc++] = "--";
-	rev_argv[rev_argc] = NULL;
-
-	strcpy(symmetric, sha1_to_hex(ours->object.sha1));
-	strcpy(symmetric + 40, "...");
-	strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));
-
-	init_revisions(&revs, NULL);
-	setup_revisions(rev_argc, rev_argv, &revs, NULL);
-	prepare_revision_walk(&revs);
-
-	/* ... and count the commits on each side. */
-	num_ours = 0;
-	num_theirs = 0;
-	while (1) {
-		struct commit *c = get_revision(&revs);
-		if (!c)
-			break;
-		if (c->object.flags & SYMMETRIC_LEFT)
-			num_ours++;
-		else
-			num_theirs++;
-	}
-
-	if (!prefixcmp(base, "refs/remotes/")) {
-		remote_msg = " remote";
-		base += strlen("refs/remotes/");
-	} else {
-		remote_msg = "";
-	}
-
-	if (!num_theirs)
-		printf("Your branch is ahead of the tracked%s branch '%s' "
-		       "by %d commit%s.\n",
-		       remote_msg, base,
-		       num_ours, (num_ours == 1) ? "" : "s");
-	else if (!num_ours)
-		printf("Your branch is behind the tracked%s branch '%s' "
-		       "by %d commit%s,\n"
-		       "and can be fast-forwarded.\n",
-		       remote_msg, base,
-		       num_theirs, (num_theirs == 1) ? "" : "s");
-	else
-		printf("Your branch and the tracked%s branch '%s' "
-		       "have diverged,\nand respectively "
-		       "have %d and %d different commit(s) each.\n",
-		       remote_msg, base,
-		       num_ours, num_theirs);
+	fputs(sb.buf, stdout);
+	strbuf_release(&sb);
 }
 
 static void update_refs_for_switch(struct checkout_opts *opts,
@@ -441,7 +359,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
 	remove_branch_state();
 	strbuf_release(&msg);
 	if (!opts->quiet && (new->path || !strcmp(new->name, "HEAD")))
-		report_tracking(new, opts);
+		report_tracking(new);
 }
 
 static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
diff --git a/remote.c b/remote.c
index ff2c802..bd5c3be 100644
--- a/remote.c
+++ b/remote.c
@@ -1,6 +1,9 @@
 #include "cache.h"
 #include "remote.h"
 #include "refs.h"
+#include "commit.h"
+#include "diff.h"
+#include "revision.h"
 
 static struct refspec s_tag_refspec = {
 	0,
@@ -1222,3 +1225,113 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)
 		}
 	return 1;
 }
+
+/*
+ * Return true if there is anything to report, otherwise false.
+ */
+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
+{
+	unsigned char sha1[20];
+	struct commit *ours, *theirs;
+	char symmetric[84];
+	struct rev_info revs;
+	const char *rev_argv[10], *base;
+	int rev_argc;
+
+	/*
+	 * Nothing to report unless we are marked to build on top of
+	 * somebody else.
+	 */
+	if (!branch ||
+	    !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
+		return 0;
+
+	/*
+	 * If what we used to build on no longer exists, there is
+	 * nothing to report.
+	 */
+	base = branch->merge[0]->dst;
+	if (!resolve_ref(base, sha1, 1, NULL))
+		return 0;
+	theirs = lookup_commit(sha1);
+	if (!theirs)
+		return 0;
+
+	if (!resolve_ref(branch->refname, sha1, 1, NULL))
+		return 0;
+	ours = lookup_commit(sha1);
+	if (!ours)
+		return 0;
+
+	/* are we the same? */
+	if (theirs == ours)
+		return 0;
+
+	/* Run "rev-list --left-right ours...theirs" internally... */
+	rev_argc = 0;
+	rev_argv[rev_argc++] = NULL;
+	rev_argv[rev_argc++] = "--left-right";
+	rev_argv[rev_argc++] = symmetric;
+	rev_argv[rev_argc++] = "--";
+	rev_argv[rev_argc] = NULL;
+
+	strcpy(symmetric, sha1_to_hex(ours->object.sha1));
+	strcpy(symmetric + 40, "...");
+	strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));
+
+	init_revisions(&revs, NULL);
+	setup_revisions(rev_argc, rev_argv, &revs, NULL);
+	prepare_revision_walk(&revs);
+
+	/* ... and count the commits on each side. */
+	*num_ours = 0;
+	*num_theirs = 0;
+	while (1) {
+		struct commit *c = get_revision(&revs);
+		if (!c)
+			break;
+		if (c->object.flags & SYMMETRIC_LEFT)
+			(*num_ours)++;
+		else
+			(*num_theirs)++;
+	}
+	return 1;
+}
+
+/*
+ * Return true when there is anything to report, otherwise false.
+ */
+int format_tracking_info(struct branch *branch, struct strbuf *sb)
+{
+	int num_ours, num_theirs;
+	const char *base, *remote_msg;
+
+	if (!stat_tracking_info(branch, &num_ours, &num_theirs))
+		return 0;
+
+	base = branch->merge[0]->dst;
+	if (!prefixcmp(base, "refs/remotes/")) {
+		remote_msg = " remote";
+		base += strlen("refs/remotes/");
+	} else {
+		remote_msg = "";
+	}
+	if (!num_theirs)
+		strbuf_addf(sb, "Your branch is ahead of the tracked%s branch '%s' "
+			    "by %d commit%s.\n",
+			    remote_msg, base,
+			    num_ours, (num_ours == 1) ? "" : "s");
+	else if (!num_ours)
+		strbuf_addf(sb, "Your branch is behind the tracked%s branch '%s' "
+			    "by %d commit%s,\n"
+			    "and can be fast-forwarded.\n",
+			    remote_msg, base,
+			    num_theirs, (num_theirs == 1) ? "" : "s");
+	else
+		strbuf_addf(sb, "Your branch and the tracked%s branch '%s' "
+			    "have diverged,\nand respectively "
+			    "have %d and %d different commit(s) each.\n",
+			    remote_msg, base,
+			    num_ours, num_theirs);
+	return 1;
+}
diff --git a/remote.h b/remote.h
index 8eed87b..091b1d0 100644
--- a/remote.h
+++ b/remote.h
@@ -129,4 +129,8 @@ enum match_refs_flags {
 	MATCH_REFS_MIRROR	= (1 << 1),
 };
 
+/* Reporting of tracking info */
+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
+int format_tracking_info(struct branch *branch, struct strbuf *sb);
+
 #endif
-- 
1.5.6.1.156.ge903b

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 2/3] git-status: show the remote tracking statistics
  2008-07-01 19:16     ` Junio C Hamano
  2008-07-02  7:50       ` [PATCH 0/3] Making remote tracking statistics available to other tools Junio C Hamano
  2008-07-02  7:51       ` [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout" Junio C Hamano
@ 2008-07-02  7:52       ` Junio C Hamano
  2008-07-02  7:52       ` [PATCH 3/3] git-branch -v: " Junio C Hamano
  3 siblings, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-02  7:52 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

This teaches "git status" to show the same remote tracking statistics
"git checkout" gives at the beginning of the output.

Now the necessary low-level machinery is properly factored out, we can do
this quite cleanly.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 wt-status.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 28c9e63..eeb106e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -9,6 +9,7 @@
 #include "diffcore.h"
 #include "quote.h"
 #include "run-command.h"
+#include "remote.h"
 
 int wt_status_relative_paths = 1;
 int wt_status_use_color = -1;
@@ -315,6 +316,25 @@ static void wt_status_print_verbose(struct wt_status *s)
 	run_diff_index(&rev, 1);
 }
 
+static void wt_status_print_tracking(struct wt_status *s)
+{
+	struct strbuf sb = STRBUF_INIT;
+	const char *cp, *ep;
+	struct branch *branch;
+
+	assert(s->branch && !s->is_initial);
+	if (prefixcmp(s->branch, "refs/heads/"))
+		return;
+	branch = branch_get(s->branch + 11);
+	if (!format_tracking_info(branch, &sb))
+		return;
+
+	for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
+		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
+				 "# %.*s", (int)(ep - cp), cp);
+	color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+}
+
 void wt_status_print(struct wt_status *s)
 {
 	unsigned char sha1[20];
@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)
 		}
 		color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
 		color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+		if (!s->is_initial)
+			wt_status_print_tracking(s);
 	}
 
 	if (s->is_initial) {
-- 
1.5.6.1.156.ge903b

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-01 19:16     ` Junio C Hamano
                         ` (2 preceding siblings ...)
  2008-07-02  7:52       ` [PATCH 2/3] git-status: show the remote tracking statistics Junio C Hamano
@ 2008-07-02  7:52       ` Junio C Hamano
  2008-07-02  8:23         ` Johannes Sixt
  2008-07-02 15:44         ` Johannes Schindelin
  3 siblings, 2 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-02  7:52 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Bruce Stephens, git

This teaches "git branch -v" to insert the remote tracking statistics in
the form of [ours/theirs] just before the one-liner commit log message
for the branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
  ... which means that you would see something like this.

  * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...

  I did not think we want to spend extra columns to show the name of
  remote branch each of them tracks, so I am showing only counts.

 builtin-branch.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index d279702..0e2bb52 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -310,6 +310,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 	if (verbose) {
 		struct strbuf subject;
 		const char *sub = " **** invalid ref ****";
+		char stat[128];
 
 		strbuf_init(&subject, 0);
 
@@ -319,10 +320,19 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 					    &subject, 0, NULL, NULL, 0, 0);
 			sub = subject.buf;
 		}
-		printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
+
+		stat[0] = '\0';
+		if (item->kind == REF_LOCAL_BRANCH) {
+			int ours, theirs;
+			struct branch *branch = branch_get(item->name);
+			if (stat_tracking_info(branch, &ours, &theirs))
+				sprintf(stat, "[%d/%d] ", ours, theirs);
+		}
+		printf("%c %s%-*s%s %s %s%s\n", c, branch_get_color(color),
 		       maxwidth, item->name,
 		       branch_get_color(COLOR_BRANCH_RESET),
-		       find_unique_abbrev(item->sha1, abbrev), sub);
+		       find_unique_abbrev(item->sha1, abbrev),
+		       stat, sub);
 		strbuf_release(&subject);
 	} else {
 		printf("%c %s%s%s\n", c, branch_get_color(color), item->name,
-- 
1.5.6.1.156.ge903b

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-02  7:52       ` [PATCH 3/3] git-branch -v: " Junio C Hamano
@ 2008-07-02  8:23         ` Johannes Sixt
  2008-07-02  8:33           ` Karl Hasselström
  2008-07-02  8:42           ` Junio C Hamano
  2008-07-02 15:44         ` Johannes Schindelin
  1 sibling, 2 replies; 28+ messages in thread
From: Johannes Sixt @ 2008-07-02  8:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ingo Molnar, Bruce Stephens, git

Junio C Hamano schrieb:
> This teaches "git branch -v" to insert the remote tracking statistics in
> the form of [ours/theirs] just before the one-liner commit log message
> for the branch.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   ... which means that you would see something like this.
> 
>   * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...
> 
>   I did not think we want to spend extra columns to show the name of
>   remote branch each of them tracks, so I am showing only counts.

What makes the "tracking statistics" so useful, is that it explains the
situation in clear words. But here you throw in a few numbers without
explanation. It's practically undiscoverable what the numbers mean.
Therefore, I personally would prefer not to have them here and to save the
space for the commit summary.

What do you think about showing the tracking information only if --track
is supplied? But then even write more information:

* jc/report-tracking   41666f7 diverged 3 vs. 117
  foo                  1234567 behind 22
  bar                  fedcba9 ahead 6

and filter the output to show only tracking branches.

-- Hannes

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-02  8:23         ` Johannes Sixt
@ 2008-07-02  8:33           ` Karl Hasselström
  2008-07-02 14:44             ` Brian Gernhardt
  2008-07-02  8:42           ` Junio C Hamano
  1 sibling, 1 reply; 28+ messages in thread
From: Karl Hasselström @ 2008-07-02  8:33 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, Ingo Molnar, Bruce Stephens, git

On 2008-07-02 10:23:33 +0200, Johannes Sixt wrote:

> * jc/report-tracking   41666f7 diverged 3 vs. 117

Or even "ahead 3, behind 117" here. Otherwise the user has to remember
which number is which, which kind of defeats your point. And it's just
one more character.

>   foo                  1234567 behind 22
>   bar                  fedcba9 ahead 6

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-02  8:23         ` Johannes Sixt
  2008-07-02  8:33           ` Karl Hasselström
@ 2008-07-02  8:42           ` Junio C Hamano
  1 sibling, 0 replies; 28+ messages in thread
From: Junio C Hamano @ 2008-07-02  8:42 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Ingo Molnar, Bruce Stephens, git

Johannes Sixt <j.sixt@viscovery.net> writes:

> What do you think about showing the tracking information only if --track
> is supplied? But then even write more information:
>
> * jc/report-tracking   41666f7 diverged 3 vs. 117
>   foo                  1234567 behind 22
>   bar                  fedcba9 ahead 6
>
> and filter the output to show only tracking branches.

I am not sure about the use of --track option, but now the infrastructure
is clean enough for anybody to paint it in his favorite color, and I do
not care deeply about how it would look like.  Discuss away and give me an
applicable patch that the list has concensus on, and I'll apply it.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-02  8:33           ` Karl Hasselström
@ 2008-07-02 14:44             ` Brian Gernhardt
  0 siblings, 0 replies; 28+ messages in thread
From: Brian Gernhardt @ 2008-07-02 14:44 UTC (permalink / raw)
  To: Karl Hasselström
  Cc: Johannes Sixt, Junio C Hamano, Ingo Molnar, Bruce Stephens, git


On Jul 2, 2008, at 4:33 AM, Karl Hasselström wrote:

> On 2008-07-02 10:23:33 +0200, Johannes Sixt wrote:
>
>> * jc/report-tracking   41666f7 diverged 3 vs. 117
>
> Or even "ahead 3, behind 117" here. Otherwise the user has to remember
> which number is which, which kind of defeats your point. And it's just
> one more character.
>
>>  foo                  1234567 behind 22
>>  bar                  fedcba9 ahead 6

This is probably the most useful for a new user.  The short version of  
that (config option to give it for power users and hide it from those  
it would confuse) should use plus and minus for ahead and behind:

  * jc/report-tracking        41666f7 [+3 -117] git-branch -v: show  
the remo...

I can't follow the code with the ten seconds I have to look at it.  Is  
this ahead/behind current branch, tracking branch, or other?

~~ Brian

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics
  2008-07-02  7:52       ` [PATCH 3/3] git-branch -v: " Junio C Hamano
  2008-07-02  8:23         ` Johannes Sixt
@ 2008-07-02 15:44         ` Johannes Schindelin
  1 sibling, 0 replies; 28+ messages in thread
From: Johannes Schindelin @ 2008-07-02 15:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ingo Molnar, Bruce Stephens, git

Hi,

On Wed, 2 Jul 2008, Junio C Hamano wrote:

> This teaches "git branch -v" to insert the remote tracking statistics in
> the form of [ours/theirs] just before the one-liner commit log message
> for the branch.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>   ... which means that you would see something like this.
> 
>   * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...

Actually, I would like to have something like

$ git branch --explain-relationship master next

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/3] Making remote tracking statistics available to other tools
  2008-07-02  7:50       ` [PATCH 0/3] Making remote tracking statistics available to other tools Junio C Hamano
@ 2008-07-03 16:26         ` Olivier Marin
  2008-07-03 19:07           ` Junio C Hamano
  0 siblings, 1 reply; 28+ messages in thread
From: Olivier Marin @ 2008-07-03 16:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ingo Molnar, Bruce Stephens, git

Junio C Hamano a écrit :
> The one I sent out was a bit hacky as the existing implementation inside
> git-checkout was not designed to be cleanly reusable.
> 
> Here is a cleaned up series that could be applied.
> 
> [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout"
> [PATCH 2/3] git-status: show the remote tracking statistics
> [PATCH 3/3] git-branch -v: show the remote tracking statistics

Sorry, but the third patch does not work for me. FWIU, the problem comes from
the revision walking code that is not reentrant because of the object cache.
IOW, calling stats_tracking_info() more than once does not work: objects
states changed after first call.

I do not understand the code enough yet and I failed to fix it. The only way
I found is by clearing obj_hash (object.c) but this seems the wrong thing to
do.

Ideas?

This test case should trigger the bug:

$ for i in a b c; do echo $i>$i && git add $i && git commit -m $i; done
$ git clone . clone1
$ cd clone1
$ git checkout -b b1 origin/master
$ git reset --hard HEAD~
$ echo d>d && git add d && git commit -m d
$ git checkout -b b2 origin/master
$ git reset --hard HEAD~
$ git merge b1

$ git branch -v
  b1     c07015a [ahead 1, behind 1] d
* b2     c07015a d
  master 08ca18b c

b1 and b2 are both 1 commit ahead and 1 commit behind.

$ git branch -D b1
$ git branch -v
* b2     c07015a [ahead 1, behind 1] d
  master 08ca18b c

deleting b1 show us the side effect.

Olivier.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/3] Making remote tracking statistics available to other tools
  2008-07-03 16:26         ` Olivier Marin
@ 2008-07-03 19:07           ` Junio C Hamano
  2008-07-03 19:25             ` Olivier Marin
  0 siblings, 1 reply; 28+ messages in thread
From: Junio C Hamano @ 2008-07-03 19:07 UTC (permalink / raw)
  To: Olivier Marin; +Cc: Ingo Molnar, Bruce Stephens, git

Olivier Marin <dkr+ml.git@free.fr> writes:

> Junio C Hamano a écrit :
>> The one I sent out was a bit hacky as the existing implementation inside
>> git-checkout was not designed to be cleanly reusable.
>> 
>> Here is a cleaned up series that could be applied.
>> 
>> [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout"
>> [PATCH 2/3] git-status: show the remote tracking statistics
>> [PATCH 3/3] git-branch -v: show the remote tracking statistics
>
> Sorry, but the third patch does not work for me. FWIU, the problem comes from
> the revision walking code that is not reentrant because of the object cache.
> IOW, calling stats_tracking_info() more than once does not work: objects
> states changed after first call.
>
> I do not understand the code enough yet and I failed to fix it. The only way
> I found is by clearing obj_hash (object.c) but this seems the wrong thing to
> do.
>
> Ideas?

Thanks.

 remote.c                 |    4 +++
 revision.h               |    1 +
 t/t6040-tracking-info.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/remote.c b/remote.c
index bd5c3be..df8bd72 100644
--- a/remote.c
+++ b/remote.c
@@ -1295,6 +1295,10 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
 		else
 			(*num_theirs)++;
 	}
+
+	/* clear object flags smudged by the above traversal */
+	clear_commit_marks(ours, ALL_REV_FLAGS);
+	clear_commit_marks(theirs, ALL_REV_FLAGS);
 	return 1;
 }
 
diff --git a/revision.h b/revision.h
index abce500..e8bac6d 100644
--- a/revision.h
+++ b/revision.h
@@ -11,6 +11,7 @@
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
 #define TOPOSORT	(1u<<9)	/* In the active toposort list.. */
+#define ALL_REV_FLAGS	((1u<<10)-1)
 
 struct rev_info;
 struct log_info;
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
new file mode 100755
index 0000000..960db2d
--- /dev/null
+++ b/t/t6040-tracking-info.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='remote tracking stats'
+
+. ./test-lib.sh
+
+advance () {
+	echo "$1" >"$1" &&
+	git add "$1" &&
+	test_tick &&
+	git commit -m "$1"
+}
+
+test_expect_success setup '
+	for i in a b c;
+	do
+		advance $i || break
+	done &&
+	git clone . test &&
+	(
+		cd test &&
+		git checkout -b b1 origin &&
+		git reset --hard HEAD^ &&
+		advance d &&
+		git checkout -b b2 origin &&
+		git reset --hard b1 &&
+		git checkout -b b3 origin &&
+		git reset --hard HEAD^ &&
+		git checkout -b b4 origin &&
+		advance e &&
+		advance f
+	)
+'
+
+script='s/^..\(b.\)[	 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
+cat >expect <<\EOF
+b1 ahead 1, behind 1
+b2 ahead 1, behind 1
+b3 behind 1
+b4 ahead 2
+EOF
+
+test_expect_success 'branch -v' '
+	(
+		cd test &&
+		git branch -v
+	) |
+	sed -n -e "$script" >actual &&
+	test_cmp expect actual
+'
+
+test_done

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/3] Making remote tracking statistics available to other tools
  2008-07-03 19:07           ` Junio C Hamano
@ 2008-07-03 19:25             ` Olivier Marin
  0 siblings, 0 replies; 28+ messages in thread
From: Olivier Marin @ 2008-07-03 19:25 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ingo Molnar, Bruce Stephens, git

Junio C Hamano a écrit :
> 
>  remote.c                 |    4 +++
>  revision.h               |    1 +
>  t/t6040-tracking-info.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 57 insertions(+), 0 deletions(-)

Tested: it works. Thanks.

Olivier.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.
  2008-07-01 11:22       ` Ingo Molnar
  2008-07-01 11:41         ` Miklos Vajna
@ 2008-07-04  8:35         ` Pedro Melo
  1 sibling, 0 replies; 28+ messages in thread
From: Pedro Melo @ 2008-07-04  8:35 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Git Mailing List

Hi,

On Jul 1, 2008, at 12:22 PM, Ingo Molnar wrote:
> [ Oh, and i could switch between git versions without having to  
> rebuild
>   ;-) ]

hmms... Can you just use

version=`git-describe`
./configure --prefix=/usr/local/git-$version
make && sudo make install
sudo sh -c 'rm -f /usr/local/git && ln -s /usr/local/git-$version / 
usr/local/git'

and stick /usr/local/git/bin in your path?

Changing git versions is just a ln -s away.

Best regards,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo@simplicidade.org
Use XMPP!

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2008-07-04  8:36 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-01  9:13 [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Ingo Molnar
2008-07-01  9:26 ` Bruce Stephens
2008-07-01 10:14   ` Ingo Molnar
2008-07-01 11:41     ` SZEDER Gábor
2008-07-01 12:47       ` Jakub Narebski
2008-07-01 19:16     ` Junio C Hamano
2008-07-02  7:50       ` [PATCH 0/3] Making remote tracking statistics available to other tools Junio C Hamano
2008-07-03 16:26         ` Olivier Marin
2008-07-03 19:07           ` Junio C Hamano
2008-07-03 19:25             ` Olivier Marin
2008-07-02  7:51       ` [PATCH 1/3] Refactor "tracking statistics" code used by "git checkout" Junio C Hamano
2008-07-02  7:52       ` [PATCH 2/3] git-status: show the remote tracking statistics Junio C Hamano
2008-07-02  7:52       ` [PATCH 3/3] git-branch -v: " Junio C Hamano
2008-07-02  8:23         ` Johannes Sixt
2008-07-02  8:33           ` Karl Hasselström
2008-07-02 14:44             ` Brian Gernhardt
2008-07-02  8:42           ` Junio C Hamano
2008-07-02 15:44         ` Johannes Schindelin
2008-07-01 12:44   ` [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits Jakub Narebski
2008-07-01  9:32 ` Junio C Hamano
2008-07-01 10:07   ` Ingo Molnar
2008-07-01 11:16     ` Miklos Vajna
2008-07-01 11:22       ` Ingo Molnar
2008-07-01 11:41         ` Miklos Vajna
2008-07-01 23:55           ` Junio C Hamano
2008-07-04  8:35         ` Pedro Melo
2008-07-01 12:46     ` Mikael Magnusson
2008-07-01 18:01     ` Björn Steinbrink

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).