All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bash completion: add space between branch name and status flags
@ 2009-11-20 12:09 Roman Fietze
  2009-11-20 17:53 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Roman Fietze @ 2009-11-20 12:09 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Hello Shawn, hello git list members,

Wouldn't it improve the readability of the bash prompt, if there would
be a space between the branch name and the status flags (dirty, stash,
untracked)?

Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>
---
 contrib/completion/git-completion.bash |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-
completion.bash
index bd66639..407176b 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -169,10 +169,12 @@ __git_ps1 ()
 			fi
 		fi
 
+		local f="$w$i$s$u$r"
+		f=${f:+ $f}
 		if [ -n "${1-}" ]; then
-			printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
+			printf "$1" "$c${b##refs/heads/}$f"
 		else
-			printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
+			printf " (%s)" "$c${b##refs/heads/}$f"
 		fi
 	fi
 }
-- 
1.6.4.2


Roman

-- 
Roman Fietze                Telemotive AG Büro Mühlhausen
Breitwiesen                              73347 Mühlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bash completion: add space between branch name and status flags
  2009-11-20 12:09 [PATCH] bash completion: add space between branch name and status flags Roman Fietze
@ 2009-11-20 17:53 ` Junio C Hamano
  2009-12-30 13:41   ` Nanako Shiraishi
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2009-11-20 17:53 UTC (permalink / raw)
  To: Roman Fietze; +Cc: Shawn O. Pearce, git

Roman Fietze <roman.fietze@telemotive.de> writes:

> Hello Shawn, hello git list members,
>
> Wouldn't it improve the readability of the bash prompt, if there would
> be a space between the branch name and the status flags (dirty, stash,
> untracked)?

Perhaps.

> Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>
> ---
>  contrib/completion/git-completion.bash |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-
> completion.bash
> index bd66639..407176b 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -169,10 +169,12 @@ __git_ps1 ()
>  			fi
>  		fi
>  
> +		local f="$w$i$s$u$r"

I think this line and the two changes to printf below is a big improvement
(unless we are using f for something else---I didn't look).  But I think
the next line is wrong.

> +		f=${f:+ $f}

The $r string is designed to be used as suffix from the beginning and
always has "|" in front of it as a delimiter, so if there is no w/i/s/u
(and I suspect many people do not use GIT_PS1_SHOWDIRTYSTATE and friends,
and these are _always_ empty for them) the above will begin with "|".
There is no need to steal one column from a typeable width from the
command line in such a case.

>  		if [ -n "${1-}" ]; then
> -			printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
> +			printf "$1" "$c${b##refs/heads/}$f"
>  		else
> -			printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
> +			printf " (%s)" "$c${b##refs/heads/}$f"
>  		fi
>  	fi
>  }

To implement your stated goal (dirty/stash/untracked), you probably want
to do this instead...

	local f="$w$i$s$u"
        f="${f:+ $f}$r"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bash completion: add space between branch name and status flags
  2009-11-20 17:53 ` Junio C Hamano
@ 2009-12-30 13:41   ` Nanako Shiraishi
  2009-12-30 14:57     ` Shawn O. Pearce
  0 siblings, 1 reply; 7+ messages in thread
From: Nanako Shiraishi @ 2009-12-30 13:41 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Shawn O. Pearce, git, Roman Fietze

Junio, could you tell us what happened to this thread?

In response to a patch from Roman Fietze to outline a better way
to do it.  Nothing happened.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] bash completion: add space between branch name and status flags
  2009-12-30 13:41   ` Nanako Shiraishi
@ 2009-12-30 14:57     ` Shawn O. Pearce
  2009-12-30 19:27       ` Junio C Hamano
  2010-01-06 11:59       ` Roman Fietze
  0 siblings, 2 replies; 7+ messages in thread
From: Shawn O. Pearce @ 2009-12-30 14:57 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: Junio C Hamano, git, Roman Fietze

Nanako Shiraishi <nanako3@lavabit.com> wrote:
> Junio, could you tell us what happened to this thread?
> 
> In response to a patch from Roman Fietze to outline a better way
> to do it.  Nothing happened.

Junio responded with a suggestion on how to improve the patch when
GIT_PS1_SHOWDIRTYSTATE was not set, but Roman Fietze didn't send
a revised patch, so it got dropped.

Here is the revised patch, Junio, still think its a good idea?

--8<--
From: Roman Fietze <roman.fietze@telemotive.de>
Subject: [PATCH] bash completion: add space between branch name and status flags

Improve the readability of the bash prompt by adding a space between
the branch name and the status flags (dirty, stash, untracked).

Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fbfa5f2..3c8b6df 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -163,10 +163,12 @@ __git_ps1 ()
 			fi
 		fi
 
+		local f="$w$i$s$u"
+		f="${f:+ $f}$r"
 		if [ -n "${1-}" ]; then
-			printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
+			printf "$1" "$c${b##refs/heads/}$f"
 		else
-			printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
+			printf " (%s)" "$c${b##refs/heads/}$f"
 		fi
 	fi
 }
-- 
1.6.6.307.gba67


-- 
Shawn.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bash completion: add space between branch name and status flags
  2009-12-30 14:57     ` Shawn O. Pearce
@ 2009-12-30 19:27       ` Junio C Hamano
  2009-12-31  3:04         ` Shawn O. Pearce
  2010-01-06 11:59       ` Roman Fietze
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2009-12-30 19:27 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Nanako Shiraishi, git, Roman Fietze

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Nanako Shiraishi <nanako3@lavabit.com> wrote:
>> Junio, could you tell us what happened to this thread?
>> 
>> In response to a patch from Roman Fietze to outline a better way
>> to do it.  Nothing happened.
>
> Junio responded with a suggestion on how to improve the patch when
> GIT_PS1_SHOWDIRTYSTATE was not set, but Roman Fietze didn't send
> a revised patch, so it got dropped.
>
> Here is the revised patch, Junio, still think its a good idea?

Thanks for following up.

As I don't use $[wisu] myself, I don't have a very strong opinion either
way, but the user has spent cycles to compute them, so we'd better present
them in a way that is easier to read, I guess.

> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index fbfa5f2..3c8b6df 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -163,10 +163,12 @@ __git_ps1 ()
>  			fi
>  		fi
>  
> +		local f="$w$i$s$u"
> +		f="${f:+ $f}$r"
>  		if [ -n "${1-}" ]; then
> -			printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
> +			printf "$1" "$c${b##refs/heads/}$f"
>  		else
> -			printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
> +			printf " (%s)" "$c${b##refs/heads/}$f"
>  		fi

I notice that printf argument look very similar.  Maybe we want to do
something like

    printf "${1:-" (%s)"}" ...

to avoid duplication?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] bash completion: add space between branch name and status flags
  2009-12-30 19:27       ` Junio C Hamano
@ 2009-12-31  3:04         ` Shawn O. Pearce
  0 siblings, 0 replies; 7+ messages in thread
From: Shawn O. Pearce @ 2009-12-31  3:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nanako Shiraishi, git, Roman Fietze

Improve the readability of the bash prompt by adding a space between
the branch name and the status flags (dirty, stash, untracked).

While we are cleaning up this section of code, the two cases for
formatting the prompt are identical except for the format string,
so make them the same.

Suggested-by: Roman Fietze <roman.fietze@telemotive.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
   Junio C Hamano <gitster@pobox.com> wrote:
   > I notice that printf argument look very similar.  Maybe we want to do
   > something like
   > 
   >     printf "${1:-" (%s)"}" ...
   > 
   > to avoid duplication?
   
   Ack.

   Because its rather far from the original poster's patch, I've
   taken blame for it.
   
 contrib/completion/git-completion.bash |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fbfa5f2..9ed7df2 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -163,11 +163,9 @@ __git_ps1 ()
 			fi
 		fi
 
-		if [ -n "${1-}" ]; then
-			printf "$1" "$c${b##refs/heads/}$w$i$s$u$r"
-		else
-			printf " (%s)" "$c${b##refs/heads/}$w$i$s$u$r"
-		fi
+		local f="$w$i$s$u"
+		f="${f:+ $f}$r"
+		printf "${1:- (%s)}" "$c${b##refs/heads/}$f"
 	fi
 }
 
-- 
1.6.6.325.g6f5f

-- 
Shawn.

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] bash completion: add space between branch name and status flags
  2009-12-30 14:57     ` Shawn O. Pearce
  2009-12-30 19:27       ` Junio C Hamano
@ 2010-01-06 11:59       ` Roman Fietze
  1 sibling, 0 replies; 7+ messages in thread
From: Roman Fietze @ 2010-01-06 11:59 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Nanako Shiraishi, Junio C Hamano, git

Hello Shawn,

On Wednesday 30 December 2009 15:57:51 Shawn O. Pearce wrote:

> ... but Roman Fietze didn't send
> a revised patch, so it got dropped

Sorry about that, but our Notes "spam filter" has been eating
important mail again.


I'l check the version as proposed by you as soon as I'm back.


Roman

-- 
Roman Fietze                Telemotive AG Büro Mühlhausen
Breitwiesen                              73347 Mühlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-01-06 12:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20 12:09 [PATCH] bash completion: add space between branch name and status flags Roman Fietze
2009-11-20 17:53 ` Junio C Hamano
2009-12-30 13:41   ` Nanako Shiraishi
2009-12-30 14:57     ` Shawn O. Pearce
2009-12-30 19:27       ` Junio C Hamano
2009-12-31  3:04         ` Shawn O. Pearce
2010-01-06 11:59       ` Roman Fietze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.