{"thread":{"id":"24021","subject":"[PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","startedAt":"2010-06-06T00:05:20Z","lastAt":"2010-06-12T00:00:02Z","messageCount":20,"participants":["Andrew Sayers","Thomas Rast","Jakub Narebski","Peter Kjellerstedt","John Tapsell","Michael J Gruber","Steven Michalske","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143069","messageId":"4C0AE640.3040503@pileofstuff.org","threadId":"24021","inReplyTo":null,"subject":"[PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-06-06T00:05:20Z","receivedAt":"2010-06-06T00:05:20Z","isPatch":true,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"People working in small teams sometimes forget to push their changes, causing\ngeneral confusion.  A gentle reminder in the command prompt should help.\n\nUsers migrating from centralised version control systems are especially likely\nto forget, so I've included git-svn support as a special case.  Only SVN is\nsupported because it's the only centralised version control system I have any\nexperience with.  The code is designed to make adding other version control\nsystems easy for anyone that's interested.\n\nSigned-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n---\n contrib/completion/git-completion.bash |   33 ++++++++++++++++++++++++++++++-\n 1 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d3fec32..4bb0fee 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -48,6 +48,12 @@\n #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n #       untracked files, then a '%' will be shown next to the branch name.\n #\n+#       If you would like to see if there're unpushed commits, then\n+#       you can set GIT_PS1_SHOWUNPUSHED to a nonempty value. If\n+#       there're unpushed commits, then a '!' will be shown next to\n+#       the branch name.  Setting GIT_PS1_SHOWUNPUSHED=svn will look\n+#       for unpushed git-svn commits.\n+#\n # To submit patches:\n #\n #    *) Read Documentation/SubmittingPatches\n@@ -138,6 +144,7 @@ __git_ps1 ()\n \t\tlocal s\n \t\tlocal u\n \t\tlocal c\n+\t\tlocal p\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n@@ -167,12 +174,34 @@ __git_ps1 ()\n \t\t\t      u=\"%\"\n \t\t\t   fi\n \t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUNPUSHED-}\" ]; then\n+\t\t\t   local head\n+\t\t\t   local upstream\n+\t\t\t   if [ \"${GIT_PS1_SHOWUNPUSHED-}\" = \"svn\" ]; then # git-svn upstream checking\n+\t\t\t      local remote_branch=$( git config --get svn-remote.svn.url | sed 's/\\//\\\\\\//g' )\n+\t\t\t      upstream=$( git log | sed -ne \"/^    git-svn-id: / { s/^    git-svn-id: $remote_branch\\/\\([^@]*\\).*/\\1/p ; q }\" )\n+\t\t\t   else # git upstream checking\n+\t\t\t      upstream=\"@{upstream}\"\n+\t\t\t   fi\n+\n+\t\t\t   if git rev-parse --quiet \"$upstream\" HEAD 2>/dev/null | {\n+\t\t\t      read upstream\n+\t\t\t      read head\n+\t\t\t      [ -n \"$head\" -a -n \"$upstream\" -a \"$head\" != \"$upstream\" ]\n+\t\t\t   }; then\n+\t\t\t       p='!'\n+\t\t\t   else\n+\t\t\t       p=\n+\t\t\t   fi\n+\t\t\tfi\n+\n \t\tfi\n \n \t\tif [ -n \"${1-}\" ]; then\n-\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n+\t\t\tprintf \"$1\" \"$c${b##refs/heads/}$w$i$s$u$r$p\"\n \t\telse\n-\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n+\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r$p\"\n \t\tfi\n \tfi\n }\n"},{"id":"143097","messageId":"201006062014.59386.trast@student.ethz.ch","threadId":"24021","inReplyTo":"4C0AE640.3040503@pileofstuff.org","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-06T18:14:59Z","receivedAt":"2010-06-06T18:14:59Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Andrew Sayers wrote:\n> People working in small teams sometimes forget to push their changes, causing\n> general confusion.  A gentle reminder in the command prompt should help.\n\nI think this is a good idea but...\n\n> +#       If you would like to see if there're unpushed commits, then\n> +#       you can set GIT_PS1_SHOWUNPUSHED to a nonempty value. If\n> +#       there're unpushed commits, then a '!' will be shown next to\n> +#       the branch name.  Setting GIT_PS1_SHOWUNPUSHED=svn will look\n> +#       for unpushed git-svn commits.\n\nAt least the svn/git setting should definitely be configurable through\ngit-config, so that it becomes per-repo configurable.  Also, you could\ntry to trigger the svn mode by default if a svn-remote.svn.url exists.\n\n> +\t\t\t      upstream=$( git log | sed -ne \"/^    git-svn-id: / { s/^    git-svn-id: $remote_branch\\/\\([^@]*\\).*/\\1/p ; q }\" )\n\nHow about starting with\n\n  git log -1 --first-parent --grep=\"^git-svn-id: $remote_branch\"\n\nwhich should be faster and is also closer to the truth.  It still\ndoesn't work if the repo was cloned with --no-metadata.  Doing it\nright probably would require a new informational command in git-svn\nthat reports the branch name.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"143104","messageId":"201006062212.56657.trast@student.ethz.ch","threadId":"24021","inReplyTo":"4C0AE640.3040503@pileofstuff.org","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-06T20:12:56Z","receivedAt":"2010-06-06T20:12:56Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Andrew Sayers wrote:\n> People working in small teams sometimes forget to push their changes, causing\n> general confusion.  A gentle reminder in the command prompt should help.\n[...]\n> +#       there're unpushed commits, then a '!' will be shown next to\n\nBTW, here's another idea: how about using '>' and '<' to signal being\nahead and behind upstream, resp. (and both if they diverged)?\n\n(I think the hard question here is whether it's helpful enough to\nweigh against the confusion of having it show nothing, because the\nuser hasn't fetched after an update on the remote...)\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"143106","messageId":"4C0C09BF.4070503@pileofstuff.org","threadId":"24021","inReplyTo":"201006062014.59386.trast@student.ethz.ch","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-06-06T20:49:03Z","receivedAt":"2010-06-06T20:49:03Z","isPatch":true,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"On 06/06/10 19:14, Thomas Rast wrote:\n> \n> At least the svn/git setting should definitely be configurable through\n> git-config, so that it becomes per-repo configurable.  Also, you could\n> try to trigger the svn mode by default if a svn-remote.svn.url exists.\n> \n\nI'm not averse to adding a config setting, or to exploring the\n\"--no-metadata\" case.  I am concerned about the strict time constraints\nfor code called in a command prompt though.  For instance, calling\ngit-svn could easily make your prompt take over half a second to respond\nbecause of all the Perl you'd have to compile.  I'd also want a few\nreal-world use cases and a nod from Shawn before diverging any further\nfrom the existing GIT_PS1_FOO= convention.\n\nHaving said all that, I'm quite happy to resubmit with\nGIT_PS1_SHOWUNPUSHED=svn treated like GIT_PS1_SHOWUNPUSHED=1 when\n$GIT_DIR/svn doesn't exist.\n\n> How about starting with\n> \n>   git log -1 --first-parent --grep=\"^git-svn-id: $remote_branch\"\n> \n> which should be faster and is also closer to the truth.  It still\n> doesn't work if the repo was cloned with --no-metadata.  Doing it\n> right probably would require a new informational command in git-svn\n> that reports the branch name.\n\nGood idea about \"-1\" and \"--grep\", but multi-parent commits aren't\ncompatible with SVN, so I don't see how \"--first-parent\" is useful here?\n In fact I'm tempted to look for merge commits and print a big warning\nwhen one is found.\n\nI don't see how to actually split out the branch name without calling\nsed or using one of the disallowed ${} constructs.  So I compared the\nfollowing commands on my PC (2.1 GHz dual-core Athlon) using a\nrepository with 100 empty commits between HEAD and a git-svn-id:\n\ntime git log | \\\n\tsed -ne \"/^    git-svn-id: / { s/^    git-svn-id: \"\\\n\t\"$remote_branch\\/\\([^@]*\\).*/\\1/p ; q }\"\n\ntime git log -1 --grep=\"^git-svn-id: $remote_branch\" | \\\n\tsed -ne \"s/^    git-svn-id: $remote_branch\\/\\([^@]*\\).*/\\1/p\"\n\nThe former averaged about 0.017 seconds, whereas the latter averaged\nabout 0.015.  So when I resubmit this patch, I'll include your version\nif merge commits are somehow useful to SVNers, or a merge warning otherwise.\n\nIncidentally, a quick bit of etiquette - would you rather I submitted an\nRFC patch or two with these changes, or wait until the discussion has\nreached a more stable point?\n\n\t- Andrew\n"},{"id":"143107","messageId":"m3r5kjq3ac.fsf@localhost.localdomain","threadId":"24021","inReplyTo":"4C0C09BF.4070503@pileofstuff.org","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-06-06T21:07:48Z","receivedAt":"2010-06-06T21:07:48Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Andrew Sayers <andrew-git@pileofstuff.org> writes:\n\n> I don't see how to actually split out the branch name without calling\n> sed or using one of the disallowed ${} constructs.  So I compared the\n> following commands on my PC (2.1 GHz dual-core Athlon) using a\n> repository with 100 empty commits between HEAD and a git-svn-id:\n> \n> time git log | \\\n> \tsed -ne \"/^    git-svn-id: / { s/^    git-svn-id: \"\\\n> \t\"$remote_branch\\/\\([^@]*\\).*/\\1/p ; q }\"\n> \n> time git log -1 --grep=\"^git-svn-id: $remote_branch\" | \\\n> \tsed -ne \"s/^    git-svn-id: $remote_branch\\/\\([^@]*\\).*/\\1/p\"\n\nWhat disallowed ${} constructs?\n\nFirst, ${var#pattern}, ${var##pattern}, ${var%pattern} and ${var%%pattern}\nare POSIX, so you can use it in git shell scripts.\n\nSecond, this is _bash_ completion, so you can use also bash-specific\nexpansion, like ${var/pattern/string} or ${var//pattern/string}.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"143119","messageId":"4C0C1EDF.6050404@pileofstuff.org","threadId":"24021","inReplyTo":"m3r5kjq3ac.fsf@localhost.localdomain","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-06-06T22:19:11Z","receivedAt":"2010-06-06T22:19:11Z","isPatch":true,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"On 06/06/10 22:07, Jakub Narebski wrote:\n> \n> What disallowed ${} constructs?\n\nMy mistake, I misread that part of CodingGuidelines.  The following\nbash-specific implementation takes about 0.013 seconds:\n\nBRANCH=( $( git log --first-parent -1 \\\n\t\t--grep=\"^git-svn-id: $remote_branch\" ) )\nBRANCH=${BRANCH[ ${#BRANCH[@]} - 2 ]}\nBRANCH=${BRANCH%@*}\nBRANCH=${BRANCH#*$remote_branch/}\n\nUsing an array here saves about 0.001 of a second.\n\n\t- Andrew\n"},{"id":"143144","messageId":"201006070942.34753.trast@student.ethz.ch","threadId":"24021","inReplyTo":"4C0C09BF.4070503@pileofstuff.org","subject":"Re: [PATCH] bash completion: Support \"unpushed commits\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-07T07:42:34Z","receivedAt":"2010-06-07T07:42:34Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Andrew Sayers wrote:\n> \n> I'm not averse to adding a config setting, or to exploring the\n> \"--no-metadata\" case.  I am concerned about the strict time constraints\n> for code called in a command prompt though.  For instance, calling\n> git-svn could easily make your prompt take over half a second to respond\n> because of all the Perl you'd have to compile.\n\nTrue, I forgot about that.\n\n> I'd also want a few\n> real-world use cases and a nod from Shawn before diverging any further\n> from the existing GIT_PS1_FOO= convention.\n\n> Having said all that, I'm quite happy to resubmit with\n> GIT_PS1_SHOWUNPUSHED=svn treated like GIT_PS1_SHOWUNPUSHED=1 when\n> $GIT_DIR/svn doesn't exist.\n\nThere's the precedent of bash.showDirtyState that allows you to\ndisable the +* indicators _per repository_.  The latter idea also\nsounds reasonable, though I personally would find the configuration\nmore useful.  I have several repos that push to both git (for real\nwork) and SVN (for buildbots) where I'd prefer the indicator to refer\nto git.\n\n> > How about starting with\n> > \n> >   git log -1 --first-parent --grep=\"^git-svn-id: $remote_branch\"\n> \n> Good idea about \"-1\" and \"--grep\", but multi-parent commits aren't\n> compatible with SVN, so I don't see how \"--first-parent\" is useful here?\n>  In fact I'm tempted to look for merge commits and print a big warning\n> when one is found.\n\nPlease don't; you'd immediately lose me as a user :-)\n\nFirst, --first-parent is actually how git-svn looks for the\ngit-svn-id, and any other search is liable to turn up wrong results.\nSee working_head_info in git-svn.perl.\n\nSecond, the behaviour of git-svn with merges is very useful and\nwell-defined.  (Yes, there are stern warnings in the manpage, but if\nyou know what you're doing just ignore them...)\n\n'git svn dcommit' will first determine the correct upstream branch\naccording to the above logic, i.e., it *always* commits to the\nfirst-parent ancestry.  Then it commits the diff along this line of\nhistory (i.e., always diffing to the first parent) but it does rewrite\nthe commits so that merges are preserved.\n\nIn pictures, if you have\n\n    o---B---o---o---o    trunk\n         \\\n          *---*---*---*    topic\n\nand run 'git checkout trunk; git merge topic; git svn dcommit' you get\n\n    o---B---o---o---o---M'    trunk\n         \\             /\n          *---*---*---*    topic\n\n(writing M' since this is already the rewritten version of an original\nmerge M).  M' looks to SVN like a 'git merge --squash topic' because\ngit-svn doesn't (yet?) store the merge info.\n\nSo you get to keep the git merge info, which is very useful for later\nmerges of 'topic'.\n\nNote: NEVER run 'git checkout topic; git merge trunk'.  git-svn will\nthink (because of the first-parent rule) that you want to commit on\ntop of B!  I don't know what happens next but I expect it won't be too\npretty.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"143284","messageId":"4C0EB7F1.1030707@pileofstuff.org","threadId":"24021","inReplyTo":"201006070942.34753.trast@student.ethz.ch","subject":"[RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-06-08T21:36:49Z","receivedAt":"2010-06-08T21:36:49Z","isPatch":false,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"Add a notification in the command prompt specifying whether you're ahead of\n(>), behind (<), diverged from (<>) or at (=) your upstream.  This is\nespecially helpful in small teams that (forget to) push to each other very\nfrequently.\n\nSupport git-svn upstream detection as a special case, as migraters from\ncentralised version control systems are especially likely to forget to push.\n\nSupport for other types of upstream than SVN should be easy to add if anyone is\nso inclined.\n\nSigned-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n---\n\nThis patch includes Thomas Rast's feedback - thanks Thomas for the education :)\n\nThis patch makes unashamed use of shell arrays and substring expansion that\nwould normally not be allowed.  As Jakub Narebski mentioned, this is probably ok\nin a bash-specific script.\n\nUnlike other prompt options, I've put the divergence characters on the left of the\nbranch name.  I'm really not sure about this, and I'd like to hear people's\nopinions.\n\nThis patch produces output like this when I have unpushed commits:\n\n[andrew@pc myrepo >master] # my master is ahead of upstream\n\nIntuitively, I like having a \">\" when I'm ahead, although it would be more\nlogical to have something like this:\n\n[andrew@pc myrepo <master] # upstream less-than master\n\nPutting the symbol on the right makes this problem go away, but looks ridiculous\nif you use a prompt like PS1='\\W:$(__git_ps1 \"(%s)\")> '\n\nmyrepo:master>> # master greater-than upstream\nmyrepo:master<> # master less-than upstream\nmyrepo:master<>> # master and upstream have diverged\n\nI'd rather not rely on colour prompts to clear this up - using colour as the\nonly way to convey important information to the user rarely ends well.\n\nAdding a \"u\" to the symbol could also clear this up:\n\n[andrew@pc myrepo u<master] # upstream less-than master\n\nUsing \"u<\", \"u=\", \"u>\" and \"<>\" would mean that the prompt always used either\ntwo or zero characters, which would keep prompts lined up over time.  But it\nwould also eat horizontal space for an issue you'd stop seeing after a few\nminutes.\n\nFinally, my apologies to anyone that tried to apply my previous patch - to make\na long story short, it turns out I need this feature more than I realised :)\n\n contrib/completion/git-completion.bash |   58 +++++++++++++++++++++++++++++++-\n 1 files changed, 57 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 57245a8..1dc80fd 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -42,6 +42,14 @@\n #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n #       untracked files, then a '%' will be shown next to the branch name.\n #\n+#       If you would like to see the difference bitween HEAD and its\n+#       upstream, set GIT_PS1_SHOWUPSTREAM to a nonempty value.\n+#       Unpushed commits (>), unmerged commits (<), both (<>) and\n+#       neither (=) will be shown on the left of the branch name.  You\n+#       can enable git-svn mode by setting GIT_PS1_SHOWUPSTREAM=svn\n+#       and set the value per-repository with the bash.showUpstream\n+#       variable.\n+#\n # To submit patches:\n #\n #    *) Read Documentation/SubmittingPatches\n@@ -132,6 +140,7 @@ __git_ps1 ()\n \t\tlocal s\n \t\tlocal u\n \t\tlocal c\n+\t\tlocal p\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n@@ -159,10 +168,57 @@ __git_ps1 ()\n \t\t\t      u=\"%\"\n \t\t\t   fi\n \t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n+\n+\t\t\t\t# Note: 'p' is used as a temporary throughout this block,\n+\t\t\t\t# before finally being assigned its correct value\n+\n+\t\t\t\tif p=\"$(git config --get bash.showUpstream)\"\n+\t\t\t\tthen\n+\t\t\t\t\tGIT_PS1_SHOWUPSTREAM=\"$p\"\n+\t\t\t\tfi\n+\n+\t\t\t\tlocal upstream\n+\n+\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n+\n+\t\t\t\t\t# git-svn upstream checking\n+\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n+\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n+\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n+\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n+\t\t\t\t\tupstream=${upstream%@*}\n+\t\t\t\t\tupstream=${upstream#*$p/}\n+\n+\t\t\t\telse # git upstream checking\n+\t\t\t\t  upstream=\"@{upstream}\"\n+\t\t\t\tfi\n+\n+\t\t\t\tif p=\"$( git rev-list \\\n+\t\t\t\t\t\t--left-right \"$upstream\"...HEAD 2>/dev/null )\"\n+\t\t\t\tthen\n+\t\t\t\t\tcase \"$p\" in\n+\t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n+\t\t\t\t\t\t*\\<*          ) p=\"<\"  ;;\n+\t\t\t\t\t\t*\\>*          ) p=\">\"  ;;\n+\t\t\t\t\t\t\"\"            ) p=\"=\"  ;;\n+\n+\t\t\t\t\t\t# the following case shouldn't be possible\n+\t\t\t\t\t\t# if you see this, please report it as a bug\n+\t\t\t\t\t\t* ) p=\"?ERROR($p)?\" ;;\n+\n+\t\t\t\t\tesac\n+\t\t\t\telse\n+\t\t\t\t\tp=\"\"\n+\t\t\t\tfi\n+\n+\t\t\tfi\n+\n \t\tfi\n \n \t\tlocal f=\"$w$i$s$u\"\n-\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r\"\n+\t\tprintf \"${1:- (%s)}\" \"$c$p${b##refs/heads/}${f:+ $f}$r\"\n \tfi\n }\n \n-- \n1.7.0.4\n"},{"id":"143314","messageId":"A612847CFE53224C91B23E3A5B48BAC744839BF3EB@xmail3.se.axis.com","threadId":"24021","inReplyTo":"4C0EB7F1.1030707@pileofstuff.org","subject":"RE: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Peter Kjellerstedt","fromEmail":"peter.kjellerstedt@axis.com","sentAt":"2010-06-09T08:21:29Z","receivedAt":"2010-06-09T08:21:29Z","isPatch":false,"sender":{"key":"peter.kjellerstedt@axis.com","avatar":"https://gravatar.com/avatar/6d5a0182283c8eccd7b134a54dbfd5f30038f3ad4d38b96f424884b614a61ca2?d=mp&s=160"},"body":"> -----Original Message-----\n> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On\n> Behalf Of Andrew Sayers\n> Sent: den 8 juni 2010 23:37\n> To: Thomas Rast\n> Cc: Shawn O. Pearce; Git Mailing List\n> Subject: [RFC/PATCHv2] bash completion: Support \"divergence from\n> upstream\" warnings in __git_ps1\n> \n> Add a notification in the command prompt specifying whether you're ahead of\n> (>), behind (<), diverged from (<>) or at (=) your upstream.  This is\n> especially helpful in small teams that (forget to) push to each other very\n> frequently.\n> \n> Support git-svn upstream detection as a special case, as migraters from\n> centralised version control systems are especially likely to forget to push.\n> \n> Support for other types of upstream than SVN should be easy to add if anyone is\n> so inclined.\n> \n> Signed-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n> ---\n> \n> This patch includes Thomas Rast's feedback - thanks Thomas for the education :)\n> \n> This patch makes unashamed use of shell arrays and substring expansion that\n> would normally not be allowed.  As Jakub Narebski mentioned, this is probably ok\n> in a bash-specific script.\n> \n> Unlike other prompt options, I've put the divergence characters on the left of the\n> branch name.  I'm really not sure about this, and I'd like to hear people's\n> opinions.\n> \n> This patch produces output like this when I have unpushed commits:\n> \n> [andrew@pc myrepo >master] # my master is ahead of upstream\n> \n> Intuitively, I like having a \">\" when I'm ahead, although it would be more\n> logical to have something like this:\n> \n> [andrew@pc myrepo <master] # upstream less-than master\n> \n> Putting the symbol on the right makes this problem go away, but looks ridiculous\n> if you use a prompt like PS1='\\W:$(__git_ps1 \"(%s)\")> '\n> \n> myrepo:master>> # master greater-than upstream\n> myrepo:master<> # master less-than upstream\n> myrepo:master<>> # master and upstream have diverged\n> \n> I'd rather not rely on colour prompts to clear this up - using colour as the\n> only way to convey important information to the user rarely ends well.\n> \n> Adding a \"u\" to the symbol could also clear this up:\n> \n> [andrew@pc myrepo u<master] # upstream less-than master\n> \n> Using \"u<\", \"u=\", \"u>\" and \"<>\" would mean that the prompt always used either\n> two or zero characters, which would keep prompts lined up over time. But it\n> would also eat horizontal space for an issue you'd stop seeing after a few\n> minutes.\n> \n> Finally, my apologies to anyone that tried to apply my previous patch - to make\n> a long story short, it turns out I need this feature more than I realised :)\n> \n>  contrib/completion/git-completion.bash |   58 +++++++++++++++++++++++++++++++-\n>  1 files changed, 57 insertions(+), 1 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 57245a8..1dc80fd 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -42,6 +42,14 @@\n>  #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n>  #       untracked files, then a '%' will be shown next to the branch name.\n>  #\n> +#       If you would like to see the difference bitween HEAD and its\n\nTypo: bitween -> between\n\n> +#       upstream, set GIT_PS1_SHOWUPSTREAM to a nonempty value.\n> +#       Unpushed commits (>), unmerged commits (<), both (<>) and\n> +#       neither (=) will be shown on the left of the branch name.  You\n> +#       can enable git-svn mode by setting GIT_PS1_SHOWUPSTREAM=svn\n> +#       and set the value per-repository with the bash.showUpstream\n> +#       variable.\n> +#\n>  # To submit patches:\n>  #\n>  #    *) Read Documentation/SubmittingPatches\n> @@ -132,6 +140,7 @@ __git_ps1 ()\n>  \t\tlocal s\n>  \t\tlocal u\n>  \t\tlocal c\n> +\t\tlocal p\n> \n>  \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n>  \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n> @@ -159,10 +168,57 @@ __git_ps1 ()\n>  \t\t\t      u=\"%\"\n>  \t\t\t   fi\n>  \t\t\tfi\n> +\n> +\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n> +\n> +\t\t\t\t# Note: 'p' is used as a temporary throughout this block,\n> +\t\t\t\t# before finally being assigned its correct value\n> +\n> +\t\t\t\tif p=\"$(git config --get bash.showUpstream)\"\n> +\t\t\t\tthen\n> +\t\t\t\t\tGIT_PS1_SHOWUPSTREAM=\"$p\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tlocal upstream\n> +\n> +\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n> +\n> +\t\t\t\t\t# git-svn upstream checking\n> +\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n> +\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n> +\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n> +\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n> +\t\t\t\t\tupstream=${upstream%@*}\n> +\t\t\t\t\tupstream=${upstream#*$p/}\n> +\n> +\t\t\t\telse # git upstream checking\n> +\t\t\t\t  upstream=\"@{upstream}\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tif p=\"$( git rev-list \\\n> +\t\t\t\t\t\t--left-right \"$upstream\"...HEAD 2>/dev/null )\"\n> +\t\t\t\tthen\n> +\t\t\t\t\tcase \"$p\" in\n> +\t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n> +\t\t\t\t\t\t*\\<*          ) p=\"<\"  ;;\n> +\t\t\t\t\t\t*\\>*          ) p=\">\"  ;;\n> +\t\t\t\t\t\t\"\"            ) p=\"=\"  ;;\n> +\n> +\t\t\t\t\t\t# the following case shouldn't be possible\n> +\t\t\t\t\t\t# if you see this, please report it as a bug\n> +\t\t\t\t\t\t* ) p=\"?ERROR($p)?\" ;;\n> +\n> +\t\t\t\t\tesac\n> +\t\t\t\telse\n> +\t\t\t\t\tp=\"\"\n> +\t\t\t\tfi\n> +\n> +\t\t\tfi\n> +\n>  \t\tfi\n> \n>  \t\tlocal f=\"$w$i$s$u\"\n> -\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r\"\n> +\t\tprintf \"${1:- (%s)}\" \"$c$p${b##refs/heads/}${f:+ $f}$r\"\n>  \tfi\n>  }\n> \n> --\n> 1.7.0.4\n\n//Peter\n"},{"id":"143316","messageId":"AANLkTiltzOHvsVkqnKLV-fy-T8KyGQ8vg6pPm4xPZpJ-@mail.gmail.com","threadId":"24021","inReplyTo":"4C0EB7F1.1030707@pileofstuff.org","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"John Tapsell","fromEmail":"johnflux@gmail.com","sentAt":"2010-06-09T08:45:15Z","receivedAt":"2010-06-09T08:45:15Z","isPatch":false,"sender":{"key":"johnflux@gmail.com","avatar":"https://gravatar.com/avatar/25f70d4c0f96396b84a2e34bcd9bdc233462c7b4be29b5fdca8266fc53f30b0c?d=mp&s=160"},"body":"On 9 June 2010 06:36, Andrew Sayers <andrew-git@pileofstuff.org> wrote:\n> Add a notification in the command prompt specifying whether you're ahead of\n> (>), behind (<), diverged from (<>) or at (=) your upstream.  This is\n> especially helpful in small teams that (forget to) push to each other very\n> frequently.\n\nI hate to get all feature-bloat on you...\n\nBut could it state the number of commits as well please? :) :)\n\nJohn\n"},{"id":"143318","messageId":"4C0F5C26.5080108@drmicha.warpmail.net","threadId":"24021","inReplyTo":"4C0EB7F1.1030707@pileofstuff.org","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-09T09:17:26Z","receivedAt":"2010-06-09T09:17:26Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"[I haven't followed the previous discussion, just this RFC.]\n\nAndrew Sayers venit, vidit, dixit 08.06.2010 23:36:\n> Add a notification in the command prompt specifying whether you're ahead of\n> (>), behind (<), diverged from (<>) or at (=) your upstream.  This is\n> especially helpful in small teams that (forget to) push to each other very\n> frequently.\n> \n> Support git-svn upstream detection as a special case, as migraters from\n> centralised version control systems are especially likely to forget to push.\n> \n> Support for other types of upstream than SVN should be easy to add if anyone is\n> so inclined.\n> \n> Signed-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n> ---\n> \n> This patch includes Thomas Rast's feedback - thanks Thomas for the education :)\n> \n> This patch makes unashamed use of shell arrays and substring expansion that\n> would normally not be allowed.  As Jakub Narebski mentioned, this is probably ok\n> in a bash-specific script.\n> \n> Unlike other prompt options, I've put the divergence characters on the left of the\n> branch name.  I'm really not sure about this, and I'd like to hear people's\n> opinions.\n\nI'd say it would make sense to you use the same order as \"branch -vv\"\nand \"status -s\", i.e. after the branch name.\n\n> \n> This patch produces output like this when I have unpushed commits:\n> \n> [andrew@pc myrepo >master] # my master is ahead of upstream\n> \n> Intuitively, I like having a \">\" when I'm ahead, although it would be more\n> logical to have something like this:\n\nThat is really illogical, please don't.\n\n> \n> [andrew@pc myrepo <master] # upstream less-than master\n> \n> Putting the symbol on the right makes this problem go away, but looks ridiculous\n> if you use a prompt like PS1='\\W:$(__git_ps1 \"(%s)\")> '\n\nPatient: If I move my arm like this then it hurts.\nDoctor: Then don't do that ;)\n\n> \n> myrepo:master>> # master greater-than upstream\n> myrepo:master<> # master less-than upstream\n> myrepo:master<>> # master and upstream have diverged\n> \n> I'd rather not rely on colour prompts to clear this up - using colour as the\n> only way to convey important information to the user rarely ends well.\n> \n> Adding a \"u\" to the symbol could also clear this up:\n> \n> [andrew@pc myrepo u<master] # upstream less-than master\n> \n> Using \"u<\", \"u=\", \"u>\" and \"<>\" would mean that the prompt always used either\n> two or zero characters, which would keep prompts lined up over time.  But it\n> would also eat horizontal space for an issue you'd stop seeing after a few\n> minutes.\n> \n\nI think a simple space would help already, i.e.\nmyrepo:master<> >\n\nAn alternative would be to use something like\nmyrepo:master+5-3\n\nThe numbers should make this distinguishable from the \"--cached +\". Of\ncourse it eats up more space and is slightly confusing unless it is read\nmaster = upstream + 5 -3.\nOTOH it is very analogous to status -s and branch -vv.\n\n> Finally, my apologies to anyone that tried to apply my previous patch - to make\n> a long story short, it turns out I need this feature more than I realised :)\n> \n\n;)\n\n>  contrib/completion/git-completion.bash |   58 +++++++++++++++++++++++++++++++-\n>  1 files changed, 57 insertions(+), 1 deletions(-)\n> \n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 57245a8..1dc80fd 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -42,6 +42,14 @@\n>  #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n>  #       untracked files, then a '%' will be shown next to the branch name.\n>  #\n> +#       If you would like to see the difference bitween HEAD and its\n> +#       upstream, set GIT_PS1_SHOWUPSTREAM to a nonempty value.\n> +#       Unpushed commits (>), unmerged commits (<), both (<>) and\n> +#       neither (=) will be shown on the left of the branch name.  You\n> +#       can enable git-svn mode by setting GIT_PS1_SHOWUPSTREAM=svn\n> +#       and set the value per-repository with the bash.showUpstream\n> +#       variable.\n> +#\n>  # To submit patches:\n>  #\n>  #    *) Read Documentation/SubmittingPatches\n> @@ -132,6 +140,7 @@ __git_ps1 ()\n>  \t\tlocal s\n>  \t\tlocal u\n>  \t\tlocal c\n> +\t\tlocal p\n>  \n>  \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n>  \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n> @@ -159,10 +168,57 @@ __git_ps1 ()\n>  \t\t\t      u=\"%\"\n>  \t\t\t   fi\n>  \t\t\tfi\n> +\n> +\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n> +\n> +\t\t\t\t# Note: 'p' is used as a temporary throughout this block,\n> +\t\t\t\t# before finally being assigned its correct value\n> +\n> +\t\t\t\tif p=\"$(git config --get bash.showUpstream)\"\n> +\t\t\t\tthen\n> +\t\t\t\t\tGIT_PS1_SHOWUPSTREAM=\"$p\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tlocal upstream\n> +\n> +\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n> +\n> +\t\t\t\t\t# git-svn upstream checking\n> +\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n> +\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n> +\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n> +\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n> +\t\t\t\t\tupstream=${upstream%@*}\n> +\t\t\t\t\tupstream=${upstream#*$p/}\n> +\n> +\t\t\t\telse # git upstream checking\n> +\t\t\t\t  upstream=\"@{upstream}\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tif p=\"$( git rev-list \\\n> +\t\t\t\t\t\t--left-right \"$upstream\"...HEAD 2>/dev/null )\"\n\nHere you have all the info to do a \"grep \\<|wc -l\" etc. instead of the\nbelow if you go for the +5-3.\n\n> +\t\t\t\tthen\n> +\t\t\t\t\tcase \"$p\" in\n> +\t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n> +\t\t\t\t\t\t*\\<*          ) p=\"<\"  ;;\n> +\t\t\t\t\t\t*\\>*          ) p=\">\"  ;;\n> +\t\t\t\t\t\t\"\"            ) p=\"=\"  ;;\n> +\n> +\t\t\t\t\t\t# the following case shouldn't be possible\n> +\t\t\t\t\t\t# if you see this, please report it as a bug\n> +\t\t\t\t\t\t* ) p=\"?ERROR($p)?\" ;;\n> +\n> +\t\t\t\t\tesac\n> +\t\t\t\telse\n> +\t\t\t\t\tp=\"\"\n> +\t\t\t\tfi\n> +\n> +\t\t\tfi\n> +\n>  \t\tfi\n>  \n>  \t\tlocal f=\"$w$i$s$u\"\n> -\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r\"\n> +\t\tprintf \"${1:- (%s)}\" \"$c$p${b##refs/heads/}${f:+ $f}$r\"\n>  \tfi\n>  }\n>  \n\nCheers,\nMichael\n"},{"id":"143374","messageId":"4C0FFE06.60903@drmicha.warpmail.net","threadId":"24021","inReplyTo":"4C0F5C26.5080108@drmicha.warpmail.net","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-09T20:48:06Z","receivedAt":"2010-06-09T20:48:06Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Michael J Gruber venit, vidit, dixit 09.06.2010 11:17:\n...\n> An alternative would be to use something like\n> myrepo:master+5-3\n> \n> The numbers should make this distinguishable from the \"--cached +\". Of\n> course it eats up more space and is slightly confusing unless it is read\n> master = upstream + 5 -3.\n> OTOH it is very analogous to status -s and branch -vv.\n...\n>> +\t\t\t\tif p=\"$( git rev-list \\\n>> +\t\t\t\t\t\t--left-right \"$upstream\"...HEAD 2>/dev/null )\"\n> \n> Here you have all the info to do a \"grep \\<|wc -l\" etc. instead of the\n> below if you go for the +5-3.\n> \n>> +\t\t\t\tthen\n>> +\t\t\t\t\tcase \"$p\" in\n>> +\t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n>> +\t\t\t\t\t\t*\\<*          ) p=\"<\"  ;;\n>> +\t\t\t\t\t\t*\\>*          ) p=\">\"  ;;\n\nI mean something like this\n\n\t\t\t\t\tcase \"$p\" in\n\t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"+\"$(echo \"$p\"|grep \">\"|wc -l)\"-\"$(echo\n\"$p\"|grep \"<\"|wc -l)  ;;\n\t\t\t\t\t\t*\\<*          ) p=\"-\"$(echo \"$p\"|grep \"<\"|wc -l)  ;;\n\t\t\t\t\t\t*\\>*          ) p=\"+\"$(echo \"$p\"|grep \">\"|wc -l)  ;;\n\nwith\n\n\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}$p${f:+ $f}$r\"\n\nresulting in a prompt like\n\n[mjg@localhost git (mjg/sane-symlink-diff+4-153 *+%)]\n\non my branch \"mjg/sane-symlink-diff\".\n\nCheers,\nMichael\n"},{"id":"143378","messageId":"F1A17EC9-1241-4735-9D38-AFECA61CB1D4@gmail.com","threadId":"24021","inReplyTo":"AANLkTiltzOHvsVkqnKLV-fy-T8KyGQ8vg6pPm4xPZpJ-@mail.gmail.com","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Steven Michalske","fromEmail":"smichalske@gmail.com","sentAt":"2010-06-09T21:02:28Z","receivedAt":"2010-06-09T21:02:28Z","isPatch":false,"sender":{"key":"smichalske@gmail.com","avatar":"https://gravatar.com/avatar/721f27456adc9ac84f3bb235f021a70015abb9e09222ae8622fc5579c6a203c1?d=mp&s=160"},"body":"\nOn Jun 9, 2010, at 1:45 AM, John Tapsell wrote:\n\n> On 9 June 2010 06:36, Andrew Sayers <andrew-git@pileofstuff.org> wrote:\n>> Add a notification in the command prompt specifying whether you're ahead of\n>> (>), behind (<), diverged from (<>) or at (=) your upstream.  This is\n>> especially helpful in small teams that (forget to) push to each other very\n>> frequently.\n> \n> I hate to get all feature-bloat on you...\n> \n> But could it state the number of commits as well please? :) :)\n> \n\nI like the idea of ahead, at, behind, and diverged\n\nbut I would want to use unicode/utf8  as my terminal supports it, would use it.\n\n⇅\tUPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW is diverged.\n↑\tUPWARDS ARROW master is ahead.\n↓\tDOWNWARDS ARROW is master is behind.\n\nSteve\n"},{"id":"143379","messageId":"4C1001BA.5010206@drmicha.warpmail.net","threadId":"24021","inReplyTo":"4C0FFE06.60903@drmicha.warpmail.net","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-09T21:03:54Z","receivedAt":"2010-06-09T21:03:54Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Michael J Gruber venit, vidit, dixit 09.06.2010 22:48:\n\n> \t\t\t\t\tcase \"$p\" in\n> \t\t\t\t\t\t\\<*\\>*|\\>*\\<* ) p=\"+\"$(echo \"$p\"|grep \">\"|wc -l)\"-\"$(echo\n> \"$p\"|grep \"<\"|wc -l)  ;;\n> \t\t\t\t\t\t*\\<*          ) p=\"-\"$(echo \"$p\"|grep \"<\"|wc -l)  ;;\n> \t\t\t\t\t\t*\\>*          ) p=\"+\"$(echo \"$p\"|grep \">\"|wc -l)  ;;\n> \n\n...make this\n\ngrep -Fc \">\"\n\netc. rather than\n\ngrep \">\"|wc -l\n\netc. of course. Sorry for the bash-spam :)\n\nMichael\n"},{"id":"143418","messageId":"cover.1276169807.git.trast@student.ethz.ch","threadId":"24021","inReplyTo":"4C0EB7F1.1030707@pileofstuff.org","subject":"[PATCH 0/2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-10T11:47:22Z","receivedAt":"2010-06-10T11:47:22Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Andrew Sayers wrote:\n> +                                       case \"$p\" in\n> +                                               \\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n> +                                               *\\<*          ) p=\"<\"  ;;\n> +                                               *\\>*          ) p=\">\"  ;;\n> +                                               \"\"            ) p=\"=\"  ;;\n> +\n> +                                               # the following case shouldn't be possible\n> +                                               # if you see this, please report it as a bug\n> +                                               * ) p=\"?ERROR($p)?\" ;;\n> +\n> +                                       esac\n\nI didn't really like this bit, since rev-list has to format the output\nonly so you can match it.  I realized that I too have written code in\nthe past to detect which way this goes (in post-receive hooks), and/or\nthe number of commits as per the request\n\nJohn Tapsell wrote:\n> I hate to get all feature-bloat on you...\n> \n> But could it state the number of commits as well please? :) :)\n\nSo here's an additional patch to provide rev-list logic that supports\nthis feature.  I have then tweaked your original patch to make use of\nit a u+7-5 style.\n\nI'm not too picky about the exact style that it turns out to have in\nthe end; I have used my own customized version ever since we started\nprinting a space before the (master *+) dirtiness indicator.  However,\nI think we should try to be as unambiguous and short as possible.\nHence I picked the 'u' prefix to avoid ambiguity with the dirtiness\nindicator.\n\n\nAndrew Sayers (1):\n  bash completion: Support \"divergence from upstream\" warnings in\n    __git_ps1\n\nThomas Rast (1):\n  rev-list: introduce --count option\n\n Documentation/rev-list-options.txt     |    9 +++++\n builtin/rev-list.c                     |   16 +++++++++\n contrib/completion/git-completion.bash |   57 +++++++++++++++++++++++++++++++-\n revision.c                             |    2 +\n revision.h                             |    5 +++\n t/t6007-rev-list-cherry-pick-file.sh   |   29 ++++++++++++++++\n 6 files changed, 117 insertions(+), 1 deletions(-)\n"},{"id":"143420","messageId":"a1981bddc4deb4125824ecb02a914c2931543430.1276169807.git.trast@student.ethz.ch","threadId":"24021","inReplyTo":"cover.1276169807.git.trast@student.ethz.ch","subject":"[PATCH 1/2] rev-list: introduce --count option","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-10T11:47:23Z","receivedAt":"2010-06-10T11:47:23Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Add a --count option that, instead of actually listing the commits,\nmerely counts them.\n\nThis is mostly geared towards script use, and to this end it acts\nspecially when used with --left-right: it outputs the left and right\ncounts separately.  Previously, scripts would have to run a shell loop\nor small inline script over to achieve the same.  (Without\n--left-right, a simple |wc -l does the job.)\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n Documentation/rev-list-options.txt   |    9 +++++++++\n builtin/rev-list.c                   |   16 ++++++++++++++++\n revision.c                           |    2 ++\n revision.h                           |    5 +++++\n t/t6007-rev-list-cherry-pick-file.sh |   29 +++++++++++++++++++++++++++++\n 5 files changed, 61 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex b9fb7a8..066ade9 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -98,6 +98,15 @@ you would get an output like this:\n This implies the '--topo-order' option by default, but the\n '--date-order' option may also be specified.\n \n+ifdef::git-rev-list[]\n+--count::\n+\tPrint a number stating how many commits would have been\n+\tlisted, and suppress all other output.  When used together\n+\twith '--left-right', instead print the counts for left and\n+\tright commits, separated by a tab.\n+endif::git-rev-list[]\n+\n+\n ifndef::git-rev-list[]\n Diff Formatting\n ~~~~~~~~~~~~~~~\ndiff --git a/builtin/rev-list.c b/builtin/rev-list.c\nindex 51ceb19..efe9360 100644\n--- a/builtin/rev-list.c\n+++ b/builtin/rev-list.c\n@@ -50,6 +50,15 @@ static void show_commit(struct commit *commit, void *data)\n \n \tgraph_show_commit(revs->graph);\n \n+\tif (revs->count) {\n+\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\t\trevs->count_left++;\n+\t\telse\n+\t\t\trevs->count_right++;\n+\t\tfinish_commit(commit, data);\n+\t\treturn;\n+\t}\n+\n \tif (info->show_timestamp)\n \t\tprintf(\"%lu \", commit->date);\n \tif (info->header_prefix)\n@@ -400,5 +409,12 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t\t     quiet ? finish_object : show_object,\n \t\t\t     &info);\n \n+\tif (revs.count) {\n+\t\tif (revs.left_right)\n+\t\t\tprintf(\"%d\\t%d\\n\", revs.count_left, revs.count_right);\n+\t\telse\n+\t\t\tprintf(\"%d\\n\", revs.count_left + revs.count_right);\n+\t}\n+\n \treturn 0;\n }\ndiff --git a/revision.c b/revision.c\nindex b209d49..94fca7f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1146,6 +1146,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->boundary = 1;\n \t} else if (!strcmp(arg, \"--left-right\")) {\n \t\trevs->left_right = 1;\n+\t} else if (!strcmp(arg, \"--count\")) {\n+\t\trevs->count = 1;\n \t} else if (!strcmp(arg, \"--cherry-pick\")) {\n \t\trevs->cherry_pick = 1;\n \t\trevs->limited = 1;\ndiff --git a/revision.h b/revision.h\nindex 568f1c9..bafa728 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -57,6 +57,7 @@ struct rev_info {\n \t\t\tlimited:1,\n \t\t\tunpacked:1,\n \t\t\tboundary:2,\n+\t\t\tcount:1,\n \t\t\tleft_right:1,\n \t\t\trewrite_parents:1,\n \t\t\tprint_parents:1,\n@@ -131,6 +132,10 @@ struct rev_info {\n \n \t/* notes-specific options: which refs to show */\n \tstruct display_notes_opt notes_opt;\n+\n+\t/* commit counts */\n+\tint count_left;\n+\tint count_right;\n };\n \n #define REV_TREE_SAME\t\t0\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex 4b8611c..b565638 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -32,6 +32,23 @@ test_expect_success setup '\n \tgit tag B\n '\n \n+cat >expect <<EOF\n+<tags/B\n+>tags/C\n+EOF\n+\n+test_expect_success '--left-right' '\n+\tgit rev-list --left-right B...C > actual &&\n+\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\t\t< actual > actual.named &&\n+\ttest_cmp actual.named expect\n+'\n+\n+test_expect_success '--count' '\n+\tgit rev-list --count B...C > actual &&\n+\ttest \"$(cat actual)\" = 2\n+'\n+\n test_expect_success '--cherry-pick foo comes up empty' '\n \ttest -z \"$(git rev-list --left-right --cherry-pick B...C -- foo)\"\n '\n@@ -54,4 +71,16 @@ test_expect_success '--cherry-pick with independent, but identical branches' '\n \t\tHEAD...master -- foo)\"\n '\n \n+cat >expect <<EOF\n+1\t2\n+EOF\n+\n+# Insert an extra commit to break the symmetry\n+test_expect_success '--count --left-right' '\n+\tgit checkout branch &&\n+\ttest_commit D &&\n+\tgit rev-list --count --left-right B...D > actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n-- \n1.7.1.553.ge4d5c.dirty\n"},{"id":"143419","messageId":"a798e1b7f5ce3872a794829555c7295e588e2c61.1276169807.git.trast@student.ethz.ch","threadId":"24021","inReplyTo":"cover.1276169807.git.trast@student.ethz.ch","subject":"[PATCH 2/2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-10T11:47:24Z","receivedAt":"2010-06-10T11:47:24Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"From: Andrew Sayers <andrew-git@pileofstuff.org>\n\nAdd a notification in the command prompt specifying whether you're\nahead of or behind your upstream.  This is especially helpful in small\nteams that (forget to) push to each other very frequently.\n\nSupport git-svn upstream detection as a special case, as migraters from\ncentralised version control systems are especially likely to forget to push.\n\nSupport for other types of upstream than SVN should be easy to add if anyone is\nso inclined.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n contrib/completion/git-completion.bash |   57 +++++++++++++++++++++++++++++++-\n 1 files changed, 56 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex de5e6c1..49253a1 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -42,6 +42,14 @@\n #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n #       untracked files, then a '%' will be shown next to the branch name.\n #\n+#       If you would like to see the difference bitween HEAD and its\n+#       upstream, set GIT_PS1_SHOWUPSTREAM to a nonempty value.  The\n+#       difference will be shown as, e.g., \"u+7-5\" meaning that you\n+#       are 7 commits ahead of and 5 commits behind the upstream.  You\n+#       can enable git-svn mode by setting GIT_PS1_SHOWUPSTREAM=svn\n+#       and set the value per-repository with the bash.showUpstream\n+#       variable.\n+#\n # To submit patches:\n #\n #    *) Read Documentation/SubmittingPatches\n@@ -132,6 +140,7 @@ __git_ps1 ()\n \t\tlocal s\n \t\tlocal u\n \t\tlocal c\n+\t\tlocal p\n \n \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n@@ -159,10 +168,56 @@ __git_ps1 ()\n \t\t\t      u=\"%\"\n \t\t\t   fi\n \t\t\tfi\n+\n+\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n+\n+\t\t\t\t# Note: 'p' is used as a temporary throughout this block,\n+\t\t\t\t# before finally being assigned its correct value\n+\n+\t\t\t\tif p=\"$(git config --get bash.showUpstream)\"\n+\t\t\t\tthen\n+\t\t\t\t\tGIT_PS1_SHOWUPSTREAM=\"$p\"\n+\t\t\t\tfi\n+\n+\t\t\t\tlocal upstream\n+\n+\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n+\n+\t\t\t\t\t# git-svn upstream checking\n+\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n+\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n+\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n+\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n+\t\t\t\t\tupstream=${upstream%@*}\n+\t\t\t\t\tupstream=${upstream#*$p/}\n+\n+\t\t\t\telse # git upstream checking\n+\t\t\t\t\tupstream=\"@{upstream}\"\n+\t\t\t\tfi\n+\n+\t\t\t\tp=$(git rev-list --count --left-right \"$upstream\"...HEAD 2>/dev/null)\n+\t\t\t\tdebug_p=\"$p\"\n+\t\t\t\tcase \"$p\" in\n+\t\t\t\t\"0\t0\"|\"\") # empty means no --count support or no upstream\n+\t\t\t\t\tp=\n+\t\t\t\t\t;;\n+\t\t\t\t\"0\t\"*)\n+\t\t\t\t\tp=\"+${p#0\t}\"\n+\t\t\t\t\t;;\n+\t\t\t\t*\"\t0\")\n+\t\t\t\t\tp=\"-${p%\t0}\"\n+\t\t\t\t\t;;\n+\t\t\t\t*)\n+\t\t\t\t\tp=\"+${p#*\t}-${p%\t*}\"\n+\t\t\t\t\t;;\n+\t\t\t\tesac\n+\n+\t\t\tfi\n+\n \t\tfi\n \n \t\tlocal f=\"$w$i$s$u\"\n-\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r\"\n+\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r${p:+ u$p}\"\n \tfi\n }\n \n-- \n1.7.1.553.ge4d5c.dirty\n"},{"id":"143421","messageId":"201006101403.41754.trast@student.ethz.ch","threadId":"24021","inReplyTo":"4C0EB7F1.1030707@pileofstuff.org","subject":"Re: [RFC/PATCHv2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-10T12:03:41Z","receivedAt":"2010-06-10T12:03:41Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Andrew Sayers wrote:\n> +\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n> +\n> +\t\t\t\t\t# git-svn upstream checking\n> +\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n> +\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n> +\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n> +\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n> +\t\t\t\t\tupstream=${upstream%@*}\n> +\t\t\t\t\tupstream=${upstream#*$p/}\n\nThis appears to be tailored to --stdlayout, and sadly doesn't work in\nthe (probably fairly common) case of single-branch checkouts where\ngit-svn only puts a \"remotes/git-svn\" branch.\n\nI can't come up with any easy-but-robust method of checking that\nthough.  Perhaps it suffices to check that\n\n  git config 'svn-remote.svn.(branches|tags)'\n\ncomes up empty, and in this case simply use git-svn as the remote.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"143436","messageId":"4C10E921.1030909@drmicha.warpmail.net","threadId":"24021","inReplyTo":"cover.1276169807.git.trast@student.ethz.ch","subject":"Re: [PATCH 0/2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-10T13:31:13Z","receivedAt":"2010-06-10T13:31:13Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Thomas Rast venit, vidit, dixit 10.06.2010 13:47:\n> Andrew Sayers wrote:\n>> +                                       case \"$p\" in\n>> +                                               \\<*\\>*|\\>*\\<* ) p=\"<>\" ;;\n>> +                                               *\\<*          ) p=\"<\"  ;;\n>> +                                               *\\>*          ) p=\">\"  ;;\n>> +                                               \"\"            ) p=\"=\"  ;;\n>> +\n>> +                                               # the following case shouldn't be possible\n>> +                                               # if you see this, please report it as a bug\n>> +                                               * ) p=\"?ERROR($p)?\" ;;\n>> +\n>> +                                       esac\n> \n> I didn't really like this bit, since rev-list has to format the output\n> only so you can match it.  I realized that I too have written code in\n> the past to detect which way this goes (in post-receive hooks), and/or\n> the number of commits as per the request\n> \n> John Tapsell wrote:\n>> I hate to get all feature-bloat on you...\n>>\n>> But could it state the number of commits as well please? :) :)\n> \n> So here's an additional patch to provide rev-list logic that supports\n> this feature.  I have then tweaked your original patch to make use of\n> it a u+7-5 style.\n> \n> I'm not too picky about the exact style that it turns out to have in\n> the end; I have used my own customized version ever since we started\n> printing a space before the (master *+) dirtiness indicator.  However,\n> I think we should try to be as unambiguous and short as possible.\n> Hence I picked the 'u' prefix to avoid ambiguity with the dirtiness\n> indicator.\n> \n> \n> Andrew Sayers (1):\n>   bash completion: Support \"divergence from upstream\" warnings in\n>     __git_ps1\n> \n> Thomas Rast (1):\n>   rev-list: introduce --count option\n> \n>  Documentation/rev-list-options.txt     |    9 +++++\n>  builtin/rev-list.c                     |   16 +++++++++\n>  contrib/completion/git-completion.bash |   57 +++++++++++++++++++++++++++++++-\n>  revision.c                             |    2 +\n>  revision.h                             |    5 +++\n>  t/t6007-rev-list-cherry-pick-file.sh   |   29 ++++++++++++++++\n>  6 files changed, 117 insertions(+), 1 deletions(-)\n> \n\nChecked and tested. After setting DIFF, even the tests pass!\nBut we can probably do without the debug_p line ;)\n\nLiked-by: Michael J Gruber <git@drmicha.warpmail.net>\n"},{"id":"143540","messageId":"20100612000002.GA30196@neumann","threadId":"24021","inReplyTo":"a798e1b7f5ce3872a794829555c7295e588e2c61.1276169807.git.trast@student.ethz.ch","subject":"Re: [PATCH 2/2] bash completion: Support \"divergence from upstream\" warnings in __git_ps1","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-06-12T00:00:02Z","receivedAt":"2010-06-12T00:00:02Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi,\n\n\nOn Thu, Jun 10, 2010 at 01:47:24PM +0200, Thomas Rast wrote:\n> From: Andrew Sayers <andrew-git@pileofstuff.org>\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index de5e6c1..49253a1 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -42,6 +42,14 @@\n>  #       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're\n>  #       untracked files, then a '%' will be shown next to the branch name.\n>  #\n> +#       If you would like to see the difference bitween HEAD and its\n> +#       upstream, set GIT_PS1_SHOWUPSTREAM to a nonempty value.  The\n> +#       difference will be shown as, e.g., \"u+7-5\" meaning that you\n> +#       are 7 commits ahead of and 5 commits behind the upstream.  You\n> +#       can enable git-svn mode by setting GIT_PS1_SHOWUPSTREAM=svn\n> +#       and set the value per-repository with the bash.showUpstream\n> +#       variable.\n\nI find the last sentence of this description ambiguous.  What value\nshould bash.showUpstream be set to?  Do I really need to set both\nGIT_PS1_SHOWUPSTREAM and bash.showUpstream?  What if\nGIT_PS1_SHOWUPSTREAM=foo and bash.showUpstream=svn?\n\nFurthermore, I think it would be good to provide means to disable this\nfeature for some repositories while keeping it enabled for others.  In\nthe current version I could either disable or enable it globally.\nPerhaps we could disable it when bash.showUpstream is set to an empty\nvalue.\n\n> +#\n>  # To submit patches:\n>  #\n>  #    *) Read Documentation/SubmittingPatches\n> @@ -132,6 +140,7 @@ __git_ps1 ()\n>  \t\tlocal s\n>  \t\tlocal u\n>  \t\tlocal c\n> +\t\tlocal p\n>  \n>  \t\tif [ \"true\" = \"$(git rev-parse --is-inside-git-dir 2>/dev/null)\" ]; then\n>  \t\t\tif [ \"true\" = \"$(git rev-parse --is-bare-repository 2>/dev/null)\" ]; then\n> @@ -159,10 +168,56 @@ __git_ps1 ()\n>  \t\t\t      u=\"%\"\n>  \t\t\t   fi\n>  \t\t\tfi\n> +\n> +\t\t\tif [ -n \"${GIT_PS1_SHOWUPSTREAM-}\" ]; then\n> +\n> +\t\t\t\t# Note: 'p' is used as a temporary throughout this block,\n> +\t\t\t\t# before finally being assigned its correct value\n> +\n\nBack in the old days when I was just learning programming, I got my\nass kicked when I dared to reuse the same variable for different\npurposes.  C'mon, just how much shorter it is to create one more\nvariable than this two lines long comment?! ;)  It could even be\nsquashed together with the \"local upstream\" line.\n\n> +\t\t\t\tif p=\"$(git config --get bash.showUpstream)\"\n> +\t\t\t\tthen\n> +\t\t\t\t\tGIT_PS1_SHOWUPSTREAM=\"$p\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tlocal upstream\n> +\n> +\t\t\t\tif [ \"${GIT_PS1_SHOWUPSTREAM-}\" = \"svn\" ]; then\n\nNo need to use default value here, because GIT_PS1_SHOWUPSTREAM has\nalready been set above.\n\n> +\n> +\t\t\t\t\t# git-svn upstream checking\n> +\t\t\t\t\tp=\"$( git config --get svn-remote.svn.url )\"\n> +\t\t\t\t\tupstream=( $( git log --first-parent -1 \\\n> +\t\t\t\t\t\t--grep=\"^git-svn-id: $p\" ) )\n> +\t\t\t\t\tupstream=${upstream[ ${#upstream[@]} - 2 ]}\n> +\t\t\t\t\tupstream=${upstream%@*}\n> +\t\t\t\t\tupstream=${upstream#*$p/}\n> +\n\nUnnecessary empty lines before and after this block of code.\n\n> +\t\t\t\telse # git upstream checking\n> +\t\t\t\t\tupstream=\"@{upstream}\"\n> +\t\t\t\tfi\n> +\n> +\t\t\t\tp=$(git rev-list --count --left-right \"$upstream\"...HEAD 2>/dev/null)\n> +\t\t\t\tdebug_p=\"$p\"\n\nThe leftover debugging mentioned by Michael.\n\n> +\t\t\t\tcase \"$p\" in\n> +\t\t\t\t\"0\t0\"|\"\") # empty means no --count support or no upstream\n> +\t\t\t\t\tp=\n> +\t\t\t\t\t;;\n> +\t\t\t\t\"0\t\"*)\n> +\t\t\t\t\tp=\"+${p#0\t}\"\n> +\t\t\t\t\t;;\n> +\t\t\t\t*\"\t0\")\n> +\t\t\t\t\tp=\"-${p%\t0}\"\n> +\t\t\t\t\t;;\n> +\t\t\t\t*)\n> +\t\t\t\t\tp=\"+${p#*\t}-${p%\t*}\"\n> +\t\t\t\t\t;;\n> +\t\t\t\tesac\n> +\n> +\t\t\tfi\n> +\n>  \t\tfi\n\nUnnecessary empty lines before both fi.\n\n>  \n>  \t\tlocal f=\"$w$i$s$u\"\n> -\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r\"\n> +\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}${f:+ $f}$r${p:+ u$p}\"\n>  \tfi\n>  }\n>  \n> -- \n> 1.7.1.553.ge4d5c.dirty\n> \n> \n"}]}