Re: [PATCH v5 1/2] git-contacts: allow inputting patch via stdin
Brigham Campbell <me@brighamcampbell.com> writes:
Show 39 quoted lines
> Make git-contacts accept patch contents via stdin for better
> interoperability with other utilities. Read from stdin when the user
> passes `-` at least once:
>
> $ git contacts - <patch
>
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
> ---
> contrib/contacts/git-contacts | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
> index 85ad732fc0..df7b920d9e 100755
> --- a/contrib/contacts/git-contacts
> +++ b/contrib/contacts/git-contacts
> @@ -162,9 +162,11 @@ if (!@ARGV) {
> die "No input revisions or patch files\n";
> }
>
> -my (@files, @rev_args);
> +my ($read_from_stdin, @files, @rev_args);
> for (@ARGV) {
> - if (-e) {
> + if ($_ eq '-') {
> + $read_from_stdin = 1;
> + } elsif (-e) {
> push @files, $_;
> } else {
> push @rev_args, $_;
> @@ -172,6 +174,9 @@ for (@ARGV) {
> }
>
> my %sources;
> +if ($read_from_stdin) {
> + scan_patches(\%sources, undef, \*STDIN);
> +}
> for (@files) {
> scan_patch_file(\%sources, $_);
> }Doesn't the Usage comment at the beginning also want to be updated?
Thanks.
diff --git i/contrib/contacts/git-contacts w/contrib/contacts/git-contacts
index 85ad732fc0..1eb91c4ab1 100755
--- i/contrib/contacts/git-contacts
+++ w/contrib/contacts/git-contacts
@@ -3,7 +3,7 @@
# List people who might be interested in a patch. Useful as the argument to
# git-send-email --cc-cmd option, and in other situations.
#
-# Usage: git contacts <file | rev-list option> ...
+# Usage: git contacts <file | '-' | rev-list option> ...
use strict;
use warnings;