Merge branch 'ow/ref-filter-omit-empty'

"git branch --format=..." and "git format-patch --format=..."
learns "--omit-empty" to hide refs that whose formatting result
becomes an empty string from the output.

* ow/ref-filter-omit-empty:
  branch, for-each-ref, tag: add option to omit empty lines
This commit is contained in:
Junio C Hamano
2023-04-21 15:35:05 -07:00
9 changed files with 75 additions and 4 deletions

View File

@ -1374,6 +1374,14 @@ test_expect_success 'for-each-ref --ignore-case ignores case' '
test_cmp expect actual
'
test_expect_success 'for-each-ref --omit-empty works' '
git for-each-ref --format="%(refname)" >actual &&
test_line_count -gt 1 actual &&
git for-each-ref --format="%(if:equals=refs/heads/main)%(refname)%(then)%(refname)%(end)" --omit-empty >actual &&
echo refs/heads/main >expect &&
test_cmp expect actual
'
test_expect_success 'for-each-ref --ignore-case works on multiple sort keys' '
# name refs numerically to avoid case-insensitive filesystem conflicts
nr=0 &&