Merge branch 'bc/git-contacts-stdin' into jch

The 'git-contacts' program (in contrib/) has been taught to read
patches from the standard input stream when an explicit dash ('-') is
passed in place of a file.

* bc/git-contacts-stdin:
  git-contacts: allow inputting patch via stdin
jch
Junio C Hamano 2026-10-12 09:25:54 -07:00
commit 08fce9f716
2 changed files with 19 additions and 6 deletions

View File

@ -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;
@ -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, $_);
}

View File

@ -9,7 +9,7 @@ git-contacts - List people who might be interested in a set of changes
SYNOPSIS
--------
[verse]
'git contacts' (<patch>|<range>|<rev>)...
'git contacts' (<patch>|'-'|<range>|<rev>)...


DESCRIPTION
@ -23,8 +23,10 @@ which touched the lines of files under consideration.
Input consists of one or more patch files or revision arguments. A revision
argument can be a range or a single `<rev>` which is interpreted as
`<rev>..HEAD`, thus the same revision arguments are accepted as for
linkgit:git-format-patch[1]. Patch files and revision arguments can be combined
in the same invocation.
linkgit:git-format-patch[1]. A single dash `'-'` character in place of a
`<patch>` tells the command to read patch file(s) from the standard input.
Patch files, standard input, and revision arguments can be combined in the same
invocation.

This command can be useful for determining the list of people with whom to
discuss proposed changes, or for finding the list of recipients to Cc: when
@ -73,6 +75,12 @@ $ git contacts R1..R2
$ git contacts origin
------------

* Input a patch via stdin:
+
------------
$ git contacts - <feature.patch
------------

* Helper for `git send-email`:
+
------------