git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6] git-contacts: allow inputting patch via stdin

From
Brigham Campbell <me@brighamcampbell.com>
Date
Oct 2, 2026, 06:50 UTC
Message-ID
<20261002-git-contacts-stdin-v6-1-49878e872d3d@brighamcampbell.com>
In-Reply-To
<20260914-git-contacts-stdin-v1-1-9ac628e6fd20@brighamcampbell.com>

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>
---
I verified the documentation changes by rendering html and inspecting
the output in a web browser.
---
Changes in v6:
- Squash documentation and code into a single commit
- Make documentation changes more complete
- Link to v5: https://patch.msgid.link/20260928-git-contacts-stdin-v5-0-e9becaebc47e@brighamcampbell.com
Changes in v5:
- Add a patch documenting stdin support
- Link to v4: https://patch.msgid.link/20260925-git-contacts-stdin-v4-1-9b4e4bcbb91c@brighamcampbell.com
Changes in v4:
- Don't imply that git-contacts processes input in any particular order
- Link to v3: https://patch.msgid.link/20260923-git-contacts-stdin-v3-1-56dd43c64d56@brighamcampbell.com
Changes in v3:
- Make user pass '-' instead of an empty argv and non-TTY stdin
- Link to v2: https://patch.msgid.link/20260915-git-contacts-stdin-v2-1-2005061d907a@brighamcampbell.com
Changes in v2:
- Minor variable cleanup / un-spaghettification
- Include update to usage comment
- Remove Cc trailers from commit message
- Link to v1: https://patch.msgid.link/20260914-git-contacts-stdin-v1-1-9ac628e6fd20@brighamcampbell.com
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Cc: Patrick Steinhardt <ps@pks.im>
---
 contrib/contacts/git-contacts      | 11 ++++++++---
 contrib/contacts/git-contacts.adoc | 14 +++++++++++---
 2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index 85ad732fc0..e4656affb5 100755
--- a/contrib/contacts/git-contacts
+++ b/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;
@@ -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, $_);
 }
diff --git a/contrib/contacts/git-contacts.adoc b/contrib/contacts/git-contacts.adoc
index dd914d1261..ea5dd58826 100644
--- a/contrib/contacts/git-contacts.adoc
+++ b/contrib/contacts/git-contacts.adoc
@@ -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`:
 +
 ------------

---
base-commit: c46c1e37724f0478939de636ab8ea5a89086d532
change-id: 20260914-git-contacts-stdin-1e829930e19b

Thanks!
-- 
Brigham Campbell
https://brighamcampbell.com
Previous: Junio C HamanoNext: Junio C Hamano
Message 18 of 19 in “git-contacts: allow inputting patch via stdin”
  1. git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 15, 2026
  2. Junio C HamanoSep 15, 2026
  3. git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 16, 2026
  4. Junio C HamanoSep 16, 2026
  5. Brigham CampbellSep 17, 2026
  6. git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 24, 2026
  7. Junio C HamanoSep 24, 2026
  8. Brigham CampbellSep 25, 2026
  9. Junio C HamanoSep 25, 2026
  10. git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 25, 2026
  11. Junio C HamanoSep 25, 2026
  12. 0/2 git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 29, 2026
  13. 1/2 git-contacts: allow inputting patch via stdinBrigham Campbell, Sep 29, 2026
  14. Junio C HamanoSep 29, 2026
  15. Brigham CampbellOct 2, 2026
  16. 2/2 git-contacts: add stdin functionality to docsBrigham Campbell, Sep 29, 2026
  17. Junio C HamanoSep 29, 2026
  18. git-contacts: allow inputting patch via stdinBrigham Campbell, Oct 2, 2026
  19. Junio C HamanoOct 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.