summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-11-18 17:39:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-11-19 18:14:15 (GMT)
commitb28061ce0d2e31d390fee5a5724b8a061d0492a7 (patch)
treeffd06a2811065c442744dee721f0646fb0592092 /t
parent7a48b8321934384098a8392b3c4c814ec5058d00 (diff)
downloadgit-b28061ce0d2e31d390fee5a5724b8a061d0492a7.zip
git-b28061ce0d2e31d390fee5a5724b8a061d0492a7.tar.gz
git-b28061ce0d2e31d390fee5a5724b8a061d0492a7.tar.bz2
for-each-ref: introduce %(upstream:track[short])
Introduce %(upstream:track) to display "[ahead M, behind N]" and %(upstream:trackshort) to display "=", ">", "<", or "<>" appropriately (inspired by contrib/completion/git-prompt.sh). Now you can use the following format in for-each-ref: %(refname:short)%(upstream:trackshort) to display refs with terse tracking information. Note that :track and :trackshort only work with "upstream", and error out when used with anything else. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t6300-for-each-ref.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 1d998f8..d88d7ac 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -303,6 +303,33 @@ test_expect_success 'Check short upstream format' '
test_cmp expected actual
'
+test_expect_success 'setup for upstream:track[short]' '
+ test_commit two
+'
+
+cat >expected <<EOF
+[ahead 1]
+EOF
+
+test_expect_success 'Check upstream:track format' '
+ git for-each-ref --format="%(upstream:track)" refs/heads >actual &&
+ test_cmp expected actual
+'
+
+cat >expected <<EOF
+>
+EOF
+
+test_expect_success 'Check upstream:trackshort format' '
+ git for-each-ref --format="%(upstream:trackshort)" refs/heads >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'Check that :track[short] cannot be used with other atoms' '
+ test_must_fail git for-each-ref --format="%(refname:track)" 2>/dev/null &&
+ test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
+'
+
cat >expected <<EOF
$(git rev-parse --short HEAD)
EOF