Skip to contentSkip to conversation

diff-highlight: fix a whitespace nit

PATCH In review Norman Rasmussen via GitGitGadget 3 participants 4 messages Oct 15, 2019

lore
Share & tools
lore
#0 lore raw

cover diff-highlight: fix a whitespace nit

This changes the indent from
"<tab><sp><sp><sp><sp><sp><sp><sp><sp>"
to
"<tab><tab>"
so that the statement lines up with the rest of the block.

Norman Rasmussen (1):
diff-highlight: fix a whitespace nit

 contrib/diff-highlight/DiffHighlight.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

base-commit: 08da6496b61341ec45eac36afcc8f94242763468
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-397%2Fnormanr%2Fdiff-highlight-whitespace-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-397/normanr/diff-highlight-whitespace-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/397

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH 1/1 diff-highlight: fix a whitespace nit

From: Norman Rasmussen <[email protected]>

This changes the indent from
"<tab><sp><sp><sp><sp><sp><sp><sp><sp>"
to
"<tab><tab>"
so that the statement lines up with the rest of the block.

---
 contrib/diff-highlight/DiffHighlight.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/diff-highlight/DiffHighlight.pm +1 -1
index 7440aa1c46..e2589922a6 100644
@@ -72,7 +72,7 @@ sub handle_line {
 	      (?:$COLOR?\|$COLOR?[ ])* # zero or more trailing "|"
 	                         [ ]*  # trailing whitespace for merges
 	    /x) {
-	        my $graph_prefix = $&;
+		my $graph_prefix = $&;
 
 		# We must flush before setting graph indent, since the
 		# new commit may be indented differently from what we
Signature · 1 line
gitgitgadget
#2 lore raw
Quoted 7 lines · Norman Rasmussen via GitGitGadget

From: Norman Rasmussen <[email protected]>

This changes the indent from
"<tab><sp><sp><sp><sp><sp><sp><sp><sp>"
to
"<tab><tab>"
so that the statement lines up with the rest of the block.

Yep, that makes sense. Looks like I introduced the problem (most of my perl used to be written in a style that forbids tabs, so it may have snuck in that way, but the rest of the file definitely follows Git's usual style of tabs).

contrib/diff-highlight/DiffHighlight.pm sub handle_line { · line 75

Quoted 10 lines
contrib/diff-highlight/DiffHighlight.pm +1 -1
index 7440aa1c46..e2589922a6 100644
@@ -72,7 +72,7 @@ sub handle_line {
 	      (?:$COLOR?\|$COLOR?[ ])* # zero or more trailing "|"
 	                         [ ]*  # trailing whitespace for merges
 	    /x) {
-	        my $graph_prefix = $&;
+		my $graph_prefix = $&;

There are a few lines just above that have 8+ spaces. Arguably those could be tabs, too, depending on your view of tabs. We usually do "8 spaces is a tab" in the Git project, but the oft-repeated "tabs to indent, spaces to align" mantra would apply here (and I suspect you're using a different tabwidth since you noticed this one case). So I'd just as soon leave them be, and take your patch as-is.

-Peff

#3 lore raw
Quoted 6 lines · Jeff King

There are a few lines just above that have 8+ spaces. Arguably those could be tabs, too, depending on your view of tabs. We usually do "8 spaces is a tab" in the Git project, but the oft-repeated "tabs to indent, spaces to align" mantra would apply here (and I suspect you're using a different tabwidth since you noticed this one case). So I'd just as soon leave them be, and take your patch as-is.

Yep, the lines above are using the spaces to align the sections of the multi-line if statement. This happens again for the return statements in highlight_pair and is_pair_interesting. So this is the only line that doesn't stick to the rule (and probably because of editor auto-indenting). I have another change for the same change (which I'll send once I've written tests) and I only noticed this line when I changed my editor's default tabwidth after a while of coding.

Signature · 3 lines
- Norman Rasmussen
 - Email: [email protected]
 - Home page: http://norman.rasmussen.co.za/