Skip to contentSkip to conversation

log: decorate HEAD -> branch with the same color for branch and HEAD

PATCH Superseded Nguyễn Thái Ngọc Duy 3 participants 6 messages Jun 30, 2016 – Jul 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 log: decorate HEAD -> branch with the same color for branch and HEAD

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13) adds "HEAD -> branch" decoration to show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ", "). It's too subtle for my poor eyes. If color is used, we can make the branch name's color the same as HEAD to visually emphasize that it's the current branch.

---
For the original discussion of 76c61fb see
http://thread.gmane.org/gmane.comp.version-control.git/263922

 log-tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
log-tree.c +1 -1
index 78a5381..440e7cc 100644
@@ -267,7 +267,7 @@ void format_decorations_extended(struct strbuf *sb,
 				strbuf_addstr(sb, color_commit);
 				strbuf_addstr(sb, " -> ");
 				strbuf_addstr(sb, color_reset);
-				strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
+				strbuf_addstr(sb, decorate_get_color(use_color, DECORATION_REF_HEAD));
 				show_name(sb, current_and_HEAD);
 			}
 			strbuf_addstr(sb, color_reset);
Signature · 1 line
2.8.2.531.gd073806
author
#1 lore raw
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13)

.. and I got the commit wrong. It should be 51ff0f2 (log: decorate HEAD with branch name - 2015-03-10)

adds "HEAD -> branch" decoration to

Quoted 4 lines

show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ", "). It's too subtle for my poor eyes. If color is used, we can make the branch name's color the same as HEAD to visually emphasize that it's the current branch.

Signature · 1 line
Duy
#2 lore raw
In reply to Nguyễn Thái Ngọc Duy
Quoted 6 lines · Nguyễn Thái Ngọc Duy

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13) adds "HEAD -> branch" decoration to show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ", "). It's too subtle for my poor eyes. If color is used, we can make the branch name's color the same as HEAD to visually emphasize that it's the current branch.

Hmm. I think I like this, as it uses color to make the grouping between HEAD and its referent more clear.

We do already use colors to indicate "type", though. Which means:

1. The branch now uses the "symref" color. Probably OK, as that is the point of the grouping (I wonder if the "->" in the middle should match in color, too).

2. We used to color based on current_and_HEAD->type, but now that information isn't conveyed. However, can this really ever have been anything _except_ a branch?

-Peff

#3 lore raw

Jeff King venit, vidit, dixit 01.07.2016 08:31:

Quoted 18 lines · Nguyễn Thái Ngọc Duy
Quoted 7 lines

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13) adds "HEAD -> branch" decoration to show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ", "). It's too subtle for my poor eyes. If color is used, we can make the branch name's color the same as HEAD to visually emphasize that it's the current branch.

Hmm. I think I like this, as it uses color to make the grouping between HEAD and its referent more clear.

We do already use colors to indicate "type", though. Which means:

1. The branch now uses the "symref" color. Probably OK, as that is the point of the grouping (I wonder if the "->" in the middle should match in color, too).

Quoted 6 lines

2. We used to color based on current_and_HEAD->type, but now that information isn't conveyed. However, can this really ever have been anything _except_ a branch?

-Peff

So, I rechecked, and I'm afraid I don't like the proposal.

Currently, we have a clear color code that colors refs according their type (local branch, remote branch, tag, symref). This also corresponds to status colors, for example.

Under the proposal, a checked out branch would not be colored like a local branch - note that back then, the result of the discussion was:

- If a branch foo is checked out, do not decorate by "foo", but amend the HEAD decoration with "foo" and a symbol that denotes the connection.

So, "HEAD -> foo" is an intentional union of two decorations.

I wouldn't mind changing the color of "- > foo" if it were just an addition to "HEAD", but it is not - it's the decoration by the local branch foo.

With git branch, we use "*" as a symbol for the checked out branch...

Michael

author
#4 lore raw
Quoted 19 lines · Michael J Gruber

Jeff King venit, vidit, dixit 01.07.2016 08:31:

Quoted 18 lines · Nguyễn Thái Ngọc Duy
Quoted 7 lines

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13) adds "HEAD -> branch" decoration to show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ", "). It's too subtle for my poor eyes. If color is used, we can make the branch name's color the same as HEAD to visually emphasize that it's the current branch.

Hmm. I think I like this, as it uses color to make the grouping between HEAD and its referent more clear.

We do already use colors to indicate "type", though. Which means:

1. The branch now uses the "symref" color. Probably OK, as that is the point of the grouping (I wonder if the "->" in the middle should match in color, too).

Quoted 8 lines
Quoted 6 lines

2. We used to color based on current_and_HEAD->type, but now that information isn't conveyed. However, can this really ever have been anything _except_ a branch?

-Peff

So, I rechecked, and I'm afraid I don't like the proposal.

How about a middle ground: change color of the arrow (easier to catch eyes) and leave the associated branch alone.

Quoted 20 lines

Currently, we have a clear color code that colors refs according their type (local branch, remote branch, tag, symref). This also corresponds to status colors, for example.

Under the proposal, a checked out branch would not be colored like a local branch - note that back then, the result of the discussion was:

- If a branch foo is checked out, do not decorate by "foo", but amend the HEAD decoration with "foo" and a symbol that denotes the connection.

So, "HEAD -> foo" is an intentional union of two decorations.

I wouldn't mind changing the color of "- > foo" if it were just an addition to "HEAD", but it is not - it's the decoration by the local branch foo.

With git branch, we use "*" as a symbol for the checked out branch...

Michael

Signature · 1 line
Duy
#5 lore raw

PATCH v2 1/1 log: decorate HEAD -> branch with the same color for arrow and HEAD

Commit 76c61fb (log: decorate HEAD with branch name under --decorate=full, too - 2015-05-13) adds "HEAD -> branch" decoration to show current branch vs detached HEAD. The sign of whether HEAD is detached or not is "->" (vs ",") because the branch is always colored by type. Color the arrow the same as HEAD to visually emphasize that the following branch is HEAD, without paying too much attention to the actual separators "->" or ","

---
I'm going to take Michael's silence as no objection to the recoloring the arrow. So v2 changes the arrow's color instead of the branch's.

 log-tree.c                       | 2 --
 t/t4207-log-decoration-colors.sh | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)
log-tree.c +0 -2
index 78a5381..e647b08 100644
@@ -263,8 +263,6 @@ void format_decorations_extended(struct strbuf *sb,
 
 			if (current_and_HEAD &&
 			    decoration->type == DECORATION_REF_HEAD) {
-				strbuf_addstr(sb, color_reset);
-				strbuf_addstr(sb, color_commit);
 				strbuf_addstr(sb, " -> ");
 				strbuf_addstr(sb, color_reset);
 				strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
t/t4207-log-decoration-colors.sh +1 -1
index f8008b6..b972296 100755
@@ -44,7 +44,7 @@ test_expect_success setup '
 '
 
 cat >expected <<EOF
-${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}${c_commit} ->\
+${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
  ${c_reset}${c_branch}master${c_reset}${c_commit},\
  ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\
  ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
Signature · 1 line
2.8.2.537.g0965dd9