{"thread":{"id":"14241","subject":"[OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","startedAt":"2008-07-01T09:13:47Z","lastAt":"2008-07-04T08:35:31Z","messageCount":28,"participants":["Ingo Molnar","Junio C Hamano","Bruce Stephens","Miklos Vajna","SZEDER Gábor","Jakub Narebski","Mikael Magnusson","Björn Steinbrink","Johannes Sixt","Karl Hasselström","Brian Gernhardt","Johannes Schindelin","Olivier Marin","Pedro Melo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"81850","messageId":"20080701091347.GA11817@elte.hu","threadId":"14241","inReplyTo":null,"subject":"[OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2008-07-01T09:13:47Z","receivedAt":"2008-07-01T09:13:47Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\ni recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n\n  Switched to branch \"master\"\n  Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n\nit's a very useful detail! It's especially useful when two branches \ndiverge in a non-trivial way.\n\nI used to have ad-hoc scripts to discover this in the past:\n\n earth4:~/tip> tip-compare-remote\n master                        : differs from remote (-50 commits)\n tip                           : differs from remote (-1 commits)\n x86/ptrace                    : differs from remote (-1 commits)\n x86/unify-setup               : differs from remote (-2 commits)\n x86/xen-64bit                 : differs from remote (-1 commits)\n\nbut having a reminder at checkout time is even better (and faster as \nwell). Kudos.\n\n\tIngo\n"},{"id":"81854","messageId":"80iqvq2bw0.fsf@tiny.isode.net","threadId":"14241","inReplyTo":"20080701091347.GA11817@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Bruce Stephens","fromEmail":"bruce.stephens@isode.com","sentAt":"2008-07-01T09:26:39Z","receivedAt":"2008-07-01T09:26:39Z","isPatch":false,"sender":{"key":"bruce.stephens@isode.com","avatar":null},"body":"Ingo Molnar <mingo@elte.hu> writes:\n\n> i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n>\n>   Switched to branch \"master\"\n>   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n>\n> it's a very useful detail! It's especially useful when two branches \n> diverge in a non-trivial way.\n\nI agree, it's a really nice little feature.  Indeed, I occasionally do\n\"git checkout master\" just to get the message (to see where I am).\n\nIt feels logical for \"git status\" to offer the same information (when\nthe information is appropriate).\n\n[...]\n"},{"id":"81853","messageId":"7vlk0mne5d.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"20080701091347.GA11817@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-01T09:32:14Z","receivedAt":"2008-07-01T09:32:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ingo Molnar <mingo@elte.hu> writes:\n\n> i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n>\n>   Switched to branch \"master\"\n>   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n>\n> it's a very useful detail! It's especially useful when two branches \n> diverge in a non-trivial way.\n> ...\n> but having a reminder at checkout time is even better (and faster as \n> well). Kudos.\n\nThanks for a rare positive usability feedback.  When I started reading\nyour message, I almost expected that I'd hear you say \"I am getting this\nuseless cruft and it wastes extra cycles.\"\n\nSomebody must have had a very bright idea that day in late February this\nyear.\n"},{"id":"81858","messageId":"20080701100725.GE31309@elte.hu","threadId":"14241","inReplyTo":"7vlk0mne5d.fsf@gitster.siamese.dyndns.org","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2008-07-01T10:07:25Z","receivedAt":"2008-07-01T10:07:25Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"* Junio C Hamano <gitster@pobox.com> wrote:\n\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n> >\n> >   Switched to branch \"master\"\n> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n> >\n> > it's a very useful detail! It's especially useful when two branches \n> > diverge in a non-trivial way.\n> > ...\n> > but having a reminder at checkout time is even better (and faster as \n> > well). Kudos.\n> \n> Thanks for a rare positive usability feedback.  When I started reading \n> your message, I almost expected that I'd hear you say \"I am getting \n> this useless cruft and it wastes extra cycles.\"\n\nGit usability is certainly very good. (And what matters even more to me \nthan absolute usability, Git's usability is improving in a monotonic \nway.)\n\n[ You normally only hear from me if i find one of those rare outliers\n  that confuse me somewhere. So by reading my feedback you must be\n  getting an impression of problems only - that is far from the truth :) ]\n\n> Somebody must have had a very bright idea that day in late February \n> this year.\n\n:)\n\nThere's a small detail i was thinking about: is there a way to get this \nextra output without actually switching branches? Right now i do this:\n\n earth4:~/tip> git-checkout tip; git-checkout master\n Checking out files: 100% (2437/2437), done.\n Switched to branch \"tip\"\n Switched to branch \"master\"\n Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n\n(Which is an admitted lame solution but the best i could figure.)\n\nAlso, and let me hijack this thread, i sometimes feel adventurous and \ntry out git/pu for kicks. I tried it two days ago and it was quite OK, \nwith some fallout:\n\n- the git-dash changes broke half of our scripts around git. (We've got\n  about 50 tip-* scripts around various git details, about 2200 lines). \n\nI did a mass changeover:\n\n   31 files changed, 150 insertions(+), 150 deletions(-)\n\n... and that broke things too - see the two fixes below. I can \nunderstand your desire for a git-dash-less world though, but it's \ncausing some pain :-) Also, i kept typoing \"git-\" commands all the time \nso i switched back to git/master. Maybe there should be a transition \nperiod where the dash scripts warn if used interactively? Dunno.\n\n[ and there's also a git-rerere Heisenbug i have been fighting with a \n  lot with git-1.5.5. It's quite hard to reproduce and unfortunately i \n  cannot create a reproducer: but it resulted in git-rerere confusing \n  conflict resolutions and putting arch/x86/kernel/process_64.c \n  postimage entry into the entry for arch/x86/kernel/process_32.c's \n  postimage file, corrupting the integration run on the _next_ run.\n\n  Was there a bug in this area fixed recently that would show up with \n  such symptoms? The weirdness first showed up when i did a git-rerere \n  after having done a git-add arch/x86/kernel/process_64.c, git-rerere \n  printed that it added a new resolution for \n  arch/x86/kernel/process_32.c. ]\n\nand i like this warning at the end of master/pu make install:\n\n!! You have installed git-* commands to new gitexecdir.\n!! Old version git-* commands still remain in bindir.\n!! Mixing two versions of Git will lead to problems.\n!! Please remove old version commands in bindir now.\n\nthat's an easily overlooked detail.\n\n\tIngo\n\n--------------->\ncommit e87616175691dd7154cad049aae2b1bc1385bb7a\nAuthor: Ingo Molnar <mingo@elte.hu>\nDate:   Mon Jun 30 09:29:36 2008 +0200\n\n    - fix more git-dash fallout\n    \n    Signed-off-by: Ingo Molnar <mingo@elte.hu>\n\ndiff --git a/.tip/bin/tip-backup b/.tip/bin/tip-backup\nindex edd7991..682d68d 100755\n--- a/.tip/bin/tip-backup\n+++ b/.tip/bin/tip-backup\n@@ -7,7 +7,7 @@ check_master\n echo \"backing up the full -tip repo ...\"\n mkdir -p ~/tip-backups || exit -1\n \n-FILE=~/tip-backups/tip-git $(get_date_for_tag).tar.bz2\n+FILE=~/tip-backups/tip-git-$(get_date_for_tag).tar.bz2\n \n tar cjf $FILE .git || exit -1\n \ncommit 1bcce26cf0ba00ea62c051772f66d3e1c616e165\nAuthor: H. Peter Anvin <hpa@zytor.com>\nDate:   Fri Jun 27 17:05:59 2008 -0700\n\n    tip-sync-remote: quote multiword commands in variables\n    \n    When assigning a multiword command to a variable, it needs to be\n    quoted.\n\ndiff --git a/.tip/bin/tip-sync-remote b/.tip/bin/tip-sync-remote\nindex 6421e55..aeeb883 100755\n--- a/.tip/bin/tip-sync-remote\n+++ b/.tip/bin/tip-sync-remote\n@@ -65,9 +65,9 @@ do\n     then\n \techo \"Branch \"$B\" has local modifications\"\n \techo \"Rebasing local modifications to remote\"\n-\tCMD=git rebase\n+\tCMD='git rebase'\n     else\n-\tCMD=git merge\n+\tCMD='git merge'\n     fi\n \n     $CMD origin/$B || {\n"},{"id":"81860","messageId":"20080701101414.GG31309@elte.hu","threadId":"14241","inReplyTo":"80iqvq2bw0.fsf@tiny.isode.net","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2008-07-01T10:14:15Z","receivedAt":"2008-07-01T10:14:15Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"* Bruce Stephens <bruce.stephens@isode.com> wrote:\n\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n> >\n> >   Switched to branch \"master\"\n> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n> >\n> > it's a very useful detail! It's especially useful when two branches \n> > diverge in a non-trivial way.\n> \n> I agree, it's a really nice little feature.  Indeed, I occasionally do \n> \"git checkout master\" just to get the message (to see where I am).\n> \n> It feels logical for \"git status\" to offer the same information (when \n> the information is appropriate).\n> \n> [...]\n\ni have a tip-curr (shortcut: 'tc') scriptlet to answer the \"where I am \namongst 100+ branches\" question:\n\n  earth4:~/tip> tc\n  tip/master 200a86b: Merge branch 'x86/unify-setup'\n\nwhich is just a thin wrapper around git-log:\n\n  earth4:~/tip> cat ~/bin/tip/tip-curr\n  #!/bin/bash\n\n  . ~/bin/tip/tip-lib\n\n  echo \"tip/\"$(get_current_branch)\" \"$(git log -1 --pretty=format:\"%h: %s\")\n\n\tIngo\n"},{"id":"81861","messageId":"20080701111601.GT4729@genesis.frugalware.org","threadId":"14241","inReplyTo":"20080701100725.GE31309@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-07-01T11:16:01Z","receivedAt":"2008-07-01T11:16:01Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Jul 01, 2008 at 12:07:25PM +0200, Ingo Molnar <mingo@elte.hu> wrote:\n> !! You have installed git-* commands to new gitexecdir.\n> !! Old version git-* commands still remain in bindir.\n> !! Mixing two versions of Git will lead to problems.\n> !! Please remove old version commands in bindir now.\n> \n> that's an easily overlooked detail.\n\nThere is a 10-lines-length note about this in RelNotes, but I think\nremoving the old version is a task of the package manager. At least till\nthe git Makefile does not have an 'uninstall' target.\n"},{"id":"81862","messageId":"20080701112235.GC11809@elte.hu","threadId":"14241","inReplyTo":"20080701111601.GT4729@genesis.frugalware.org","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Ingo Molnar","fromEmail":"mingo@elte.hu","sentAt":"2008-07-01T11:22:35Z","receivedAt":"2008-07-01T11:22:35Z","isPatch":false,"sender":{"key":"mingo@elte.hu","avatar":null},"body":"\n* Miklos Vajna <vmiklos@frugalware.org> wrote:\n\n> On Tue, Jul 01, 2008 at 12:07:25PM +0200, Ingo Molnar <mingo@elte.hu> wrote:\n> > !! You have installed git-* commands to new gitexecdir.\n> > !! Old version git-* commands still remain in bindir.\n> > !! Mixing two versions of Git will lead to problems.\n> > !! Please remove old version commands in bindir now.\n> > \n> > that's an easily overlooked detail.\n> \n> There is a 10-lines-length note about this in RelNotes, but I think \n> removing the old version is a task of the package manager. At least \n> till the git Makefile does not have an 'uninstall' target.\n\nrandom (likely stupid) idea: perhaps git could use ... a separate Git \nrepo to track gitexecdir installations in $HOME/bin/? That could be \ntagged appropriately so you'd always know what to uninstall and whether \nthere are clashes or incompatibilities.\n\n[ Oh, and i could switch between git versions without having to rebuild\n  ;-) ]\n\n\tIngo\n"},{"id":"81864","messageId":"20080701114118.GU4729@genesis.frugalware.org","threadId":"14241","inReplyTo":"20080701112235.GC11809@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-07-01T11:41:18Z","receivedAt":"2008-07-01T11:41:18Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Jul 01, 2008 at 01:22:35PM +0200, Ingo Molnar <mingo@elte.hu> wrote:\n> [ Oh, and i could switch between git versions without having to rebuild\n>   ;-) ]\n\nI remember about a mail from Junio where he wrote he has a lot of\nversions installed under ~/git/git-version. So usually he has git from\nnext as default and he can try ~/git/git-1.5.4/git if he want 1.5.4,\netc.\n"},{"id":"81865","messageId":"20080701114149.GB6662@neumann","threadId":"14241","inReplyTo":"20080701101414.GG31309@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-07-01T11:41:49Z","receivedAt":"2008-07-01T11:41:49Z","isPatch":false,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi Ingo,\n\nOn Tue, Jul 01, 2008 at 12:14:15PM +0200, Ingo Molnar wrote:\n> i have a tip-curr (shortcut: 'tc') scriptlet to answer the \"where I am \n> amongst 100+ branches\" question:\n> \n>   earth4:~/tip> tc\n>   tip/master 200a86b: Merge branch 'x86/unify-setup'\n> \n> which is just a thin wrapper around git-log:\n> \n>   earth4:~/tip> cat ~/bin/tip/tip-curr\n>   #!/bin/bash\n> \n>   . ~/bin/tip/tip-lib\n> \n>   echo \"tip/\"$(get_current_branch)\" \"$(git log -1 --pretty=format:\"%h: %s\")\nhow about displaying the current branch in the command prompt?\n\n>From contrib/completion/git-completion.bash:\n\n  #    4) Consider changing your PS1 to also show the current branch:\n  #        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n  #\n  #       The argument to __git_ps1 will be displayed only if you\n  #       are currently in a git repository.  The %s token will be\n  #       the name of the current branch.\n\nRegards,\nGábor\n"},{"id":"81868","messageId":"m3ej6dhito.fsf@localhost.localdomain","threadId":"14241","inReplyTo":"80iqvq2bw0.fsf@tiny.isode.net","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-07-01T12:44:05Z","receivedAt":"2008-07-01T12:44:05Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Bruce Stephens <bruce.stephens@isode.com> writes:\n\n> Ingo Molnar <mingo@elte.hu> writes:\n> \n> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n> >\n> >   Switched to branch \"master\"\n> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n> >\n> > it's a very useful detail! It's especially useful when two branches \n> > diverge in a non-trivial way.\n> \n> I agree, it's a really nice little feature.  Indeed, I occasionally do\n> \"git checkout master\" just to get the message (to see where I am).\n> \n> It feels logical for \"git status\" to offer the same information (when\n> the information is appropriate).\n\nI agree that having this information in git-status would be useful,\nespecially that it would make having this reminder in buffer/editor\nwhen editing commit message.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"81869","messageId":"237967ef0807010546m3eb6f824vd5514c5824c00ddd@mail.gmail.com","threadId":"14241","inReplyTo":"20080701100725.GE31309@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2008-07-01T12:46:56Z","receivedAt":"2008-07-01T12:46:56Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2008/7/1 Ingo Molnar <mingo@elte.hu>:\n> * Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Ingo Molnar <mingo@elte.hu> writes:\n>>\n>> > i recently switched to 1.5.6.1.89.gd5446 and i'm getting this:\n>> >\n>> >   Switched to branch \"master\"\n>> >   Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n>> >\n>> > it's a very useful detail! It's especially useful when two branches\n>> > diverge in a non-trivial way.\n>> > ...\n>> > but having a reminder at checkout time is even better (and faster as\n>> > well). Kudos.\n[snippy]\n> There's a small detail i was thinking about: is there a way to get this\n> extra output without actually switching branches? Right now i do this:\n>\n>  earth4:~/tip> git-checkout tip; git-checkout master\n>  Checking out files: 100% (2437/2437), done.\n>  Switched to branch \"tip\"\n>  Switched to branch \"master\"\n>  Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.\n>\n> (Which is an admitted lame solution but the best i could figure.)\n\n{14:44:16|~code/git}% git checkout master\nChecking out files: 100% (180/180), done.\nSwitched to branch \"master\"\n{14:44:24|~code/git}% git shard HEAD\\~5\nHEAD is now at 8e69d78 Merge branch 'maint'\n{14:44:28|~code/git}% git checkout HEAD\nYour branch is behind the tracked remote branch 'origin/master' by 6 commits,\nand can be fast-forwarded.\n\n-- \nMikael Magnusson\n"},{"id":"81870","messageId":"m38wwlhinq.fsf@localhost.localdomain","threadId":"14241","inReplyTo":"20080701114149.GB6662@neumann","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-07-01T12:47:36Z","receivedAt":"2008-07-01T12:47:36Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n> how about displaying the current branch in the command prompt?\n> \n> >From contrib/completion/git-completion.bash:\n> \n>   #    4) Consider changing your PS1 to also show the current branch:\n>   #        PS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ '\n>   #\n>   #       The argument to __git_ps1 will be displayed only if you\n>   #       are currently in a git repository.  The %s token will be\n>   #       the name of the current branch.\n\nBecause I alos use StGit, I have added to my prompt visual\ndifferentiation if the branch is under StGit control.\n\nBut I have my own git prompt function, based on git-completion.bash\nbut different.  It shows current branch (or \"HEAD\" if on detached\nHEAD), current repository, and current working directory.  It laso has\nnumber of command in history, the same as in my ordinary prompt.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"81897","messageId":"20080701180109.GA14026@atjola.homenet","threadId":"14241","inReplyTo":"20080701100725.GE31309@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-07-01T18:01:09Z","receivedAt":"2008-07-01T18:01:09Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.07.01 12:07:25 +0200, Ingo Molnar wrote:\n> There's a small detail i was thinking about: is there a way to get this \n> extra output without actually switching branches? Right now i do this:\n> \n>  earth4:~/tip> git-checkout tip; git-checkout master\n>  Checking out files: 100% (2437/2437), done.\n>  Switched to branch \"tip\"\n>  Switched to branch \"master\"\n>  Your branch is ahead of the tracked remote branch 'origin/master' by\n>  50 commits.\n> \n> (Which is an admitted lame solution but the best i could figure.)\n\nJust \"git checkout\" works for me:\ngit (master) $ git checkout\nYour branch is behind the tracked remote branch 'origin/master' by 6 commits,\nand can be fast-forwarded.\n\nBjörn\n"},{"id":"81900","messageId":"7vlk0lmn32.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"20080701101414.GG31309@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-01T19:16:49Z","receivedAt":"2008-07-01T19:16:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ingo Molnar <mingo@elte.hu> writes:\n\n> * Bruce Stephens <bruce.stephens@isode.com> wrote:\n> ...\n>> It feels logical for \"git status\" to offer the same information (when \n>> the information is appropriate).\n>> \n>> [...]\n>\n> i have a tip-curr (shortcut: 'tc') scriptlet to answer the \"where I am \n> amongst 100+ branches\" question:\n\nPerhaps like this, but be warned this is untested except for compilation\ntesting.\n\n builtin-checkout.c |   39 +++++++++++++++++++++------------------\n wt-status.c        |   22 ++++++++++++++++++++++\n 2 files changed, 43 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 93ea69b..2cbc39c 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -305,7 +305,7 @@ static int merge_working_tree(struct checkout_opts *opts,\n \treturn 0;\n }\n \n-static void report_tracking(struct branch_info *new, struct checkout_opts *opts)\n+void report_tracking(FILE *fp, const char *name, struct commit *commit)\n {\n \t/*\n \t * We have switched to a new branch; is it building on\n@@ -321,7 +321,7 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)\n \tint rev_argc;\n \tint num_ours, num_theirs;\n \tconst char *remote_msg;\n-\tstruct branch *branch = branch_get(new->name);\n+\tstruct branch *branch = branch_get(name);\n \n \t/*\n \t * Nothing to report unless we are marked to build on top of\n@@ -339,7 +339,7 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)\n \t\treturn;\n \n \ttheirs = lookup_commit(sha1);\n-\tours = new->commit;\n+\tours = commit;\n \tif (!hashcmp(sha1, ours->object.sha1))\n \t\treturn; /* we are the same */\n \n@@ -380,22 +380,25 @@ static void report_tracking(struct branch_info *new, struct checkout_opts *opts)\n \t}\n \n \tif (!num_theirs)\n-\t\tprintf(\"Your branch is ahead of the tracked%s branch '%s' \"\n-\t\t       \"by %d commit%s.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_ours, (num_ours == 1) ? \"\" : \"s\");\n+\t\tfprintf(fp,\n+\t\t\t\"Your branch is ahead of the tracked%s branch '%s' \"\n+\t\t\t\"by %d commit%s.\\n\",\n+\t\t\tremote_msg, base,\n+\t\t\tnum_ours, (num_ours == 1) ? \"\" : \"s\");\n \telse if (!num_ours)\n-\t\tprintf(\"Your branch is behind the tracked%s branch '%s' \"\n-\t\t       \"by %d commit%s,\\n\"\n-\t\t       \"and can be fast-forwarded.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_theirs, (num_theirs == 1) ? \"\" : \"s\");\n+\t\tfprintf(fp,\n+\t\t\t\"Your branch is behind the tracked%s branch '%s' \"\n+\t\t\t\"by %d commit%s,\\n\"\n+\t\t\t\"and can be fast-forwarded.\\n\",\n+\t\t\tremote_msg, base,\n+\t\t\tnum_theirs, (num_theirs == 1) ? \"\" : \"s\");\n \telse\n-\t\tprintf(\"Your branch and the tracked%s branch '%s' \"\n-\t\t       \"have diverged,\\nand respectively \"\n-\t\t       \"have %d and %d different commit(s) each.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_ours, num_theirs);\n+\t\tfprintf(fp,\n+\t\t\t\"Your branch and the tracked%s branch '%s' \"\n+\t\t\t\"have diverged,\\nand respectively \"\n+\t\t\t\"have %d and %d different commit(s) each.\\n\",\n+\t\t\tremote_msg, base,\n+\t\t\tnum_ours, num_theirs);\n }\n \n static void update_refs_for_switch(struct checkout_opts *opts,\n@@ -441,7 +444,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,\n \tremove_branch_state();\n \tstrbuf_release(&msg);\n \tif (!opts->quiet && (new->path || !strcmp(new->name, \"HEAD\")))\n-\t\treport_tracking(new, opts);\n+\t\treport_tracking(stdout, new->name, new->commit);\n }\n \n static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\ndiff --git a/wt-status.c b/wt-status.c\nindex 28c9e63..e02171a 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -315,6 +315,26 @@ static void wt_status_print_verbose(struct wt_status *s)\n \trun_diff_index(&rev, 1);\n }\n \n+/* NEEDSWORK */\n+extern void report_tracking(FILE *fp, const char *name, struct commit *commit);\n+\n+static void wt_status_print_tracking(struct wt_status *s)\n+{\n+\tunsigned char sha1[20];\n+\tstruct commit *commit;\n+\n+\tassert(s->branch && !s->is_initial);\n+\n+\tif (prefixcmp(s->branch, \"refs/heads/\") ||\n+\t    !resolve_ref(s->branch, sha1, 1, NULL))\n+\t\treturn;\n+\tcommit = lookup_commit(sha1);\n+\tif (!commit)\n+\t\treturn;\n+\tfprintf(s->fp, \"# \");\n+\treport_tracking(s->fp, s->branch + 11, commit);\n+}\n+\n void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)\n \t\t}\n \t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n \t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n+\t\tif (!s->is_initial)\n+\t\t\twt_status_print_tracking(s);\n \t}\n \n \tif (s->is_initial) {\n"},{"id":"81905","messageId":"7vhcb9kvmx.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"20080701114118.GU4729@genesis.frugalware.org","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-01T23:55:02Z","receivedAt":"2008-07-01T23:55:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> On Tue, Jul 01, 2008 at 01:22:35PM +0200, Ingo Molnar <mingo@elte.hu> wrote:\n>> [ Oh, and i could switch between git versions without having to rebuild\n>>   ;-) ]\n>\n> I remember about a mail from Junio where he wrote he has a lot of\n> versions installed under ~/git/git-version. So usually he has git from\n> next as default and he can try ~/git/git-1.5.4/git if he want 1.5.4,\n> etc.\n\nYup.\n\nI have $HOME/git-active/bin on my $PATH and then these:\n\nlrwxrwxrwx 1 junio junio   10 2008-05-25 18:13 /home/junio/git-active -> git-master\ndrwxr-sr-x 6 junio junio 4096 2007-04-04 02:49 /home/junio/git-maint\ndrwxr-sr-x 5 junio junio 4096 2007-12-14 22:46 /home/junio/git-master\ndrwxr-sr-x 6 junio junio 4096 2008-06-23 22:02 /home/junio/git-next\ndrwxr-sr-x 7 junio junio 4096 2007-12-02 02:52 /home/junio/git-pu\ndrwxr-sr-x 4 junio junio 4096 2006-10-14 22:43 /home/junio/git-snap-v1.0.0\ndrwxr-sr-x 4 junio junio 4096 2007-01-11 22:27 /home/junio/git-snap-v1.1.0\ndrwxr-sr-x 4 junio junio 4096 2007-01-11 22:26 /home/junio/git-snap-v1.2.0\ndrwxr-sr-x 4 junio junio 4096 2007-01-11 22:24 /home/junio/git-snap-v1.3.0\n...\ndrwxr-sr-x 5 junio junio 4096 2008-06-07 12:11 /home/junio/git-snap-v1.5.5.4\ndrwxr-sr-x 5 junio junio 4096 2008-06-26 17:33 /home/junio/git-snap-v1.5.5.5\ndrwxr-sr-x 5 junio junio 4096 2008-06-25 14:41 /home/junio/git-test\n\nmy \"Make\" and \"Doit\" scripts that arrange the $(prefix) for these builds\nare found in my 'todo' branch.\n"},{"id":"81932","messageId":"7v3amsg1wx.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"7vlk0lmn32.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 0/3] Making remote tracking statistics available to other tools","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-02T07:50:38Z","receivedAt":"2008-07-02T07:50:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The one I sent out was a bit hacky as the existing implementation inside\ngit-checkout was not designed to be cleanly reusable.\n\nHere is a cleaned up series that could be applied.\n\n[PATCH 1/3] Refactor \"tracking statistics\" code used by \"git checkout\"\n[PATCH 2/3] git-status: show the remote tracking statistics\n[PATCH 3/3] git-branch -v: show the remote tracking statistics\n"},{"id":"81933","messageId":"7vvdzoenbd.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"7vlk0lmn32.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 1/3] Refactor \"tracking statistics\" code used by \"git checkout\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-02T07:51:18Z","receivedAt":"2008-07-02T07:51:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"People seem to like \"Your branch is ahead by N commit\" report made by\n\"git checkout\", but the interface into the statistics function was a bit\nclunky.  This splits the function into three parts:\n\n * The core \"commit counting\" function that takes \"struct branch\" and\n   returns number of commits to show if we are ahead, behind or forked;\n\n * Convenience \"stat formating\" function that takes \"struct branch\" and\n   formats the report into a given strbuf, using the above function;\n\n * \"checkout\" specific function that takes \"branch_info\" (type that is\n   internal to checkout implementation), calls the above function and\n   print the formatted result.\n\nin the hope that the former two can be more easily reusable.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-checkout.c |   94 +++----------------------------------------\n remote.c           |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n remote.h           |    4 ++\n 3 files changed, 123 insertions(+), 88 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 93ea69b..d6641c2 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -305,97 +305,15 @@ static int merge_working_tree(struct checkout_opts *opts,\n \treturn 0;\n }\n \n-static void report_tracking(struct branch_info *new, struct checkout_opts *opts)\n+static void report_tracking(struct branch_info *new)\n {\n-\t/*\n-\t * We have switched to a new branch; is it building on\n-\t * top of another branch, and if so does that other branch\n-\t * have changes we do not have yet?\n-\t */\n-\tchar *base;\n-\tunsigned char sha1[20];\n-\tstruct commit *ours, *theirs;\n-\tchar symmetric[84];\n-\tstruct rev_info revs;\n-\tconst char *rev_argv[10];\n-\tint rev_argc;\n-\tint num_ours, num_theirs;\n-\tconst char *remote_msg;\n+\tstruct strbuf sb = STRBUF_INIT;\n \tstruct branch *branch = branch_get(new->name);\n \n-\t/*\n-\t * Nothing to report unless we are marked to build on top of\n-\t * somebody else.\n-\t */\n-\tif (!branch || !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)\n-\t\treturn;\n-\n-\t/*\n-\t * If what we used to build on no longer exists, there is\n-\t * nothing to report.\n-\t */\n-\tbase = branch->merge[0]->dst;\n-\tif (!resolve_ref(base, sha1, 1, NULL))\n+\tif (!format_tracking_info(branch, &sb))\n \t\treturn;\n-\n-\ttheirs = lookup_commit(sha1);\n-\tours = new->commit;\n-\tif (!hashcmp(sha1, ours->object.sha1))\n-\t\treturn; /* we are the same */\n-\n-\t/* Run \"rev-list --left-right ours...theirs\" internally... */\n-\trev_argc = 0;\n-\trev_argv[rev_argc++] = NULL;\n-\trev_argv[rev_argc++] = \"--left-right\";\n-\trev_argv[rev_argc++] = symmetric;\n-\trev_argv[rev_argc++] = \"--\";\n-\trev_argv[rev_argc] = NULL;\n-\n-\tstrcpy(symmetric, sha1_to_hex(ours->object.sha1));\n-\tstrcpy(symmetric + 40, \"...\");\n-\tstrcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));\n-\n-\tinit_revisions(&revs, NULL);\n-\tsetup_revisions(rev_argc, rev_argv, &revs, NULL);\n-\tprepare_revision_walk(&revs);\n-\n-\t/* ... and count the commits on each side. */\n-\tnum_ours = 0;\n-\tnum_theirs = 0;\n-\twhile (1) {\n-\t\tstruct commit *c = get_revision(&revs);\n-\t\tif (!c)\n-\t\t\tbreak;\n-\t\tif (c->object.flags & SYMMETRIC_LEFT)\n-\t\t\tnum_ours++;\n-\t\telse\n-\t\t\tnum_theirs++;\n-\t}\n-\n-\tif (!prefixcmp(base, \"refs/remotes/\")) {\n-\t\tremote_msg = \" remote\";\n-\t\tbase += strlen(\"refs/remotes/\");\n-\t} else {\n-\t\tremote_msg = \"\";\n-\t}\n-\n-\tif (!num_theirs)\n-\t\tprintf(\"Your branch is ahead of the tracked%s branch '%s' \"\n-\t\t       \"by %d commit%s.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_ours, (num_ours == 1) ? \"\" : \"s\");\n-\telse if (!num_ours)\n-\t\tprintf(\"Your branch is behind the tracked%s branch '%s' \"\n-\t\t       \"by %d commit%s,\\n\"\n-\t\t       \"and can be fast-forwarded.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_theirs, (num_theirs == 1) ? \"\" : \"s\");\n-\telse\n-\t\tprintf(\"Your branch and the tracked%s branch '%s' \"\n-\t\t       \"have diverged,\\nand respectively \"\n-\t\t       \"have %d and %d different commit(s) each.\\n\",\n-\t\t       remote_msg, base,\n-\t\t       num_ours, num_theirs);\n+\tfputs(sb.buf, stdout);\n+\tstrbuf_release(&sb);\n }\n \n static void update_refs_for_switch(struct checkout_opts *opts,\n@@ -441,7 +359,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,\n \tremove_branch_state();\n \tstrbuf_release(&msg);\n \tif (!opts->quiet && (new->path || !strcmp(new->name, \"HEAD\")))\n-\t\treport_tracking(new, opts);\n+\t\treport_tracking(new);\n }\n \n static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\ndiff --git a/remote.c b/remote.c\nindex ff2c802..bd5c3be 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1,6 +1,9 @@\n #include \"cache.h\"\n #include \"remote.h\"\n #include \"refs.h\"\n+#include \"commit.h\"\n+#include \"diff.h\"\n+#include \"revision.h\"\n \n static struct refspec s_tag_refspec = {\n \t0,\n@@ -1222,3 +1225,113 @@ int resolve_remote_symref(struct ref *ref, struct ref *list)\n \t\t}\n \treturn 1;\n }\n+\n+/*\n+ * Return true if there is anything to report, otherwise false.\n+ */\n+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)\n+{\n+\tunsigned char sha1[20];\n+\tstruct commit *ours, *theirs;\n+\tchar symmetric[84];\n+\tstruct rev_info revs;\n+\tconst char *rev_argv[10], *base;\n+\tint rev_argc;\n+\n+\t/*\n+\t * Nothing to report unless we are marked to build on top of\n+\t * somebody else.\n+\t */\n+\tif (!branch ||\n+\t    !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)\n+\t\treturn 0;\n+\n+\t/*\n+\t * If what we used to build on no longer exists, there is\n+\t * nothing to report.\n+\t */\n+\tbase = branch->merge[0]->dst;\n+\tif (!resolve_ref(base, sha1, 1, NULL))\n+\t\treturn 0;\n+\ttheirs = lookup_commit(sha1);\n+\tif (!theirs)\n+\t\treturn 0;\n+\n+\tif (!resolve_ref(branch->refname, sha1, 1, NULL))\n+\t\treturn 0;\n+\tours = lookup_commit(sha1);\n+\tif (!ours)\n+\t\treturn 0;\n+\n+\t/* are we the same? */\n+\tif (theirs == ours)\n+\t\treturn 0;\n+\n+\t/* Run \"rev-list --left-right ours...theirs\" internally... */\n+\trev_argc = 0;\n+\trev_argv[rev_argc++] = NULL;\n+\trev_argv[rev_argc++] = \"--left-right\";\n+\trev_argv[rev_argc++] = symmetric;\n+\trev_argv[rev_argc++] = \"--\";\n+\trev_argv[rev_argc] = NULL;\n+\n+\tstrcpy(symmetric, sha1_to_hex(ours->object.sha1));\n+\tstrcpy(symmetric + 40, \"...\");\n+\tstrcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));\n+\n+\tinit_revisions(&revs, NULL);\n+\tsetup_revisions(rev_argc, rev_argv, &revs, NULL);\n+\tprepare_revision_walk(&revs);\n+\n+\t/* ... and count the commits on each side. */\n+\t*num_ours = 0;\n+\t*num_theirs = 0;\n+\twhile (1) {\n+\t\tstruct commit *c = get_revision(&revs);\n+\t\tif (!c)\n+\t\t\tbreak;\n+\t\tif (c->object.flags & SYMMETRIC_LEFT)\n+\t\t\t(*num_ours)++;\n+\t\telse\n+\t\t\t(*num_theirs)++;\n+\t}\n+\treturn 1;\n+}\n+\n+/*\n+ * Return true when there is anything to report, otherwise false.\n+ */\n+int format_tracking_info(struct branch *branch, struct strbuf *sb)\n+{\n+\tint num_ours, num_theirs;\n+\tconst char *base, *remote_msg;\n+\n+\tif (!stat_tracking_info(branch, &num_ours, &num_theirs))\n+\t\treturn 0;\n+\n+\tbase = branch->merge[0]->dst;\n+\tif (!prefixcmp(base, \"refs/remotes/\")) {\n+\t\tremote_msg = \" remote\";\n+\t\tbase += strlen(\"refs/remotes/\");\n+\t} else {\n+\t\tremote_msg = \"\";\n+\t}\n+\tif (!num_theirs)\n+\t\tstrbuf_addf(sb, \"Your branch is ahead of the tracked%s branch '%s' \"\n+\t\t\t    \"by %d commit%s.\\n\",\n+\t\t\t    remote_msg, base,\n+\t\t\t    num_ours, (num_ours == 1) ? \"\" : \"s\");\n+\telse if (!num_ours)\n+\t\tstrbuf_addf(sb, \"Your branch is behind the tracked%s branch '%s' \"\n+\t\t\t    \"by %d commit%s,\\n\"\n+\t\t\t    \"and can be fast-forwarded.\\n\",\n+\t\t\t    remote_msg, base,\n+\t\t\t    num_theirs, (num_theirs == 1) ? \"\" : \"s\");\n+\telse\n+\t\tstrbuf_addf(sb, \"Your branch and the tracked%s branch '%s' \"\n+\t\t\t    \"have diverged,\\nand respectively \"\n+\t\t\t    \"have %d and %d different commit(s) each.\\n\",\n+\t\t\t    remote_msg, base,\n+\t\t\t    num_ours, num_theirs);\n+\treturn 1;\n+}\ndiff --git a/remote.h b/remote.h\nindex 8eed87b..091b1d0 100644\n--- a/remote.h\n+++ b/remote.h\n@@ -129,4 +129,8 @@ enum match_refs_flags {\n \tMATCH_REFS_MIRROR\t= (1 << 1),\n };\n \n+/* Reporting of tracking info */\n+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);\n+int format_tracking_info(struct branch *branch, struct strbuf *sb);\n+\n #endif\n-- \n1.5.6.1.156.ge903b\n"},{"id":"81934","messageId":"7vod5gen9r.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"7vlk0lmn32.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 2/3] git-status: show the remote tracking statistics","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-02T07:52:16Z","receivedAt":"2008-07-02T07:52:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This teaches \"git status\" to show the same remote tracking statistics\n\"git checkout\" gives at the beginning of the output.\n\nNow the necessary low-level machinery is properly factored out, we can do\nthis quite cleanly.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n wt-status.c |   22 ++++++++++++++++++++++\n 1 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 28c9e63..eeb106e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -9,6 +9,7 @@\n #include \"diffcore.h\"\n #include \"quote.h\"\n #include \"run-command.h\"\n+#include \"remote.h\"\n \n int wt_status_relative_paths = 1;\n int wt_status_use_color = -1;\n@@ -315,6 +316,25 @@ static void wt_status_print_verbose(struct wt_status *s)\n \trun_diff_index(&rev, 1);\n }\n \n+static void wt_status_print_tracking(struct wt_status *s)\n+{\n+\tstruct strbuf sb = STRBUF_INIT;\n+\tconst char *cp, *ep;\n+\tstruct branch *branch;\n+\n+\tassert(s->branch && !s->is_initial);\n+\tif (prefixcmp(s->branch, \"refs/heads/\"))\n+\t\treturn;\n+\tbranch = branch_get(s->branch + 11);\n+\tif (!format_tracking_info(branch, &sb))\n+\t\treturn;\n+\n+\tfor (cp = sb.buf; (ep = strchr(cp, '\\n')) != NULL; cp = ep + 1)\n+\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER),\n+\t\t\t\t \"# %.*s\", (int)(ep - cp), cp);\n+\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n+}\n+\n void wt_status_print(struct wt_status *s)\n {\n \tunsigned char sha1[20];\n@@ -333,6 +353,8 @@ void wt_status_print(struct wt_status *s)\n \t\t}\n \t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n \t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n+\t\tif (!s->is_initial)\n+\t\t\twt_status_print_tracking(s);\n \t}\n \n \tif (s->is_initial) {\n-- \n1.5.6.1.156.ge903b\n"},{"id":"81935","messageId":"7vhcb8en92.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"7vlk0lmn32.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-02T07:52:41Z","receivedAt":"2008-07-02T07:52:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This teaches \"git branch -v\" to insert the remote tracking statistics in\nthe form of [ours/theirs] just before the one-liner commit log message\nfor the branch.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n  ... which means that you would see something like this.\n\n  * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...\n\n  I did not think we want to spend extra columns to show the name of\n  remote branch each of them tracks, so I am showing only counts.\n\n builtin-branch.c |   14 ++++++++++++--\n 1 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex d279702..0e2bb52 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -310,6 +310,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,\n \tif (verbose) {\n \t\tstruct strbuf subject;\n \t\tconst char *sub = \" **** invalid ref ****\";\n+\t\tchar stat[128];\n \n \t\tstrbuf_init(&subject, 0);\n \n@@ -319,10 +320,19 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,\n \t\t\t\t\t    &subject, 0, NULL, NULL, 0, 0);\n \t\t\tsub = subject.buf;\n \t\t}\n-\t\tprintf(\"%c %s%-*s%s %s %s\\n\", c, branch_get_color(color),\n+\n+\t\tstat[0] = '\\0';\n+\t\tif (item->kind == REF_LOCAL_BRANCH) {\n+\t\t\tint ours, theirs;\n+\t\t\tstruct branch *branch = branch_get(item->name);\n+\t\t\tif (stat_tracking_info(branch, &ours, &theirs))\n+\t\t\t\tsprintf(stat, \"[%d/%d] \", ours, theirs);\n+\t\t}\n+\t\tprintf(\"%c %s%-*s%s %s %s%s\\n\", c, branch_get_color(color),\n \t\t       maxwidth, item->name,\n \t\t       branch_get_color(COLOR_BRANCH_RESET),\n-\t\t       find_unique_abbrev(item->sha1, abbrev), sub);\n+\t\t       find_unique_abbrev(item->sha1, abbrev),\n+\t\t       stat, sub);\n \t\tstrbuf_release(&subject);\n \t} else {\n \t\tprintf(\"%c %s%s%s\\n\", c, branch_get_color(color), item->name,\n-- \n1.5.6.1.156.ge903b\n"},{"id":"81938","messageId":"486B3B05.4080006@viscovery.net","threadId":"14241","inReplyTo":"7vhcb8en92.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-02T08:23:33Z","receivedAt":"2008-07-02T08:23:33Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> This teaches \"git branch -v\" to insert the remote tracking statistics in\n> the form of [ours/theirs] just before the one-liner commit log message\n> for the branch.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>   ... which means that you would see something like this.\n> \n>   * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...\n> \n>   I did not think we want to spend extra columns to show the name of\n>   remote branch each of them tracks, so I am showing only counts.\n\nWhat makes the \"tracking statistics\" so useful, is that it explains the\nsituation in clear words. But here you throw in a few numbers without\nexplanation. It's practically undiscoverable what the numbers mean.\nTherefore, I personally would prefer not to have them here and to save the\nspace for the commit summary.\n\nWhat do you think about showing the tracking information only if --track\nis supplied? But then even write more information:\n\n* jc/report-tracking   41666f7 diverged 3 vs. 117\n  foo                  1234567 behind 22\n  bar                  fedcba9 ahead 6\n\nand filter the output to show only tracking branches.\n\n-- Hannes\n"},{"id":"81953","messageId":"20080702083306.GA28337@diana.vm.bytemark.co.uk","threadId":"14241","inReplyTo":"486B3B05.4080006@viscovery.net","subject":"Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-07-02T08:33:06Z","receivedAt":"2008-07-02T08:33:06Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-07-02 10:23:33 +0200, Johannes Sixt wrote:\n\n> * jc/report-tracking   41666f7 diverged 3 vs. 117\n\nOr even \"ahead 3, behind 117\" here. Otherwise the user has to remember\nwhich number is which, which kind of defeats your point. And it's just\none more character.\n\n>   foo                  1234567 behind 22\n>   bar                  fedcba9 ahead 6\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"81955","messageId":"7vwsk4d6d2.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"486B3B05.4080006@viscovery.net","subject":"Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-02T08:42:49Z","receivedAt":"2008-07-02T08:42:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> What do you think about showing the tracking information only if --track\n> is supplied? But then even write more information:\n>\n> * jc/report-tracking   41666f7 diverged 3 vs. 117\n>   foo                  1234567 behind 22\n>   bar                  fedcba9 ahead 6\n>\n> and filter the output to show only tracking branches.\n\nI am not sure about the use of --track option, but now the infrastructure\nis clean enough for anybody to paint it in his favorite color, and I do\nnot care deeply about how it would look like.  Discuss away and give me an\napplicable patch that the list has concensus on, and I'll apply it.\n"},{"id":"81983","messageId":"CC9ACD5E-2E7E-42D4-AF75-C35C2AB8651E@silverinsanity.com","threadId":"14241","inReplyTo":"20080702083306.GA28337@diana.vm.bytemark.co.uk","subject":"Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2008-07-02T14:44:21Z","receivedAt":"2008-07-02T14:44:21Z","isPatch":true,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Jul 2, 2008, at 4:33 AM, Karl Hasselström wrote:\n\n> On 2008-07-02 10:23:33 +0200, Johannes Sixt wrote:\n>\n>> * jc/report-tracking   41666f7 diverged 3 vs. 117\n>\n> Or even \"ahead 3, behind 117\" here. Otherwise the user has to remember\n> which number is which, which kind of defeats your point. And it's just\n> one more character.\n>\n>>  foo                  1234567 behind 22\n>>  bar                  fedcba9 ahead 6\n\nThis is probably the most useful for a new user.  The short version of  \nthat (config option to give it for power users and hide it from those  \nit would confuse) should use plus and minus for ahead and behind:\n\n  * jc/report-tracking        41666f7 [+3 -117] git-branch -v: show  \nthe remo...\n\nI can't follow the code with the ten seconds I have to look at it.  Is  \nthis ahead/behind current branch, tracking branch, or other?\n\n~~ Brian\n"},{"id":"81991","messageId":"alpine.DEB.1.00.0807021643120.9925@racer","threadId":"14241","inReplyTo":"7vhcb8en92.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] git-branch -v: show the remote tracking statistics","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-02T15:44:19Z","receivedAt":"2008-07-02T15:44:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 2 Jul 2008, Junio C Hamano wrote:\n\n> This teaches \"git branch -v\" to insert the remote tracking statistics in\n> the form of [ours/theirs] just before the one-liner commit log message\n> for the branch.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>   ... which means that you would see something like this.\n> \n>   * jc/report-tracking        41666f7 [3/117] git-branch -v: show the remo...\n\nActually, I would like to have something like\n\n$ git branch --explain-relationship master next\n\nCiao,\nDscho\n"},{"id":"82133","messageId":"486CFDA3.9070704@free.fr","threadId":"14241","inReplyTo":"7v3amsg1wx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/3] Making remote tracking statistics available to other tools","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-03T16:26:11Z","receivedAt":"2008-07-03T16:26:11Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Junio C Hamano a écrit :\n> The one I sent out was a bit hacky as the existing implementation inside\n> git-checkout was not designed to be cleanly reusable.\n> \n> Here is a cleaned up series that could be applied.\n> \n> [PATCH 1/3] Refactor \"tracking statistics\" code used by \"git checkout\"\n> [PATCH 2/3] git-status: show the remote tracking statistics\n> [PATCH 3/3] git-branch -v: show the remote tracking statistics\n\nSorry, but the third patch does not work for me. FWIU, the problem comes from\nthe revision walking code that is not reentrant because of the object cache.\nIOW, calling stats_tracking_info() more than once does not work: objects\nstates changed after first call.\n\nI do not understand the code enough yet and I failed to fix it. The only way\nI found is by clearing obj_hash (object.c) but this seems the wrong thing to\ndo.\n\nIdeas?\n\nThis test case should trigger the bug:\n\n$ for i in a b c; do echo $i>$i && git add $i && git commit -m $i; done\n$ git clone . clone1\n$ cd clone1\n$ git checkout -b b1 origin/master\n$ git reset --hard HEAD~\n$ echo d>d && git add d && git commit -m d\n$ git checkout -b b2 origin/master\n$ git reset --hard HEAD~\n$ git merge b1\n\n$ git branch -v\n  b1     c07015a [ahead 1, behind 1] d\n* b2     c07015a d\n  master 08ca18b c\n\nb1 and b2 are both 1 commit ahead and 1 commit behind.\n\n$ git branch -D b1\n$ git branch -v\n* b2     c07015a [ahead 1, behind 1] d\n  master 08ca18b c\n\ndeleting b1 show us the side effect.\n\nOlivier.\n"},{"id":"82142","messageId":"7v8wwi23dr.fsf@gitster.siamese.dyndns.org","threadId":"14241","inReplyTo":"486CFDA3.9070704@free.fr","subject":"Re: [PATCH 0/3] Making remote tracking statistics available to other tools","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-03T19:07:12Z","receivedAt":"2008-07-03T19:07:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olivier Marin <dkr+ml.git@free.fr> writes:\n\n> Junio C Hamano a écrit :\n>> The one I sent out was a bit hacky as the existing implementation inside\n>> git-checkout was not designed to be cleanly reusable.\n>> \n>> Here is a cleaned up series that could be applied.\n>> \n>> [PATCH 1/3] Refactor \"tracking statistics\" code used by \"git checkout\"\n>> [PATCH 2/3] git-status: show the remote tracking statistics\n>> [PATCH 3/3] git-branch -v: show the remote tracking statistics\n>\n> Sorry, but the third patch does not work for me. FWIU, the problem comes from\n> the revision walking code that is not reentrant because of the object cache.\n> IOW, calling stats_tracking_info() more than once does not work: objects\n> states changed after first call.\n>\n> I do not understand the code enough yet and I failed to fix it. The only way\n> I found is by clearing obj_hash (object.c) but this seems the wrong thing to\n> do.\n>\n> Ideas?\n\nThanks.\n\n remote.c                 |    4 +++\n revision.h               |    1 +\n t/t6040-tracking-info.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 57 insertions(+), 0 deletions(-)\n\ndiff --git a/remote.c b/remote.c\nindex bd5c3be..df8bd72 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1295,6 +1295,10 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)\n \t\telse\n \t\t\t(*num_theirs)++;\n \t}\n+\n+\t/* clear object flags smudged by the above traversal */\n+\tclear_commit_marks(ours, ALL_REV_FLAGS);\n+\tclear_commit_marks(theirs, ALL_REV_FLAGS);\n \treturn 1;\n }\n \ndiff --git a/revision.h b/revision.h\nindex abce500..e8bac6d 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -11,6 +11,7 @@\n #define ADDED\t\t(1u<<7)\t/* Parents already parsed and added? */\n #define SYMMETRIC_LEFT\t(1u<<8)\n #define TOPOSORT\t(1u<<9)\t/* In the active toposort list.. */\n+#define ALL_REV_FLAGS\t((1u<<10)-1)\n \n struct rev_info;\n struct log_info;\ndiff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh\nnew file mode 100755\nindex 0000000..960db2d\n--- /dev/null\n+++ b/t/t6040-tracking-info.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+\n+test_description='remote tracking stats'\n+\n+. ./test-lib.sh\n+\n+advance () {\n+\techo \"$1\" >\"$1\" &&\n+\tgit add \"$1\" &&\n+\ttest_tick &&\n+\tgit commit -m \"$1\"\n+}\n+\n+test_expect_success setup '\n+\tfor i in a b c;\n+\tdo\n+\t\tadvance $i || break\n+\tdone &&\n+\tgit clone . test &&\n+\t(\n+\t\tcd test &&\n+\t\tgit checkout -b b1 origin &&\n+\t\tgit reset --hard HEAD^ &&\n+\t\tadvance d &&\n+\t\tgit checkout -b b2 origin &&\n+\t\tgit reset --hard b1 &&\n+\t\tgit checkout -b b3 origin &&\n+\t\tgit reset --hard HEAD^ &&\n+\t\tgit checkout -b b4 origin &&\n+\t\tadvance e &&\n+\t\tadvance f\n+\t)\n+'\n+\n+script='s/^..\\(b.\\)[\t 0-9a-f]*\\[\\([^]]*\\)\\].*/\\1 \\2/p'\n+cat >expect <<\\EOF\n+b1 ahead 1, behind 1\n+b2 ahead 1, behind 1\n+b3 behind 1\n+b4 ahead 2\n+EOF\n+\n+test_expect_success 'branch -v' '\n+\t(\n+\t\tcd test &&\n+\t\tgit branch -v\n+\t) |\n+\tsed -n -e \"$script\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_done\n"},{"id":"82145","messageId":"486D27AA.405@free.fr","threadId":"14241","inReplyTo":"7v8wwi23dr.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/3] Making remote tracking statistics available to other tools","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-07-03T19:25:30Z","receivedAt":"2008-07-03T19:25:30Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Junio C Hamano a écrit :\n> \n>  remote.c                 |    4 +++\n>  revision.h               |    1 +\n>  t/t6040-tracking-info.sh |   52 ++++++++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 57 insertions(+), 0 deletions(-)\n\nTested: it works. Thanks.\n\nOlivier.\n"},{"id":"82210","messageId":"25F65C20-1B9B-4626-AD06-449D8613D394@simplicidade.org","threadId":"14241","inReplyTo":"20080701112235.GC11809@elte.hu","subject":"Re: [OT] Your branch is ahead of the tracked remote branch 'origin/master' by 50 commits.","fromName":"Pedro Melo","fromEmail":"melo@simplicidade.org","sentAt":"2008-07-04T08:35:31Z","receivedAt":"2008-07-04T08:35:31Z","isPatch":false,"sender":{"key":"melo@simplicidade.org","avatar":"https://gravatar.com/avatar/13ddbb01e300285a93aa1e3739653a81f9b1d3438bd03a4ac36b88e4ffeeafc3?d=mp&s=160"},"body":"Hi,\n\nOn Jul 1, 2008, at 12:22 PM, Ingo Molnar wrote:\n> [ Oh, and i could switch between git versions without having to  \n> rebuild\n>   ;-) ]\n\nhmms... Can you just use\n\nversion=`git-describe`\n./configure --prefix=/usr/local/git-$version\nmake && sudo make install\nsudo sh -c 'rm -f /usr/local/git && ln -s /usr/local/git-$version / \nusr/local/git'\n\nand stick /usr/local/git/bin in your path?\n\nChanging git versions is just a ln -s away.\n\nBest regards,\n-- \nPedro Melo\nBlog: http://www.simplicidade.org/notes/\nXMPP ID: melo@simplicidade.org\nUse XMPP!\n"}]}