{"thread":{"id":"9739","subject":"[PATCH] Improve bash prompt to detect merge / rebase in progress","startedAt":"2007-09-01T10:22:37Z","lastAt":"2007-10-01T18:29:37Z","messageCount":13,"participants":["Robin Rosenberg","Junio C Hamano","Shawn O. Pearce","Johannes Schindelin","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"52142","messageId":"11886421573285-git-send-email-robin.rosenberg@dewire.com","threadId":"9739","inReplyTo":null,"subject":"[PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-09-01T10:22:37Z","receivedAt":"2007-09-01T10:22:37Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n contrib/completion/git-completion.bash |   30 ++++++++++++++++++++++++++----\n 1 files changed, 26 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 5ed1821..1fef857 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -64,12 +64,34 @@ __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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\tr=\"|REBASEING\"\n+\t\telse\n+\t\t\tif [ -d \"$g/.dotest-merge\" ]\n+\t\t\tthen\n+\t\t\t\tr=\"|REBASING\"\n+\t\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\t\telse\n+\t\t\t\tif [ -f \"$g/MERGE_HEAD\" ]\n+\t\t\t\tthen\n+\t\t\t\t\tr=\"|MERGING\"\n+\t\t\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\t\telse\n+\t\t\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\t\tfi\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.3.rc7.844.gfd3c5\n"},{"id":"52150","messageId":"7vir6us1ia.fsf@gitster.siamese.dyndns.org","threadId":"9739","inReplyTo":"11886421573285-git-send-email-robin.rosenberg@dewire.com","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-01T18:07:25Z","receivedAt":"2007-09-01T18:07:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 5ed1821..1fef857 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -64,12 +64,34 @@ __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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n> +\t\t\tr=\"|REBASEING\"\n\nI might be in the middle of resolving a conflicted \"git am\".\n\nBut I love the idea.  We need to think about cleaning up our\n\"state machine\" mechanism to make this kind of thing easier to\ndo.  We've had a few suggestions on the list in the past but\nthey never passed the suggestion/speculation stage.\n"},{"id":"52154","messageId":"20070901222036.GH18160@spearce.org","threadId":"9739","inReplyTo":"7vir6us1ia.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-01T22:20:36Z","receivedAt":"2007-09-01T22:20:36Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n> >\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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n> > +\t\t\tr=\"|REBASEING\"\n> \n> I might be in the middle of resolving a conflicted \"git am\".\n\nAnd there's no way to tell the difference either.  I just spent a\nfew minutes digging around git-am and git-rebase and realized there\nreally isn't a way to tell these two user level commands apart as\ngit-rebase (by default) calls git-am and there's no marker to say\nit was started by rebase.\n\nBut more than that I have to wonder why git-am still uses .dotest\nin the working directory for its state management.  Why don't we\nmove it into $GIT_DIR like we do for `rebase -m`?\n\n> But I love the idea.  We need to think about cleaning up our\n> \"state machine\" mechanism to make this kind of thing easier to\n> do.  We've had a few suggestions on the list in the past but\n> they never passed the suggestion/speculation stage.\n\nI love the idea too.  I've actually walked away from a rebase -i and\ncome back the following day and forgotten that I was in the middle\nof a rebase and just thought I was sitting on a detached checkout.\nReally confused me for a few minutes when code I was looking for\nwasn't found (it was still pending to be applied by rebase -i).\n\n-- \nShawn.\n"},{"id":"52156","messageId":"Pine.LNX.4.64.0709020002010.28586@racer.site","threadId":"9739","inReplyTo":"7vir6us1ia.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-01T23:02:39Z","receivedAt":"2007-09-01T23:02:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 1 Sep 2007, Junio C Hamano wrote:\n\n> Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n> \n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index 5ed1821..1fef857 100755\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -64,12 +64,34 @@ __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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n> > +\t\t\tr=\"|REBASEING\"\n> \n> I might be in the middle of resolving a conflicted \"git am\".\n> \n> But I love the idea.  We need to think about cleaning up our\n> \"state machine\" mechanism to make this kind of thing easier to\n> do.  We've had a few suggestions on the list in the past but\n> they never passed the suggestion/speculation stage.\n\nLike your git-explain?\n\nI actually liked the idea.  Maybe we can get more people interested on \nthat thing post 1.5.3...\n\nCiao,\nDscho\n"},{"id":"52158","messageId":"200709020152.30070.robin.rosenberg@dewire.com","threadId":"9739","inReplyTo":"7vir6us1ia.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-09-01T23:52:28Z","receivedAt":"2007-09-01T23:52:28Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"lördag 01 september 2007 skrev Junio C Hamano:\n> Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n> \n> > diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> > index 5ed1821..1fef857 100755\n> > --- a/contrib/completion/git-completion.bash\n> > +++ b/contrib/completion/git-completion.bash\n> > @@ -64,12 +64,34 @@ __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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n> > +\t\t\tr=\"|REBASEING\"\n> \n> I might be in the middle of resolving a conflicted \"git am\".\n> \n> But I love the idea.  We need to think about cleaning up our\n> \"state machine\" mechanism to make this kind of thing easier to\n> do.  We've had a few suggestions on the list in the past but\n> they never passed the suggestion/speculation stage.\n\nI'd love to see that. The Eclipse plugin needs to know about such things\nin order to prevent the user from making errors he wouldn't like to do. We do\ncommit and checkouts without looking for these states now. Not too good.\n\nThe downside of improving the state machine is that we'll have to detect\nthe old AND the new states.\n\nHere's an ever better version which handles bisect and detached heads.\n\n-- robin\n\nFrom e5b2b9833786f13d729b7fead74297580b03f775 Mon Sep 17 00:00:00 2001\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\nDate: Sat, 1 Sep 2007 12:20:48 +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 5ed1821..048a715 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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\tr=\"|REBASING\"\n+\t\telse\n+\t\t\tif [ -d \"$g/.dotest-merge\" ]\n+\t\t\tthen\n+\t\t\t\tr=\"|REBASING\"\n+\t\t\t\tb=\"$(cat $g/.dotest-merge/head-name)\"\n+\t\t\telse\n+\t\t\t\tif [ -f \"$g/MERGE_HEAD\" ]\n+\t\t\t\tthen\n+\t\t\t\t\tr=\"|MERGING\"\n+\t\t\t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\t\telse\n+\t\t\t\t\tif [ -f $g/BISECT_LOG ]\n+\t\t\t\t\tthen\n+\t\t\t\t\t\tr=\"|BISECTING\"\n+\t\t\t\t\tfi\n+\t\t\t\t\tif ! b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\t\t\tthen\n+\t\t\t\t\t\tb=\"$(cut -c1-7 $g/HEAD)...\"\n+\t\t\t\t\tfi\n+\t\t\t\tfi\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.3.rc7.844.gfd3c5\n"},{"id":"52160","messageId":"Pine.LNX.4.64.0709020133540.28586@racer.site","threadId":"9739","inReplyTo":"20070901222036.GH18160@spearce.org","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-02T00:35:00Z","receivedAt":"2007-09-02T00:35:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 1 Sep 2007, Shawn O. Pearce wrote:\n\n> Junio C Hamano <gitster@pobox.com> wrote:\n> > Robin Rosenberg <robin.rosenberg@dewire.com> writes:\n> > >\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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n> > > +\t\t\tr=\"|REBASEING\"\n> > \n> > I might be in the middle of resolving a conflicted \"git am\".\n> \n> And there's no way to tell the difference either.\n\nAFAICT git-am creates an \"info\" file in .dotest/.\n\nAnd interactive rebase is detectable by the \"interactive\" file in \n.git/.dotest-merge/.\n\nCiao,\nDscho\n"},{"id":"52161","messageId":"20070902004407.GI18160@spearce.org","threadId":"9739","inReplyTo":"Pine.LNX.4.64.0709020133540.28586@racer.site","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-02T00:44:07Z","receivedAt":"2007-09-02T00:44:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Sat, 1 Sep 2007, Shawn O. Pearce wrote:\n> > Junio C Hamano <gitster@pobox.com> wrote:\n> > > \n> > > I might be in the middle of resolving a conflicted \"git am\".\n> > \n> > And there's no way to tell the difference either.\n> \n> AFAICT git-am creates an \"info\" file in .dotest/.\n\nBut git-rebase without -m and -i is defined as format-patch|am.\nSo when rebasing it looks identical to git-am.  Hence no way to\ntell the difference between the two.\n\nI think post 1.5.3 one of the things we should work on is trying\nto better track our current operation state.  Most of that would\nbe to refactor how we track state in things like rebase/am/merge.\n \n-- \nShawn.\n"},{"id":"52183","messageId":"20070902101825.1938C576FA@dx.sixt.local","threadId":"9739","inReplyTo":"200709020152.30070.robin.rosenberg@dewire.com","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-09-02T10:18:24Z","receivedAt":"2007-09-02T10:18:24Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Robin Rosenberg wrote:\n> +             if [ -d \"$g/../.dotest\" ]\n> +             then\n> +                     ...\n> +             else\n> +                     if [ -d \"$g/.dotest-merge\" ]\n> +                     then\n> +                             ...\n> +                     else\n> +                             if [ -f \"$g/MERGE_HEAD\" ]\n> +                             then\n> +                                     ...\n> +                             else\n> +                                     ...\n> +                             fi\n> +                     fi\n> +             fi\n\nYou can use 'elif' to avoid the increasing indentation.\n\n-- Hannes\n"},{"id":"52185","messageId":"200709021240.36807.robin.rosenberg@dewire.com","threadId":"9739","inReplyTo":"20070902101825.1938C576FA@dx.sixt.local","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-09-02T10:40:35Z","receivedAt":"2007-09-02T10:40:35Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"söndag 02 september 2007 skrev Johannes Sixt:\n> Robin Rosenberg wrote:\n> > +             if [ -d \"$g/../.dotest\" ]\n> > +             then\n> > +                     ...\n> > +             else\n> > +                     if [ -d \"$g/.dotest-merge\" ]\n> > +                     then\n> > +                             ...\n> > +                     else\n> > +                             if [ -f \"$g/MERGE_HEAD\" ]\n> > +                             then\n> > +                                     ...\n> > +                             else\n> > +                                     ...\n> > +                             fi\n> > +                     fi\n> > +             fi\n> \n> You can use 'elif' to avoid the increasing indentation.\n> \n> -- Hannes\n\nOfcourse :)\n\n-- robin\n\nFrom a0cce4fd418dc3ba715566980aa901dd12791b66 Mon Sep 17 00:00:00 2001\nFrom: Robin Rosenberg <robin.rosenberg@dewire.com>\nDate: Sat, 1 Sep 2007 12:20:48 +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 |   33 ++++++++++++++++++++++++++++---\n 1 files changed, 29 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 5ed1821..433be3a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -64,12 +64,37 @@ __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\tlocal b=\"$(git symbolic-ref HEAD 2>/dev/null)\"\n+\t\t\tr=\"|REBASING\"\n+\t\telif [ -d \"$g/.dotest-merge\" ]\n+\t\tthen\n+\t\t\tr=\"|REBASING\"\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\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.3\n"},{"id":"52407","messageId":"20070904071301.GA18160@spearce.org","threadId":"9739","inReplyTo":"200709021240.36807.robin.rosenberg@dewire.com","subject":"Re: [PATCH] Improve bash prompt to detect merge / rebase in progress","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-04T07:13:01Z","receivedAt":"2007-09-04T07:13:01Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Robin Rosenberg <robin.rosenberg@dewire.com> wrote:\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 \nWhat about this instead?\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex cad842a..41a558c 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\n-- \nShawn.\n"},{"id":"54385","messageId":"1191111645134-git-send-email-robin.rosenberg@dewire.com","threadId":"9739","inReplyTo":"20070904071301.GA18160@spearce.org","subject":"[PATCH] Improve bash prompt to detect various states like an unfinished merge","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-09-30T00:20:45Z","receivedAt":"2007-09-30T00:20:45Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"This 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\nThis includes Shawns improvements\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e760930..6854074 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.3.1.g80926\n"},{"id":"54457","messageId":"7vabr3tfmq.fsf@gitster.siamese.dyndns.org","threadId":"9739","inReplyTo":"1191111645134-git-send-email-robin.rosenberg@dewire.com","subject":"Re: [PATCH] Improve bash prompt to detect various states like an unfinished merge","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-10-01T08:15:25Z","receivedAt":"2007-10-01T08:15:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robin Rosenberg <robin.rosenberg@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\nSince you show the name of the branch anyway, I have to wonder\nwhy you should say BISECT.\n\nAlso if you know you normally get branch name, lack of branch\nname would indicate detached HEAD, I would presume.\n\nBut other state information may be helpful.\n"},{"id":"54500","messageId":"200710012029.38100.robin.rosenberg@dewire.com","threadId":"9739","inReplyTo":"7vabr3tfmq.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Improve bash prompt to detect various states like an unfinished merge","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2007-10-01T18:29:37Z","receivedAt":"2007-10-01T18:29:37Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"måndag 01 oktober 2007 skrev Junio C Hamano:\n> Robin Rosenberg <robin.rosenberg@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> Since you show the name of the branch anyway, I have to wonder\n> why you should say BISECT.\n\nYou can wonder around different branches while bisecting. The BISECT\npart is there to remind you that you are already doing bisecting, especially\nwhen being away from the prompt for a while. I did some mistakes without it.\n\n> Also if you know you normally get branch name, lack of branch\n> name would indicate detached HEAD, I would presume.\n\nYes, sure, but I like it better this way.\n\n> But other state information may be helpful.\n\nThis is an example script, so I'd say it's better to have a little too much \nand let people remve stuff they don't like in their personal copies.\n\n-- robin\n"}]}