Merge branch 'nd/rebase-forget'
[gitweb.git] / t / t6300-for-each-ref.sh
index 19a2823025e794a6adc3f75d65dd175a2021f282..aea1dfc7148e4885e52a579ca60ee622c49b5693 100755 (executable)
@@ -553,4 +553,39 @@ test_expect_success 'Verify sort with multiple keys' '
                refs/tags/bogo refs/tags/master > actual &&
        test_cmp expected actual
 '
+
+test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
+       test_when_finished "git checkout master" &&
+       git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
+       sed -e "s/^\* /  /" actual >expect &&
+       git checkout --orphan HEAD &&
+       git for-each-ref --format="%(HEAD) %(refname:short)" refs/heads/ >actual &&
+       test_cmp expect actual
+'
+
+cat >trailers <<EOF
+Reviewed-by: A U Thor <author@example.com>
+Signed-off-by: A U Thor <author@example.com>
+EOF
+
+test_expect_success 'basic atom: head contents:trailers' '
+       echo "Some contents" > two &&
+       git add two &&
+       git commit -F - <<-EOF &&
+       trailers: this commit message has trailers
+
+       Some message contents
+
+       $(cat trailers)
+       EOF
+       git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
+       sanitize_pgp <actual >actual.clean &&
+       # git for-each-ref ends with a blank line
+       cat >expect <<-EOF &&
+       $(cat trailers)
+
+       EOF
+       test_cmp expect actual.clean
+'
+
 test_done