{"thread":{"id":"19268","subject":"[PATCH 2/2] completion: enhance \"current branch\" display","startedAt":"2009-05-10T08:56:21Z","lastAt":"2009-05-10T21:18:18Z","messageCount":5,"participants":["Junio C Hamano","Johannes Sixt","Michal Nazarewicz","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"113451","messageId":"7vvdo91glm.fsf@alter.siamese.dyndns.org","threadId":"19268","inReplyTo":null,"subject":"[PATCH 2/2] completion: enhance \"current branch\" display","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-10T08:56:21Z","receivedAt":"2009-05-10T08:56:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Introduce GIT_PS1_DESCRIBE option you can set to \"contains\", \"branch\", or\n\"describe\" to tweak the way how a detached HEAD is described.\n\nThe default behaviour is to describe only exact match with some tag\n(otherwise use the first 7 hexdigits) as before.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I do not think the new modes based on name-rev (aka \"--contains\") are\n   much useful if you do your own development while on a detached HEAD,\n   but they probably are useful for tourists who sightsee.\n\n contrib/completion/git-completion.bash |   15 +++++++++++++--\n 1 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ccc7e0d..2490d5f 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -108,10 +108,21 @@ __git_ps1 ()\n \t\t\tfi\n \n \t\t\tb=\"$(git symbolic-ref HEAD 2>/dev/null)\" || {\n-\t\t\t\tb=\"$(git describe --exact-match HEAD 2>/dev/null)\" ||\n+\n+\t\t\t\tb=\"$(\n+\t\t\t\tcase \"${GIT_PS1_DESCRIBE_STYLE-}\" in\n+\t\t\t\t(contains)\n+\t\t\t\t\tgit describe --contains HEAD ;;\n+\t\t\t\t(branch)\n+\t\t\t\t\tgit describe --contains --all HEAD ;;\n+\t\t\t\t(describe)\n+\t\t\t\t\tgit describe HEAD ;;\n+\t\t\t\t(* | default)\n+\t\t\t\t\tgit describe --exact-match HEAD ;;\n+\t\t\t\tesac 2>/dev/null)\" ||\n+\n \t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n \t\t\t\tb=\"unknown\"\n-\n \t\t\t\tb=\"($b)\"\n \t\t\t}\n \t\tfi\n-- \n1.6.3.9.g6345d\n"},{"id":"113455","messageId":"200905101259.07175.j6t@kdbg.org","threadId":"19268","inReplyTo":"7vvdo91glm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] completion: enhance \"current branch\" display","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-05-10T10:59:07Z","receivedAt":"2009-05-10T10:59:07Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 10. Mai 2009, Junio C Hamano wrote:\n>  \t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n\nWhile you are here, you could turn this line into\n\n\t\t{ b=$(< \"$g/HEAD\") && b=${b:0:7}...; } 2>/dev/null ||\n\nto save a process. $(< foo) is a bash feature and does the same as $(cat foo), \nbut faster.\n\n-- Hannes\n"},{"id":"113456","messageId":"87my9lnqet.fsf@erwin.mina86.com","threadId":"19268","inReplyTo":"200905101259.07175.j6t@kdbg.org","subject":"Re: [PATCH 2/2] completion: enhance \"current branch\" display","fromName":"Michal Nazarewicz","fromEmail":"mina86@tlen.pl","sentAt":"2009-05-10T11:33:30Z","receivedAt":"2009-05-10T11:33:30Z","isPatch":true,"sender":{"key":"mina86@tlen.pl","avatar":"https://gravatar.com/avatar/55cbb4a7b7565c687a33afaee923bd3c05c46172519476bb1365631822278923?d=mp&s=160"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> On Sonntag, 10. Mai 2009, Junio C Hamano wrote:\n>>  \t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n>\n> While you are here, you could turn this line into\n>\n> \t\t{ b=$(< \"$g/HEAD\") && b=${b:0:7}...; } 2>/dev/null ||\n>\n> to save a process. $(< foo) is a bash feature and does the same as\n> $(cat foo), but faster.\n\nExcuse me this little cavil but how about something that works on other\nshells as well:\n\n{ read b <$g/HEAD && _b=${b#???????} && b=${b%\"$_b\"}... && unset _b }\n\n-- \nBest regards,                                         _     _\n .o. | Liege of Serenly Enlightened Majesty of      o' \\,=./ `o\n ..o | Computer Science,  Michal \"mina86\" Nazarewicz   (o o)\n ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--\n"},{"id":"113457","messageId":"200905101357.01959.j6t@kdbg.org","threadId":"19268","inReplyTo":"87my9lnqet.fsf@erwin.mina86.com","subject":"Re: [PATCH 2/2] completion: enhance \"current branch\" display","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-05-10T11:57:01Z","receivedAt":"2009-05-10T11:57:01Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 10. Mai 2009, Michal Nazarewicz wrote:\n> Johannes Sixt <j6t@kdbg.org> writes:\n> > On Sonntag, 10. Mai 2009, Junio C Hamano wrote:\n> >>  \t\t\t\tb=\"$(cut -c1-7 \"$g/HEAD\" 2>/dev/null)...\" ||\n> >\n> > While you are here, you could turn this line into\n> >\n> > \t\t{ b=$(< \"$g/HEAD\") && b=${b:0:7}...; } 2>/dev/null ||\n> >\n> > to save a process. $(< foo) is a bash feature and does the same as\n> > $(cat foo), but faster.\n>\n> Excuse me this little cavil but how about something that works on other\n> shells as well:\n>\n> { read b <$g/HEAD && _b=${b#???????} && b=${b%\"$_b\"}... && unset _b }\n\nBecause this is all about *bash* completion ;-)\n\n-- Hannes\n"},{"id":"113488","messageId":"20090510211818.GA30527@spearce.org","threadId":"19268","inReplyTo":"7vvdo91glm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] completion: enhance \"current branch\" display","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-05-10T21:18:18Z","receivedAt":"2009-05-10T21:18:18Z","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> Introduce GIT_PS1_DESCRIBE option you can set to \"contains\", \"branch\", or\n> \"describe\" to tweak the way how a detached HEAD is described.\n> \n> The default behaviour is to describe only exact match with some tag\n> (otherwise use the first 7 hexdigits) as before.\n> \n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> \n>  * I do not think the new modes based on name-rev (aka \"--contains\") are\n>    much useful if you do your own development while on a detached HEAD,\n>    but they probably are useful for tourists who sightsee.\n\nYea, both patches are sensible.\n\nIIRC the desire for name-rev was for detached HEAD in contexts\nlike what git submodule produce.  If you are sitting on a tagged\nversion in a submodule, its nice to see that in your prompt.\nSince you aren't developing there right now, there is no branch,\nand you are just sightseeing.\n\nThis feature may have started at my prior job, where we had our\nown git submodule like tool integrated with our build system,\nthat predated git submodule.  But its also still really useful\nwith say the Android Open Source Project, where users have 150 or\nso git repositories, all on detached HEADs, most pointing at an\nannotated tag.\n\n-- \nShawn.\n"}]}