Thread (29 messages) 29 messages, 2 authors, 2016-08-11

Re: [PATCH v6 02/10] ref-filter: add option to pad atoms to the right

flat view

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:05:56

On Tuesday, July 28, 2015, Karthik Nayak [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Add a new atom "padright" and support %(padright:X) where X is a
number.  This will align the succeeding atom value to the left
followed by spaces for a total length of X characters. If X is less
than the item size, the entire atom value is printed.

Add tests and documentation for the same.

Signed-off-by: Karthik Nayak <redacted>
---
diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh
index 505a360..19ac480 100755
--- a/t/t6302-for-each-ref-filter.sh
+++ b/t/t6302-for-each-ref-filter.sh
@@ -81,4 +81,20 @@ test_expect_success 'filtering with --contains' '
        test_cmp expect actual
 '

+test_expect_success 'padding to the right using `padright`' '
+       cat >expect <<-\EOF &&
+       refs/heads/master|refs/heads/master        |refs/heads/master|
+       refs/heads/side|refs/heads/side          |refs/heads/side|
+       refs/odd/spot|refs/odd/spot            |refs/odd/spot|
+       refs/tags/double-tag|refs/tags/double-tag     |refs/tags/double-tag|
+       refs/tags/four|refs/tags/four           |refs/tags/four|
+       refs/tags/one|refs/tags/one            |refs/tags/one|
+       refs/tags/signed-tag|refs/tags/signed-tag     |refs/tags/signed-tag|
+       refs/tags/three|refs/tags/three          |refs/tags/three|
+       refs/tags/two|refs/tags/two            |refs/tags/two|
+       EOF
+       git for-each-ref --format="%(refname)%(padright:25)|%(refname)|%(refname)|" >actual &&
This fails to test the important case when the atom length is greater
than the padright value (in which case no padding should be done, and
the atom text should extend beyond the 'padright' column).
+       test_cmp expect actual
+'
+
 test_done
--
2.4.6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help