]> git.ipfire.org Git - thirdparty/git.git/commit
for-each-ref: add --stdin option
authorDerrick Stolee <derrickstolee@github.com>
Mon, 20 Mar 2023 11:26:47 +0000 (11:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Mar 2023 19:17:32 +0000 (12:17 -0700)
commitb73dec55309d9b4f7e0db95dba729af0fcafb67f
tree596e5ab08d26016113a800020c98bbe799c72c7b
parentd15644fe0226af7ffc874572d968598564a230dd
for-each-ref: add --stdin option

When a user wishes to input a large list of patterns to 'git
for-each-ref' (likely a long list of exact refs) there are frequently
system limits on the number of command-line arguments.

Add a new --stdin option to instead read the patterns from standard
input. Add tests that check that any unrecognized arguments are
considered an error when --stdin is provided. Also, an empty pattern
list is interpreted as the complete ref set.

When reading from stdin, we populate the filter.name_patterns array
dynamically as opposed to pointing to the 'argv' array directly. This is
simple when using a strvec, as it is NULL-terminated in the same way. We
then free the memory directly from the strvec.

Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-for-each-ref.txt
builtin/for-each-ref.c
t/t6300-for-each-ref.sh