git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* [PATCH] prompt: do not double-discriminate detached HEAD
@ 2013-07-07 12:52 Ramkumar Ramachandra
  2013-07-07 13:35 ` John Szakmeister
  2013-07-08  1:12 ` Eduardo R. D'Avila
  0 siblings, 2 replies; 6+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-07 12:52 UTC (permalink / raw)
  To: Git List; +Cc: Eduardo R. D'Avila, SZEDER Gábor

When GIT_PS1_SHOWCOLORHINTS is turned on, there is no need to put a
detached HEAD within parenthesis: the color can be used to discriminate
the detached HEAD.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 For cuteness :)

 contrib/completion/git-prompt.sh | 5 ++++-
 t/t9903-bash-prompt.sh           | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index a81ef5a..37e66a2 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -372,7 +372,10 @@ __git_ps1 ()
 				esac 2>/dev/null)" ||
 
 				b="$short_sha..."
-				b="($b)"
+				# if there is no color, use
+				# parenthesis to indicate that the
+				# HEAD is detached
+				test -n "${GIT_PS1_SHOWCOLORHINTS-}" || b="($b)"
 			fi
 		fi
 	fi
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 3c3e4e8..c44b1a6 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -450,7 +450,7 @@ test_expect_success 'prompt - bash color pc mode - branch name' '
 '
 
 test_expect_success 'prompt - bash color pc mode - detached head' '
-	printf "BEFORE: (${c_red}(%s...)${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
+	printf "BEFORE: (${c_red}%s...${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
 	git checkout b1^ &&
 	test_when_finished "git checkout master" &&
 	(
-- 
1.8.3.2.737.gcbc076a.dirty

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

* Re: [PATCH] prompt: do not double-discriminate detached HEAD
  2013-07-07 12:52 [PATCH] prompt: do not double-discriminate detached HEAD Ramkumar Ramachandra
@ 2013-07-07 13:35 ` John Szakmeister
  2013-07-07 17:53   ` Junio C Hamano
  2013-07-08  1:12 ` Eduardo R. D'Avila
  1 sibling, 1 reply; 6+ messages in thread
From: John Szakmeister @ 2013-07-07 13:35 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Eduardo R. D'Avila, SZEDER Gábor

On Sun, Jul 7, 2013 at 8:52 AM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> When GIT_PS1_SHOWCOLORHINTS is turned on, there is no need to put a
> detached HEAD within parenthesis: the color can be used to discriminate
> the detached HEAD.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---
>  For cuteness :)

Personally, I'd rather see the parens kept.  Not everyone sees red
very well--I know several people who can't see it at all, and it keeps
it consistent with non-colored output.

-John

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

* Re: [PATCH] prompt: do not double-discriminate detached HEAD
  2013-07-07 13:35 ` John Szakmeister
@ 2013-07-07 17:53   ` Junio C Hamano
  2013-07-07 18:32     ` Kyle McKay
  2013-07-08 13:49     ` Ramkumar Ramachandra
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2013-07-07 17:53 UTC (permalink / raw)
  To: John Szakmeister
  Cc: Ramkumar Ramachandra, Git List, Eduardo R. D'Avila,
	SZEDER Gábor

John Szakmeister <john@szakmeister.net> writes:

> On Sun, Jul 7, 2013 at 8:52 AM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
>> When GIT_PS1_SHOWCOLORHINTS is turned on, there is no need to put a
>> detached HEAD within parenthesis: the color can be used to discriminate
>> the detached HEAD.
>>
>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>> ---
>>  For cuteness :)
>
> Personally, I'd rather see the parens kept.  Not everyone sees red
> very well--I know several people who can't see it at all, and it keeps
> it consistent with non-colored output.

+1; I find red on many terminal emulators to be too dark to tell,
especially in a small font, from black myself.

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

* Re: [PATCH] prompt: do not double-discriminate detached HEAD
  2013-07-07 17:53   ` Junio C Hamano
@ 2013-07-07 18:32     ` Kyle McKay
  2013-07-08 13:49     ` Ramkumar Ramachandra
  1 sibling, 0 replies; 6+ messages in thread
From: Kyle McKay @ 2013-07-07 18:32 UTC (permalink / raw)
  To: Git List
  Cc: John Szakmeister, Junio C Hamano, Ramkumar Ramachandra,
	Eduardo R. D'Avila, SZEDER Gábor

On Jul 7, 2013, at 10:53, Junio C Hamano wrote:
> John Szakmeister <john@szakmeister.net> writes:
>
>> On Sun, Jul 7, 2013 at 8:52 AM, Ramkumar Ramachandra <artagnon@gmail.com 
>> > wrote:
>>> When GIT_PS1_SHOWCOLORHINTS is turned on, there is no need to put a
>>> detached HEAD within parenthesis: the color can be used to  
>>> discriminate
>>> the detached HEAD.
>>>
>>> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
>>> ---
>>> For cuteness :)
>>
>> Personally, I'd rather see the parens kept.  Not everyone sees red
>> very well--I know several people who can't see it at all, and it  
>> keeps
>> it consistent with non-colored output.
>
> +1; I find red on many terminal emulators to be too dark to tell,
> especially in a small font, from black myself.

+1; me too for the same reason.

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

* Re: [PATCH] prompt: do not double-discriminate detached HEAD
  2013-07-07 12:52 [PATCH] prompt: do not double-discriminate detached HEAD Ramkumar Ramachandra
  2013-07-07 13:35 ` John Szakmeister
@ 2013-07-08  1:12 ` Eduardo R. D'Avila
  1 sibling, 0 replies; 6+ messages in thread
From: Eduardo R. D'Avila @ 2013-07-08  1:12 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, SZEDER Gábor

I think color in terminals should be used to highlight and make it easier to see
textual information, not to replace them. So I would keep the parenthesis.

> +                               test -n "${GIT_PS1_SHOWCOLORHINTS-}" || b="($b)"

Also, the proposed change has a side-effect because color is not possible in
non-pc mode, even if GIT_PS1_SHOWCOLORHINTS is defined. (Non-pc mode
with GIT_PS1_SHOWCOLORHINTS defined would make the detached HEAD not be
shown neither in red nor within parenthesis).

Regards,

Eduardo R. D'Avila

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

* Re: [PATCH] prompt: do not double-discriminate detached HEAD
  2013-07-07 17:53   ` Junio C Hamano
  2013-07-07 18:32     ` Kyle McKay
@ 2013-07-08 13:49     ` Ramkumar Ramachandra
  1 sibling, 0 replies; 6+ messages in thread
From: Ramkumar Ramachandra @ 2013-07-08 13:49 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: John Szakmeister, Git List, Eduardo R. D'Avila, SZEDER Gábor

Junio C Hamano wrote:
> +1; I find red on many terminal emulators to be too dark to tell,
> especially in a small font, from black myself.

It's a matter of taste anyway.  I hope everyone's not going colorblind
from writing too much C89 and Bourne shell ;)

Eduardo R. D'Avila wrote:
> I think color in terminals should be used to highlight and make it easier to see
> textual information, not to replace them. So I would keep the parenthesis.

I largely agree, but there are a few exceptions.  Most notably, have
you noticed how, in addition to font-locking, scheme-mode replaces
lambda with λ?

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

end of thread, other threads:[~2013-07-08 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-07 12:52 [PATCH] prompt: do not double-discriminate detached HEAD Ramkumar Ramachandra
2013-07-07 13:35 ` John Szakmeister
2013-07-07 17:53   ` Junio C Hamano
2013-07-07 18:32     ` Kyle McKay
2013-07-08 13:49     ` Ramkumar Ramachandra
2013-07-08  1:12 ` Eduardo R. D'Avila

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git