{"thread":{"id":"21686","subject":"[PATCH] bash completion: add space between branch name and status flags","startedAt":"2009-11-20T12:09:16Z","lastAt":"2010-01-06T11:59:01Z","messageCount":7,"participants":["Roman Fietze","Junio C Hamano","Nanako Shiraishi","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128011","messageId":"200911201309.16193.roman.fietze@telemotive.de","threadId":"21686","inReplyTo":null,"subject":"[PATCH] bash completion: add space between branch name and status flags","fromName":"Roman Fietze","fromEmail":"roman.fietze@telemotive.de","sentAt":"2009-11-20T12:09:16Z","receivedAt":"2009-11-20T12:09:16Z","isPatch":true,"sender":{"key":"roman.fietze@telemotive.de","avatar":null},"body":"Hello Shawn, hello git list members,\n\nWouldn't it improve the readability of the bash prompt, if there would\nbe a space between the branch name and the status flags (dirty, stash,\nuntracked)?\n\nSigned-off-by: Roman Fietze <roman.fietze@telemotive.de>\n---\n contrib/completion/git-completion.bash |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-\ncompletion.bash\nindex bd66639..407176b 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -169,10 +169,12 @@ __git_ps1 ()\n \t\t\tfi\n \t\tfi\n \n+\t\tlocal f=\"$w$i$s$u$r\"\n+\t\tf=${f:+ $f}\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/}$f\"\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/}$f\"\n \t\tfi\n \tfi\n }\n-- \n1.6.4.2\n\n\nRoman\n\n-- \nRoman Fietze                Telemotive AG Büro Mühlhausen\nBreitwiesen                              73347 Mühlhausen\nTel.: +49(0)7335/18493-45        http://www.telemotive.de\n"},{"id":"128030","messageId":"7v4oopxeuf.fsf@alter.siamese.dyndns.org","threadId":"21686","inReplyTo":"200911201309.16193.roman.fietze@telemotive.de","subject":"Re: [PATCH] bash completion: add space between branch name and status flags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-20T17:53:28Z","receivedAt":"2009-11-20T17:53:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Roman Fietze <roman.fietze@telemotive.de> writes:\n\n> Hello Shawn, hello git list members,\n>\n> Wouldn't it improve the readability of the bash prompt, if there would\n> be a space between the branch name and the status flags (dirty, stash,\n> untracked)?\n\nPerhaps.\n\n> Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>\n> ---\n>  contrib/completion/git-completion.bash |    6 ++++--\n>  1 files changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-\n> completion.bash\n> index bd66639..407176b 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -169,10 +169,12 @@ __git_ps1 ()\n>  \t\t\tfi\n>  \t\tfi\n>  \n> +\t\tlocal f=\"$w$i$s$u$r\"\n\nI think this line and the two changes to printf below is a big improvement\n(unless we are using f for something else---I didn't look).  But I think\nthe next line is wrong.\n\n> +\t\tf=${f:+ $f}\n\nThe $r string is designed to be used as suffix from the beginning and\nalways has \"|\" in front of it as a delimiter, so if there is no w/i/s/u\n(and I suspect many people do not use GIT_PS1_SHOWDIRTYSTATE and friends,\nand these are _always_ empty for them) the above will begin with \"|\".\nThere is no need to steal one column from a typeable width from the\ncommand line in such a case.\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/}$f\"\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/}$f\"\n>  \t\tfi\n>  \tfi\n>  }\n\nTo implement your stated goal (dirty/stash/untracked), you probably want\nto do this instead...\n\n\tlocal f=\"$w$i$s$u\"\n        f=\"${f:+ $f}$r\"\n"},{"id":"130553","messageId":"20091230224129.6117@nanako3.lavabit.com","threadId":"21686","inReplyTo":"7v4oopxeuf.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] bash completion: add space between branch name and status flags","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-30T13:41:29Z","receivedAt":"2009-12-30T13:41:29Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Junio, could you tell us what happened to this thread?\n\nIn response to a patch from Roman Fietze to outline a better way\nto do it.  Nothing happened.\n"},{"id":"130561","messageId":"20091230145751.GE6914@spearce.org","threadId":"21686","inReplyTo":"20091230224129.6117@nanako3.lavabit.com","subject":"Re: [PATCH] bash completion: add space between branch name and status flags","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-30T14:57:51Z","receivedAt":"2009-12-30T14:57:51Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> Junio, could you tell us what happened to this thread?\n> \n> In response to a patch from Roman Fietze to outline a better way\n> to do it.  Nothing happened.\n\nJunio responded with a suggestion on how to improve the patch when\nGIT_PS1_SHOWDIRTYSTATE was not set, but Roman Fietze didn't send\na revised patch, so it got dropped.\n\nHere is the revised patch, Junio, still think its a good idea?\n\n--8<--\nFrom: Roman Fietze <roman.fietze@telemotive.de>\nSubject: [PATCH] bash completion: add space between branch name and status flags\n\nImprove the readability of the bash prompt by adding a space between\nthe branch name and the status flags (dirty, stash, untracked).\n\nSigned-off-by: Roman Fietze <roman.fietze@telemotive.de>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex fbfa5f2..3c8b6df 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -163,10 +163,12 @@ __git_ps1 ()\n \t\t\tfi\n \t\tfi\n \n+\t\tlocal f=\"$w$i$s$u\"\n+\t\tf=\"${f:+ $f}$r\"\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/}$f\"\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/}$f\"\n \t\tfi\n \tfi\n }\n-- \n1.6.6.307.gba67\n\n\n-- \nShawn.\n"},{"id":"130573","messageId":"7veimc1cv6.fsf@alter.siamese.dyndns.org","threadId":"21686","inReplyTo":"20091230145751.GE6914@spearce.org","subject":"Re: [PATCH] bash completion: add space between branch name and status flags","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-30T19:27:25Z","receivedAt":"2009-12-30T19:27:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Nanako Shiraishi <nanako3@lavabit.com> wrote:\n>> Junio, could you tell us what happened to this thread?\n>> \n>> In response to a patch from Roman Fietze to outline a better way\n>> to do it.  Nothing happened.\n>\n> Junio responded with a suggestion on how to improve the patch when\n> GIT_PS1_SHOWDIRTYSTATE was not set, but Roman Fietze didn't send\n> a revised patch, so it got dropped.\n>\n> Here is the revised patch, Junio, still think its a good idea?\n\nThanks for following up.\n\nAs I don't use $[wisu] myself, I don't have a very strong opinion either\nway, but the user has spent cycles to compute them, so we'd better present\nthem in a way that is easier to read, I guess.\n\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index fbfa5f2..3c8b6df 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -163,10 +163,12 @@ __git_ps1 ()\n>  \t\t\tfi\n>  \t\tfi\n>  \n> +\t\tlocal f=\"$w$i$s$u\"\n> +\t\tf=\"${f:+ $f}$r\"\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/}$f\"\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/}$f\"\n>  \t\tfi\n\nI notice that printf argument look very similar.  Maybe we want to do\nsomething like\n\n    printf \"${1:-\" (%s)\"}\" ...\n\nto avoid duplication?\n"},{"id":"130587","messageId":"20091231030438.GH6914@spearce.org","threadId":"21686","inReplyTo":"7veimc1cv6.fsf@alter.siamese.dyndns.org","subject":"[PATCH] bash completion: add space between branch name and status flags","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-12-31T03:04:38Z","receivedAt":"2009-12-31T03:04:38Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Improve the readability of the bash prompt by adding a space between\nthe branch name and the status flags (dirty, stash, untracked).\n\nWhile we are cleaning up this section of code, the two cases for\nformatting the prompt are identical except for the format string,\nso make them the same.\n\nSuggested-by: Roman Fietze <roman.fietze@telemotive.de>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n   Junio C Hamano <gitster@pobox.com> wrote:\n   > I notice that printf argument look very similar.  Maybe we want to do\n   > something like\n   > \n   >     printf \"${1:-\" (%s)\"}\" ...\n   > \n   > to avoid duplication?\n   \n   Ack.\n\n   Because its rather far from the original poster's patch, I've\n   taken blame for it.\n   \n contrib/completion/git-completion.bash |    8 +++-----\n 1 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex fbfa5f2..9ed7df2 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -163,11 +163,9 @@ __git_ps1 ()\n \t\t\tfi\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\telse\n-\t\t\tprintf \" (%s)\" \"$c${b##refs/heads/}$w$i$s$u$r\"\n-\t\tfi\n+\t\tlocal f=\"$w$i$s$u\"\n+\t\tf=\"${f:+ $f}$r\"\n+\t\tprintf \"${1:- (%s)}\" \"$c${b##refs/heads/}$f\"\n \tfi\n }\n \n-- \n1.6.6.325.g6f5f\n\n-- \nShawn.\n"},{"id":"130915","messageId":"201001061259.01639.roman.fietze@telemotive.de","threadId":"21686","inReplyTo":"20091230145751.GE6914@spearce.org","subject":"Re: [PATCH] bash completion: add space between branch name and status flags","fromName":"Roman Fietze","fromEmail":"roman.fietze@telemotive.de","sentAt":"2010-01-06T11:59:01Z","receivedAt":"2010-01-06T11:59:01Z","isPatch":true,"sender":{"key":"roman.fietze@telemotive.de","avatar":null},"body":"Hello Shawn,\n\nOn Wednesday 30 December 2009 15:57:51 Shawn O. Pearce wrote:\n\n> ... but Roman Fietze didn't send\n> a revised patch, so it got dropped\n\nSorry about that, but our Notes \"spam filter\" has been eating\nimportant mail again.\n\n\nI'l check the version as proposed by you as soon as I'm back.\n\n\nRoman\n\n-- \nRoman Fietze                Telemotive AG Büro Mühlhausen\nBreitwiesen                              73347 Mühlhausen\nTel.: +49(0)7335/18493-45        http://www.telemotive.de\n"}]}