{"thread":{"id":"11922","subject":"command prompt script for current branch","startedAt":"2008-02-06T19:52:56Z","lastAt":"2008-02-08T14:06:32Z","messageCount":16,"participants":["Stephen Sinclair","Junio C Hamano","Jakub Narebski","Robin Rosenberg","Mike Hommey","Shawn O. Pearce","Steffen Prohaska","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"67693","messageId":"9b3e2dc20802061152q63bc61acuaecf3f33d4df8b19@mail.gmail.com","threadId":"11922","inReplyTo":null,"subject":"command prompt script for current branch","fromName":"Stephen Sinclair","fromEmail":"radarsat1@gmail.com","sentAt":"2008-02-06T19:52:56Z","receivedAt":"2008-02-06T19:52:56Z","isPatch":false,"sender":{"key":"radarsat1@gmail.com","avatar":null},"body":"Hello,\n\nAttached is a script I quickly wrote up yesterday.  Sometimes I've\nfound I started working only to realize I was on the wrong branch.\n(Now that I'm accustomed to working with git, I make many small\nbranches, so it happens.)\n\nSo I made this small script to simply write the name of the currently\nchecked out branch, as well as information on how many commits it\ndiffers from the remote tracking branch, if any.\nIt also appends an exclamation mark if I have uncommitted changes.  I\nstuck it in my PS1 environment variable, so that it would be part of\nmy command prompt.\n\nI tried to choose git commands that would be relatively quick, since\nthis will be run for every single command prompt.  If I've chosen\nsuboptimal ways of doing this, please let me know.  There's a few too\nmany 'grep' and 'sed' commands for my liking, so maybe there is a way\nto get the same information more directly instead of parsing git\ncommand output.  Anyways, if it's of general interest, I'd be happy to\nmake a patch for /contrib.\n\nFor my tiny git repos, this seems to have pretty much no negative\nimpact on my work flow.  When I cd'd to my git.git clone there was\nabout a 1/2-second delay the first time, but subsequent command\nprompts incurred no visible delay.  I've no idea how fast it would be\nfor something as big as the kernel, for example.\n\nSteve\n"},{"id":"67706","messageId":"7vodatvmtl.fsf@gitster.siamese.dyndns.org","threadId":"11922","inReplyTo":"9b3e2dc20802061152q63bc61acuaecf3f33d4df8b19@mail.gmail.com","subject":"Re: command prompt script for current branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-06T20:42:30Z","receivedAt":"2008-02-06T20:42:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Stephen Sinclair\" <radarsat1@gmail.com> writes:\n\n> ...  Sometimes I've\n> found I started working only to realize I was on the wrong branch.\n\nSee contrib/completion/git-completion.bash if you are a bash user.\n"},{"id":"67712","messageId":"m3r6fp4wrt.fsf@localhost.localdomain","threadId":"11922","inReplyTo":"9b3e2dc20802061152q63bc61acuaecf3f33d4df8b19@mail.gmail.com","subject":"Re: command prompt script for current branch","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-06T21:09:50Z","receivedAt":"2008-02-06T21:09:50Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Stephen Sinclair\" <radarsat1@gmail.com> writes:\n\n> Attached is a script I quickly wrote up yesterday.  Sometimes I've\n> found I started working only to realize I was on the wrong branch.\n> (Now that I'm accustomed to working with git, I make many small\n> branches, so it happens.)\n\nFirst, it is much better to put such script inline, in the body of\nyour email.  This makes commenting about script body much easier.\nAnd if you have to attach it, for example because your mailer mangles\nwhitespace (which is not the case here), make sure that attachement\nuses \"text/plain\", and if possible \"inline\" disposition, to better\n_view_ the code without need to save it to temporary file.\n\nI would take an exeption and comment on your code, even though you\nmake it hard to do so.\n\n\nSecond, there are numerous examples on how to create git-aware\nprompt.  Those include code in contrib/completion/git-completion.bash\nin git sources:\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\nand the _git_ps1 file in sources of \"Git In Nutshell\", with git\nrepository at http://git.jonas.iki.fi/git_guides.git; this code\nby yours truly is heavily commented to make it easier to understand.\nI'm not sure if it is included in \"Git In Nutshell\" \n(http://jonas.iki.fi/git_guides).\n\nI have put the _git_ps1 code at the end of this post.\n\n> So I made this small script to simply write the name of the currently\n> checked out branch, as well as information on how many commits it\n> differs from the remote tracking branch, if any.\n> It also appends an exclamation mark if I have uncommitted changes.  I\n> stuck it in my PS1 environment variable, so that it would be part of\n> my command prompt.\n\nThird, the information on how many commits it differes from coupled\nremote tracking branch is not that fast to get; additionally you don't\nalways _have_ coupled remote tracking branch.  For me the number of\ncommits current branch differs from origin repo, and \"dirtiness\" of\nbranch are not important, while working with detached HEAD and marking\nbranches which are StGit controlled is.\n\n> -- >8 --\n> #!/bin/bash\n>\n> # exit if not a git repo\n> if ! (git branch >/dev/null 2>&1); then\n>     exit\n> fi\n\nThere are much better ways to do this; it is usually much better to\nuse plumbing (engine) commands in scripts, not porcelain, which is\nmeant for user interaction. See code in _git_ps1\n\nBesides, why do you run git-branch _twice_?\n \n> BRANCH=$(git branch | grep \\* | sed s,\\*\\ ,, )\n\nThere is much better way to do this with plumbing.\n\n> REMOTE=$(git config --list | grep branch.$BRANCH.remote 2>/dev/null | cut -f2 -d=)\n> MERGE=$(git config --list | grep branch.$BRANCH.merge 2>/dev/null | sed s,^.*=refs/heads/,,)\n\nWhy do you use \"git config --list\" then grep for key, instead of\nasking git-config to return results for given key with \n\"git config --get\" or \"git config --get-all\"?\n\nBy the way, when you use grep you should quote '.', as '.' means any\ncharacter in regular expression. You do not need put regular\nexpression (parameter to grep) in double quotes _only_ because\nrefnames (and branchnames) cannot contain spaces.\n\nYour code wouldn't be able to deal with being on detached HEAD.\n\n> # exit if no branch found\n> if [ \"${BRANCH}\"x == x ]; then\n>     exit\n> fi\n\nThis is mixture of coding for portability with bash-isms; either use\n'test' instead of '[', or use '-z' operator.\n\n> echo -n ' '[$BRANCH\n>\n> # dirty state\n> if [ \"$(git-diff-index --name-only HEAD)\"x != x ]; then\n>     echo -n \\!\n> fi\n\nErr... if you want to check if there are differences, it would be\nbetter to use '--quiet' (which implies '--exit-code') and check for\nexit code instead of checking if there was any output.\n\nBTW. there is slight inconsistency in using dashed (git-diff-index)\nand dashless (git branch) of diff commands.  In \"external\" script\nwhich does not source git shell script \"library\", it is better to use\ndashless form.\n \n> # exit if no remote tracking branch found\n> if [ ${REMOTE}x == x -a ${MERGE}x == x ]; then\n>     echo ]\n>     exit\n> fi\n> \n> # Uncomment this line to ignore remote tracking branches\n> # echo ]; exit\n> \n> # calc number of revs between remote and local\n> FWDREVS=$(git rev-list $REMOTE/$MERGE..$BRANCH 2>/dev/null 2>&1 | wc -l)\n> \n> # and the other way, in case it is not up to date\n> BACKREVS=$(git rev-list $BRANCH..$REMOTE/$MERGE 2>/dev/null 2>&1 | wc -l)\n> \n> echo -n ' '-\\> $REMOTE/$MERGE\n> \n> if [ $FWDREVS -gt 0 ]; then\n>     echo -n +$FWDREVS\n> fi\n> \n> if [ $BACKREVS -gt 0 ]; then\n>     echo -n -$BACKREVS\n> fi\n> \n> echo ]\n\nWhy do you use sequence of \"echo -n\", instead of setting variables,\nperhaps with the help of some more advanced constructs like in example\nbelow, then using one \"echo\" to output it all?\n\n-- >8 --\nfunction _git_ps1()\n{\n\t# 'git_dir' is absolute path to git repository\n\t# 'rel' is path relative to top dir in repository\n\t# 'br' is current branch name, or 'HEAD' if we are on detached HEAD\n\tlocal git_dir rel br\n\n\t# first call to git-rev-parse also checks if we are inside git\n\t# repository; if we are not in git repository, use default prompt,\n\t# provided as an argument\n\trel=$(git rev-parse --show-prefix 2>/dev/null) || \\\n\t\t{ echo \"$@\" ; return; }\n\trel=${rel%\\/}\n\n\t# get branch name, strip 'refs/heads/' prefix,\n\t# and use 'HEAD' for detached HEAD (no branch name)\n\tbr=$(git symbolic-ref HEAD 2>/dev/null)\n\tbr=${br#refs/heads/}\n\tbr=${br:-HEAD}\n\n\t# path to top dir of git repository\n\tloc=${PWD%/$rel}\n\n\t# the following code is important only if you use StGit,\n\t# to note if you are on StGit controlled branch;\n\t# use second part of conditional if you don't use StGit\n\tgit_dir=$(git rev-parse --git-dir)\n\tif [ \"$br\" -a -e \"$git_dir/patches/$br\" ]; then\n\t\techo \"$br:${loc/*\\/}${rel:+/$rel}# \"\n\telse \n\t\techo \"$br:${loc/*\\/}${rel:+/$rel}> \"\n\tfi\n}\n\n## bash:\n## set PS1 only if we are in interactive shell (PS1 is set)\n#    [ \"$PS1\" ] && PS1='$(_git_ps1 \"\\u@\\h:\\w> \")'\n\n## zsh:\n#\tfunction precmd() {\n#\t\tPS1=`_git_ps1 '%m:%~%# '`\n#\t}\n# vim:filetype=sh\n\n \n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"67717","messageId":"9b3e2dc20802061413v5dbe349axe43a4af263e39878@mail.gmail.com","threadId":"11922","inReplyTo":"m3r6fp4wrt.fsf@localhost.localdomain","subject":"Re: command prompt script for current branch","fromName":"Stephen Sinclair","fromEmail":"radarsat1@gmail.com","sentAt":"2008-02-06T22:13:12Z","receivedAt":"2008-02-06T22:13:12Z","isPatch":false,"sender":{"key":"radarsat1@gmail.com","avatar":null},"body":"> > Attached is a script I quickly wrote up yesterday.  Sometimes I've\n> > found I started working only to realize I was on the wrong branch.\n> > (Now that I'm accustomed to working with git, I make many small\n> > branches, so it happens.)\n>\n> First, it is much better to put such script inline, in the body of\n> your email.  This makes commenting about script body much easier.\n> And if you have to attach it, for example because your mailer mangles\n> whitespace (which is not the case here), make sure that attachement\n> uses \"text/plain\", and if possible \"inline\" disposition, to better\n> _view_ the code without need to save it to temporary file.\n>\n> I would take an exeption and comment on your code, even though you\n> make it hard to do so.\n\nThank you.  Since there's already a solution for this in contrib,\n(didn't see it, sorry), I'll just take your recommendations on coding\nstyle for any future stuff I do.\n\n\nSteve\n"},{"id":"67718","messageId":"200802062314.39440.robin.rosenberg.lists@dewire.com","threadId":"11922","inReplyTo":"7vodatvmtl.fsf@gitster.siamese.dyndns.org","subject":"[PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-02-06T22:14:38Z","receivedAt":"2008-02-06T22:14:38Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Hi Junio,\n\nI'm not sure whether you didn't like it or not or just lost it. Here\nis the vastly enhanced prompt again, rebased.\n\n-- robin\n\n>From 76aa8bae8491c1ffbd6e3f5c99ab014ef87794c8 Mon Sep 17 00:00:00 2001\nFrom: Shawn O. Pearce <spearce@spearce.org>\nDate: Tue, 4 Sep 2007 03:13:01 -0400\nSubject: \n\nThis patch makes the git prompt (when enabled) show if a merge or a\nrebase is unfinished. It also detects if a bisect is being done as\nwell as detached checkouts.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n contrib/completion/git-completion.bash |   37 ++++++++++++++++++++++++++++---\n 1 files changed, 33 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0d33f9a..4ea727b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -64,12 +64,41 @@ __gitdir ()\n \n __git_ps1 ()\n {\n-\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n-\tif [ -n \"$b\" ]; then\n+\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n+\tif [ -n \"$g\" ]; then\n+\t\tlocal r\n+\t\tlocal b\n+\t\tif [ -d \"$g/../.dotest\" ]\n+\t\tthen\n+\t\t\tr=\"|AM/REBASE\"\n+\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\telif [ -f \"$g/.dotest-merge/interactive\" ]\n+\t\tthen\n+\t\t\tr=\"|REBASE-i\"\n+\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\telif [ -d \"$g/.dotest-merge\" ]\n+\t\tthen\n+\t\t\tr=\"|REBASE-m\"\n+\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\telif [ -f \"$g/MERGE_HEAD\" ]\n+\t\tthen\n+\t\t\tr=\"|MERGING\"\n+\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\telse\n+\t\t\tif [ -f $g/BISECT_LOG ]\n+\t\t\tthen\n+\t\t\t\tr=\"|BISECTING\"\n+\t\t\tfi\n+\t\t\tif ! b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\tthen\n+\t\t\t\tb=\"$(cut -c1-7 $g/HEAD)...\"\n+\t\t\tfi\n+\t\tfi\n+\n \t\tif [ -n \"$1\" ]; then\n-\t\t\tprintf \"$1\" \"${b##refs/heads/}\"\n+\t\t\tprintf \"$1\" \"${b##refs/heads/}$r\"\n \t\telse\n-\t\t\tprintf \" (%s)\" \"${b##refs/heads/}\"\n+\t\t\tprintf \" (%s)\" \"${b##refs/heads/}$r\"\n \t\tfi\n \tfi\n }\n-- \n1.5.4.rc4.25.g81cc\n"},{"id":"67722","messageId":"200802062323.15995.robin.rosenberg.lists@dewire.com","threadId":"11922","inReplyTo":"200802062314.39440.robin.rosenberg.lists@dewire.com","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-02-06T22:23:14Z","receivedAt":"2008-02-06T22:23:14Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"\nActually I wrote the patch and Shawn sent back a sligtly better version,\ni.e.:\n\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\n\n-- robin\n"},{"id":"67723","messageId":"7vodatu37m.fsf@gitster.siamese.dyndns.org","threadId":"11922","inReplyTo":"200802062314.39440.robin.rosenberg.lists@dewire.com","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-06T22:31:25Z","receivedAt":"2008-02-06T22:31:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:\n\n> I'm not sure whether you didn't like it or not or just lost it. Here\n> is the vastly enhanced prompt again, rebased.\n\nMost likely \"lost\", and I appreciate a reminder like this.\n\n> From 76aa8bae8491c1ffbd6e3f5c99ab014ef87794c8 Mon Sep 17 00:00:00 2001\n> From: Shawn O. Pearce <spearce@spearce.org>\n> Date: Tue, 4 Sep 2007 03:13:01 -0400\n> Subject: \n>\n> This patch makes the git prompt (when enabled) show if a merge or a\n> rebase is unfinished. It also detects if a bisect is being done as\n> well as detached checkouts.\n>\n> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n\nBut this looks funny, without Subject: and also S-o-b by the\noriginal author (if Shawn is indeed the original author).  It\nappears that the patch originally was from Shawn and after\ndiscussion petered out around Oct 1st 2007 there wasn't a resend\nfor inclusion.  Is this improved/revised in any way from the one\nin the thread?\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/57271/focus=57536\n"},{"id":"67728","messageId":"200802062356.41548.jnareb@gmail.com","threadId":"11922","inReplyTo":"9b3e2dc20802061413v5dbe349axe43a4af263e39878@mail.gmail.com","subject":"Re: command prompt script for current branch","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-06T22:56:41Z","receivedAt":"2008-02-06T22:56:41Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Wed, 6 Feb 2008, Stephen Sinclair wrote:\n\nPlease provide attribution (who write what) when quoting, like\nbelow:\n\n> Jakub Narebski wrote:\n>> \"Stephen Sinclair\" <radarsat1@gmail.com> writes:\n\n>>> Attached is a script I quickly wrote up yesterday.  Sometimes I've\n>>> found I started working only to realize I was on the wrong branch.\n>>> (Now that I'm accustomed to working with git, I make many small\n>>> branches, so it happens.)\n>>\n>> First, it is much better to put such script inline, in the body of\n>> your email.  This makes commenting about script body much easier.\n>> And if you have to attach it, for example because your mailer mangles\n>> whitespace (which is not the case here), make sure that attachement\n>> uses \"text/plain\", and if possible \"inline\" disposition, to better\n>> _view_ the code without need to save it to temporary file.\n>>\n>> I would take an exeption and comment on your code, even though you\n>> make it hard to do so.\n> \n> Thank you.  Since there's already a solution for this in contrib,\n> (didn't see it, sorry), I'll just take your recommendations on coding\n> style for any future stuff I do.\n\nFirst, the code in contrib doesn't do all your code did. It doesn't\nshow if workarea is \"dirty\" (although I'm not sure if this is very\nuseful), nor does it show number of commits since or to mainline\n(origin) version, although with working on (with) feature/topic\nbranches which does not have corresponding remote tracking branch\nit seems not useful.\n\nOn the other hand code in _git_ps1 (taken from one of the \"git prompt\"\nposts floating on git mailing list, and available in archives, together\nwith /usr/share/stgit/contrib/stgbashprompt.sh from StGit, Quilt-like\npatch management layer on top of Git) shows also name of repository\nand path in repository, and also if the branch is managed by StGit.\n\n\nSecond, I think you have learned something. Both on rules regarding\ndiscussion, netiquette and sending contributions on this mailing list,\nand about how to write scripts for/around git.  (At least I hope so).\n\n-- \nJakub Narebski\nPoland\n"},{"id":"67730","messageId":"m3myqd4qo2.fsf@localhost.localdomain","threadId":"11922","inReplyTo":"200802062314.39440.robin.rosenberg.lists@dewire.com","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-02-06T23:21:40Z","receivedAt":"2008-02-06T23:21:40Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:\n\n> This patch makes the git prompt (when enabled) show if a merge or a\n> rebase is unfinished. It also detects if a bisect is being done as\n> well as detached checkouts.\n[...]\n> +\t\tif [ -d \"$g/../.dotest\" ]\n[...]\n> +\t\telif [ -f \"$g/.dotest-merge/interactive\" ]\n[...]\n> +\t\telif [ -d \"$g/.dotest-merge\" ]\n\nHmmm... is it time to ressurect \"git explain\" / \"git info\" / \"git state\"\ncommand idea, as to not need to harcode info about state in scripts,\nputting it in only one place?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"67732","messageId":"20080206234448.GA18269@glandium.org","threadId":"11922","inReplyTo":"m3myqd4qo2.fsf@localhost.localdomain","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-02-06T23:44:48Z","receivedAt":"2008-02-06T23:44:48Z","isPatch":true,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Wed, Feb 06, 2008 at 03:21:40PM -0800, Jakub Narebski wrote:\n> Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:\n> \n> > This patch makes the git prompt (when enabled) show if a merge or a\n> > rebase is unfinished. It also detects if a bisect is being done as\n> > well as detached checkouts.\n> [...]\n> > +\t\tif [ -d \"$g/../.dotest\" ]\n> [...]\n> > +\t\telif [ -f \"$g/.dotest-merge/interactive\" ]\n> [...]\n> > +\t\telif [ -d \"$g/.dotest-merge\" ]\n> \n> Hmmm... is it time to ressurect \"git explain\" / \"git info\" / \"git state\"\n> command idea, as to not need to harcode info about state in scripts,\n> putting it in only one place?\n\nMaybe git status could deal with that job.\n\nMike\n"},{"id":"67738","messageId":"200802070123.43109.robin.rosenberg.lists@dewire.com","threadId":"11922","inReplyTo":"7vodatu37m.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-02-07T00:23:42Z","receivedAt":"2008-02-07T00:23:42Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"onsdagen den 6 februari 2008 skrev Junio C Hamano:\n> Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:\n> \n> > I'm not sure whether you didn't like it or not or just lost it. Here\n> > is the vastly enhanced prompt again, rebased.\n> \n> Most likely \"lost\", and I appreciate a reminder like this.\n> \n> > From 76aa8bae8491c1ffbd6e3f5c99ab014ef87794c8 Mon Sep 17 00:00:00 2001\n> > From: Shawn O. Pearce <spearce@spearce.org>\n> > Date: Tue, 4 Sep 2007 03:13:01 -0400\n> > Subject: \n> >\n> > This patch makes the git prompt (when enabled) show if a merge or a\n> > rebase is unfinished. It also detects if a bisect is being done as\n> > well as detached checkouts.\n> >\n> > Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n> \n> But this looks funny, without Subject: and also S-o-b by the\n> original author (if Shawn is indeed the original author).  It\n> appears that the patch originally was from Shawn and after\n> discussion petered out around Oct 1st 2007 there wasn't a resend\n> for inclusion.  Is this improved/revised in any way from the one\n> in the thread?\nNo.\n\nI sent a patch and Shawn modified it somewhat and posted the full modified\npatch. Here is the same patch again (to make sure you get the right one). It\nhas a better comment than the one I sent recently.\n\n-- robin\n\n>From 82a5b8d5b043ffc7c1950b391ec7ae69d575640b Mon Sep 17 00:00:00 2001\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\nDate: Sun, 30 Sep 2007 02:20:45 +0200\nSubject: [PATCH] Improve bash prompt to detect various states like an unfinished merge\n\nThis patch makes the git prompt (when enabled) show if a merge or a\nrebase is unfinished. It also detects if a bisect is being done as\nwell as detached checkouts.\n\nAn uncompleted git-am cannot be distinguised from a rebase (the\nnon-interactive version). Instead of having an even longer prompt\nwe simply ignore that and hope the power users that use git-am knows\nthe difference.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n contrib/completion/git-completion.bash |   37 ++++++++++++++++++++++++++++---\n 1 files changed, 33 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 0d33f9a..4ea727b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -64,12 +64,41 @@ __gitdir ()\n \n __git_ps1 ()\n {\n-\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n-\tif [ -n \"$b\" ]; then\n+\tlocal g=\"$(git rev-parse --git-dir 2>/dev/null)\"\n+\tif [ -n \"$g\" ]; then\n+\t\tlocal r\n+\t\tlocal b\n+\t\tif [ -d \"$g/../.dotest\" ]\n+\t\tthen\n+\t\t\tr=\"|AM/REBASE\"\n+\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\telif [ -f \"$g/.dotest-merge/interactive\" ]\n+\t\tthen\n+\t\t\tr=\"|REBASE-i\"\n+\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\telif [ -d \"$g/.dotest-merge\" ]\n+\t\tthen\n+\t\t\tr=\"|REBASE-m\"\n+\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\telif [ -f \"$g/MERGE_HEAD\" ]\n+\t\tthen\n+\t\t\tr=\"|MERGING\"\n+\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\telse\n+\t\t\tif [ -f $g/BISECT_LOG ]\n+\t\t\tthen\n+\t\t\t\tr=\"|BISECTING\"\n+\t\t\tfi\n+\t\t\tif ! b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\tthen\n+\t\t\t\tb=\"$(cut -c1-7 $g/HEAD)...\"\n+\t\t\tfi\n+\t\tfi\n+\n \t\tif [ -n \"$1\" ]; then\n-\t\t\tprintf \"$1\" \"${b##refs/heads/}\"\n+\t\t\tprintf \"$1\" \"${b##refs/heads/}$r\"\n \t\telse\n-\t\t\tprintf \" (%s)\" \"${b##refs/heads/}\"\n+\t\t\tprintf \" (%s)\" \"${b##refs/heads/}$r\"\n \t\tfi\n \tfi\n }\n-- \n1.5.4.rc4.25.g81cc\n"},{"id":"67756","messageId":"20080207063412.GQ24004@spearce.org","threadId":"11922","inReplyTo":"200802070123.43109.robin.rosenberg.lists@dewire.com","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-02-07T06:34:12Z","receivedAt":"2008-02-07T06:34:12Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n> I sent a patch and Shawn modified it somewhat and posted the full modified\n> patch. Here is the same patch again (to make sure you get the right one). It\n> has a better comment than the one I sent recently.\n> \n> -- robin\n> \n> From 82a5b8d5b043ffc7c1950b391ec7ae69d575640b Mon Sep 17 00:00:00 2001\n> From: Robin Rosenberg <robin.rosenberg@dewire.com>\n> Date: Sun, 30 Sep 2007 02:20:45 +0200\n> Subject: [PATCH] Improve bash prompt to detect various states like an unfinished merge\n> \n> This patch makes the git prompt (when enabled) show if a merge or a\n> rebase is unfinished. It also detects if a bisect is being done as\n> well as detached checkouts.\n> \n> An uncompleted git-am cannot be distinguised from a rebase (the\n> non-interactive version). Instead of having an even longer prompt\n> we simply ignore that and hope the power users that use git-am knows\n> the difference.\n> \n> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n\nFor what it's worth:\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n-- \nShawn.\n"},{"id":"67932","messageId":"F19A1227-3803-4C23-BEA2-26F23824ACF5@zib.de","threadId":"11922","inReplyTo":"20080207063412.GQ24004@spearce.org","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-02-08T11:26:01Z","receivedAt":"2008-02-08T11:26:01Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Feb 7, 2008, at 7:34 AM, Shawn O. Pearce wrote:\n\n> Robin Rosenberg <robin.rosenberg.lists@dewire.com> wrote:\n>> I sent a patch and Shawn modified it somewhat and posted the full  \n>> modified\n>> patch. Here is the same patch again (to make sure you get the  \n>> right one). It\n>> has a better comment than the one I sent recently.\n>>\n>> -- robin\n>>\n>> From 82a5b8d5b043ffc7c1950b391ec7ae69d575640b Mon Sep 17 00:00:00  \n>> 2001\n>> From: Robin Rosenberg <robin.rosenberg@dewire.com>\n>> Date: Sun, 30 Sep 2007 02:20:45 +0200\n>> Subject: [PATCH] Improve bash prompt to detect various states like  \n>> an unfinished merge\n>>\n>> This patch makes the git prompt (when enabled) show if a merge or a\n>> rebase is unfinished. It also detects if a bisect is being done as\n>> well as detached checkouts.\n>>\n>> An uncompleted git-am cannot be distinguised from a rebase (the\n>> non-interactive version). Instead of having an even longer prompt\n>> we simply ignore that and hope the power users that use git-am knows\n>> the difference.\n>>\n>> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n>\n> For what it's worth:\n>\n> Acked-by: Shawn O. Pearce <spearce@spearce.org>\n\nThis improved prompt is great.  I already miss it each time I switch\nback from next to master.\n\n\tSteffen\n"},{"id":"67941","messageId":"alpine.LSU.1.00.0802081224210.11591@racer.site","threadId":"11922","inReplyTo":"F19A1227-3803-4C23-BEA2-26F23824ACF5@zib.de","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-08T12:25:39Z","receivedAt":"2008-02-08T12:25:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 8 Feb 2008, Steffen Prohaska wrote:\n\n> This improved prompt is great.  I already miss it each time I switch \n> back from next to master.\n\nMaybe we (as in msysgit) should install the git-completion.bash script \ninto /share/git-core/?\n\nCiao,\nDscho\n"},{"id":"67942","messageId":"E3983D26-5DAC-48CE-A261-7C424FCB2D64@zib.de","threadId":"11922","inReplyTo":"alpine.LSU.1.00.0802081224210.11591@racer.site","subject":"Re: [PATCH (repost)] Improve bash prompt to detect merge / rebase in progress","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-02-08T13:12:49Z","receivedAt":"2008-02-08T13:12:49Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Feb 8, 2008, at 1:25 PM, Johannes Schindelin wrote:\n\n> On Fri, 8 Feb 2008, Steffen Prohaska wrote:\n>\n>> This improved prompt is great.  I already miss it each time I switch\n>> back from next to master.\n>\n> Maybe we (as in msysgit) should install the git-completion.bash script\n> into /share/git-core/?\n\nYes.\n\n\tSteffen\n"},{"id":"67948","messageId":"alpine.LSU.1.00.0802081405280.11591@racer.site","threadId":"11922","inReplyTo":"E3983D26-5DAC-48CE-A261-7C424FCB2D64@zib.de","subject":"[PATCH/RFC] Make git-completion.bash a first-class citizen","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-08T14:06:32Z","receivedAt":"2008-02-08T14:06:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis moves git-completion.bash out of contrib/, and installs it to\n$sharedir/git-completion/\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tOn Fri, 8 Feb 2008, Steffen Prohaska wrote:\n\t\n\t> On Feb 8, 2008, at 1:25 PM, Johannes Schindelin wrote:\n\t> \n\t> > On Fri, 8 Feb 2008, Steffen Prohaska wrote:\n\t> > \n\t> > > This improved prompt is great.  I already miss it each time \n\t> > > I switch back from next to master.\n\t> > \n\t> > Maybe we (as in msysgit) should install the \n\t> > git-completion.bash script into /share/git-core/?\n\t> \n\t> Yes.\n\n\tHow about this?\n\n Makefile                                           |    4 ++++\n .../git-completion.bash => git-completion.bash     |    0 \n 2 files changed, 4 insertions(+), 0 deletions(-)\n rename contrib/completion/git-completion.bash => git-completion.bash (100%)\n\ndiff --git a/Makefile b/Makefile\nindex de8c752..77efc3f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -168,6 +168,7 @@ gitexecdir = $(bindir)\n sharedir = $(prefix)/share\n template_dir = $(sharedir)/git-core/templates\n htmldir=$(sharedir)/doc/git-doc\n+completiondir = $(sharedir)/git-completion\n ifeq ($(prefix),/usr)\n sysconfdir = /etc\n else\n@@ -784,6 +785,7 @@ bindir_SQ = $(subst ','\\'',$(bindir))\n mandir_SQ = $(subst ','\\'',$(mandir))\n infodir_SQ = $(subst ','\\'',$(infodir))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+completiondir_SQ = $(subst ','\\'',$(completiondir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_SQ = $(subst ','\\'',$(htmldir))\n prefix_SQ = $(subst ','\\'',$(prefix))\n@@ -1067,6 +1069,8 @@ install: all\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n \t$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n \t$(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'\n+\t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(completiondir_SQ)'\n+\t$(INSTALL) git-completion.bash '$(DESTDIR_SQ)$(completiondir_SQ)'\n \t$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install\n \t$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install\n ifndef NO_TCLTK\ndiff --git a/contrib/completion/git-completion.bash b/git-completion.bash\nsimilarity index 100%\nrename from contrib/completion/git-completion.bash\nrename to git-completion.bash\n-- \n1.5.4.1261.g18335\n"}]}