all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 58813@debbugs.gnu.org
Cc: ludo@gnu.org, liliana.prikler@gmail.com,
	Maxim Cournoyer <maxim.cournoyer@gmail.com>,
	zimon.toutoune@gmail.com
Subject: bug#58813: [PATCH v2 1/5] gnu: git: Apply patch adding the --header-cmd feature.
Date: Sun, 23 Apr 2023 22:29:23 -0400	[thread overview]
Message-ID: <2899162d279cdd940bc91459b38ff1e2c3f4f0ec.1682303142.git.maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <5b9af4fa77a89c6a4b169dc464f414b1a4166d60.camel@gmail.com>

In preparation to fix <https://issues.guix.gnu.org/58813>.

* gnu/packages/patches/git-header-cmd.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/version-control.scm (git) [source]: Apply patch.
---
 gnu/local.mk                              |   1 +
 gnu/packages/patches/git-header-cmd.patch | 180 ++++++++++++++++++++++
 gnu/packages/version-control.scm          |   3 +-
 3 files changed, 183 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/git-header-cmd.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b631fa6d5a..d7c7ca48e7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1209,6 +1209,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gemmi-fix-sajson-types.patch		\
   %D%/packages/patches/genimage-mke2fs-test.patch		\
   %D%/packages/patches/geoclue-config.patch			\
+  %D%/packages/patches/git-header-cmd.patch			\
   %D%/packages/patches/ghc-8.0-fall-back-to-madv_dontneed.patch	\
   %D%/packages/patches/ghc-9.2-glibc-2.33-link-order.patch \
   %D%/packages/patches/ghc-testsuite-dlopen-pie.patch		\
diff --git a/gnu/packages/patches/git-header-cmd.patch b/gnu/packages/patches/git-header-cmd.patch
new file mode 100644
index 0000000000..fdd34fe4a4
--- /dev/null
+++ b/gnu/packages/patches/git-header-cmd.patch
@@ -0,0 +1,180 @@
+Add a '--header-cmd' to git send-email.
+
+Upstream status can be tracked at:
+https://lore.kernel.org/git/20230423122744.4865-1-maxim.cournoyer@gmail.com/T/#t
+
+diff --git a/Documentation/config/sendemail.txt b/Documentation/config/sendemail.txt
+index 51da7088a8..3d0f516520 100644
+--- a/Documentation/config/sendemail.txt
++++ b/Documentation/config/sendemail.txt
+@@ -58,6 +58,7 @@ sendemail.annotate::
+ sendemail.bcc::
+ sendemail.cc::
+ sendemail.ccCmd::
++sendemail.headerCmd::
+ sendemail.chainReplyTo::
+ sendemail.envelopeSender::
+ sendemail.from::
+diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
+index b0f438ec99..354c0d06db 100644
+--- a/Documentation/git-send-email.txt
++++ b/Documentation/git-send-email.txt
+@@ -320,6 +320,11 @@ Automating
+ 	Output of this command must be single email address per line.
+ 	Default is the value of `sendemail.ccCmd` configuration value.
+ 
++--header-cmd=<command>::
++	Specify a command to execute once per patch file which should
++	generate arbitrary, patch file specific header entries.
++	Default is the value of `sendemail.headerCmd` configuration value.
++
+ --[no-]chain-reply-to::
+ 	If this is set, each email will be sent as a reply to the previous
+ 	email sent.  If disabled with "--no-chain-reply-to", all emails after
+diff --git a/git-send-email.perl b/git-send-email.perl
+index fd8cd0d46f..676dd83d89 100755
+--- a/git-send-email.perl
++++ b/git-send-email.perl
+@@ -2,6 +2,7 @@
+ #
+ # Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
+ # Copyright 2005 Ryan Anderson <ryan@michonline.com>
++# Copyright 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+ #
+ # GPL v2 (See COPYING)
+ #
+@@ -87,8 +88,9 @@ sub usage {
+ 
+   Automating:
+     --identity              <str>  * Use the sendemail.<id> options.
+-    --to-cmd                <str>  * Email To: via `<str> \$patch_path`
+-    --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`
++    --to-cmd                <str>  * Email To: via `<str> \$patch_path`.
++    --cc-cmd                <str>  * Email Cc: via `<str> \$patch_path`.
++    --header-cmd            <str>  * Add headers via `<str> \$patch_path`.
+     --suppress-cc           <str>  * author, self, sob, cc, cccmd, body, bodycc, misc-by, all.
+     --[no-]cc-cover                * Email Cc: addresses in the cover letter.
+     --[no-]to-cover                * Email To: addresses in the cover letter.
+@@ -269,7 +271,7 @@ sub do_edit {
+ # Variables with corresponding config settings
+ my ($suppress_from, $signed_off_by_cc);
+ my ($cover_cc, $cover_to);
+-my ($to_cmd, $cc_cmd);
++my ($to_cmd, $cc_cmd, $header_cmd);
+ my ($smtp_server, $smtp_server_port, @smtp_server_options);
+ my ($smtp_authuser, $smtp_encryption, $smtp_ssl_cert_path);
+ my ($batch_size, $relogin_delay);
+@@ -318,6 +320,7 @@ sub do_edit {
+     "tocmd" => \$to_cmd,
+     "cc" => \@config_cc,
+     "cccmd" => \$cc_cmd,
++    "headercmd" => \$header_cmd,
+     "aliasfiletype" => \$aliasfiletype,
+     "bcc" => \@config_bcc,
+     "suppresscc" => \@suppress_cc,
+@@ -519,6 +522,7 @@ sub config_regexp {
+ 		    "compose" => \$compose,
+ 		    "quiet" => \$quiet,
+ 		    "cc-cmd=s" => \$cc_cmd,
++		    "header-cmd=s" => \$header_cmd,
+ 		    "suppress-from!" => \$suppress_from,
+ 		    "no-suppress-from" => sub {$suppress_from = 0},
+ 		    "suppress-cc=s" => \@suppress_cc,
+@@ -1776,6 +1780,9 @@ sub process_file {
+ 			push(@header, $_);
+ 		}
+ 	}
++	# Add computed headers, if applicable.
++	push @header, execute_cmd("header-cmd", $header_cmd, $t)
++		if defined $header_cmd;
+ 	# Now parse the header
+ 	foreach(@header) {
+ 		if (/^From /) {
+@@ -2006,15 +2013,30 @@ sub process_file {
+ 	}
+ }
+ 
++# Execute a command (e.g., $x_cmd) and return its output lines as an
++# array.
++sub execute_cmd {
++	my ($prefix, $cmd, $file) = @_;
++	my @lines = ();
++	open my $fh, "-|", "$cmd \Q$file\E"
++		or die sprintf(__("(%s) Could not execute '%s'"), $prefix, $cmd);
++	while (my $line = <$fh>) {
++		last if $line =~ /^$/;
++		push @lines, $line;
++	}
++	close $fh
++	    or die sprintf(__("(%s) failed to close pipe to '%s'"), $prefix, $cmd);
++	return @lines;
++}
++
+ # Execute a command (e.g. $to_cmd) to get a list of email addresses
+ # and return a results array
+ sub recipients_cmd {
+ 	my ($prefix, $what, $cmd, $file) = @_;
+-
++	my @lines = ();
+ 	my @addresses = ();
+-	open my $fh, "-|", "$cmd \Q$file\E"
+-	    or die sprintf(__("(%s) Could not execute '%s'"), $prefix, $cmd);
+-	while (my $address = <$fh>) {
++	@lines = execute_cmd($prefix, $cmd, $file);
++	for my $address (@lines) {
+ 		$address =~ s/^\s*//g;
+ 		$address =~ s/\s*$//g;
+ 		$address = sanitize_address($address);
+@@ -2023,8 +2045,6 @@ sub recipients_cmd {
+ 		printf(__("(%s) Adding %s: %s from: '%s'\n"),
+ 		       $prefix, $what, $address, $cmd) unless $quiet;
+ 		}
+-	close $fh
+-	    or die sprintf(__("(%s) failed to close pipe to '%s'"), $prefix, $cmd);
+ 	return @addresses;
+ }
+ 
+diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
+index 0de83b5d2b..3393725107 100755
+--- a/t/t9001-send-email.sh
++++ b/t/t9001-send-email.sh
+@@ -374,13 +374,16 @@ test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email'
+ 	)
+ '
+ 
+-test_expect_success $PREREQ 'setup tocmd and cccmd scripts' '
++test_expect_success $PREREQ 'setup cmd scripts' '
+ 	write_script tocmd-sed <<-\EOF &&
+ 	sed -n -e "s/^tocmd--//p" "$1"
+ 	EOF
+-	write_script cccmd-sed <<-\EOF
++	write_script cccmd-sed <<-\EOF &&
+ 	sed -n -e "s/^cccmd--//p" "$1"
+ 	EOF
++	write_script headercmd-sed <<-\EOF
++	sed -n -e "s/^headercmd--//p" "$1"
++	EOF
+ '
+ 
+ test_expect_success $PREREQ 'tocmd works' '
+@@ -410,6 +413,20 @@ test_expect_success $PREREQ 'cccmd works' '
+ 	grep "^	cccmd@example.com" msgtxt1
+ '
+ 
++test_expect_success $PREREQ 'headercmd works' '
++	clean_fake_sendmail &&
++	cp $patches headercmd.patch &&
++	echo "headercmd--X-Debbugs-CC: dummy@example.com" >>headercmd.patch &&
++	git send-email \
++		--from="Example <nobody@example.com>" \
++		--to=nobody@example.com \
++		--header-cmd=./headercmd-sed \
++		--smtp-server="$(pwd)/fake.sendmail" \
++		headercmd.patch \
++		&&
++	grep "^X-Debbugs-CC: dummy@example.com" msgtxt1
++'
++
+ test_expect_success $PREREQ 'reject long lines' '
+ 	z8=zzzzzzzz &&
+ 	z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 302f7c90ad..d5d88b99ed 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -232,7 +232,8 @@ (define-public git
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1mpjvhyw8mv2q941xny4d0gw3mb6b4bqaqbh73jd8b1v6zqpaps7"))))
+              "1mpjvhyw8mv2q941xny4d0gw3mb6b4bqaqbh73jd8b1v6zqpaps7"))
+            (patches (search-patches "git-header-cmd.patch"))))
    (build-system gnu-build-system)
    (native-inputs
     `(("native-perl" ,perl)
-- 
2.39.2





  parent reply	other threads:[~2023-04-24  2:31 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27  3:50 bug#58813: can't substitute etc/teams.scm command as doc suggests Maxim Cournoyer
2022-10-27  6:08 ` Liliana Marie Prikler
2022-10-27 12:40   ` Maxim Cournoyer
2022-10-27 16:27     ` Liliana Marie Prikler
2023-02-26  3:55 ` bug#58813: [PATCH] doc: Document how to use Patman for patches submission Maxim Cournoyer
2023-02-26  8:25   ` Liliana Marie Prikler
2023-02-26 17:11     ` Maxim Cournoyer
2023-02-27  0:45       ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2023-02-27 16:43         ` Maxim Cournoyer
2023-03-03  9:54   ` Ludovic Courtès
2023-03-03 17:26     ` Liliana Marie Prikler
2023-03-06 14:53       ` bug#58813: ‘guix style’ flaws Ludovic Courtès
2023-03-06 17:42         ` Maxim Cournoyer
2023-03-07  1:07     ` bug#58813: [PATCH] doc: Document how to use Patman for patches submission Maxim Cournoyer
2023-03-10  9:01       ` Ludovic Courtès
2023-03-10 14:07         ` Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 0/5] Fix teams.scm by use of a new --header-cmd git send-email option Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 1/5] gnu: git: Apply patch adding the --header-cmd feature Maxim Cournoyer
2023-04-23 17:00             ` Liliana Marie Prikler
2023-04-24  0:46               ` Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 2/5] teams: Add 'cc-members-header-cmd' action Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 3/5] teams: Add a configure-git action Maxim Cournoyer
2023-04-23 17:03             ` Liliana Marie Prikler
2023-04-24  0:59               ` Maxim Cournoyer
2023-04-24  2:29               ` bug#58813: [PATCH v2 0/5] Fix teams.scm by use of a new --header-cmd git send-email option Maxim Cournoyer
2023-04-24  2:29               ` Maxim Cournoyer [this message]
2023-04-24  2:29               ` bug#58813: [PATCH v2 2/5] teams: Add 'cc-members-header-cmd' action Maxim Cournoyer
2023-04-24  2:29               ` bug#58813: [PATCH v2 3/5] Makefile.am: Auto-configure Git on 'make' Maxim Cournoyer
2023-04-24  4:22                 ` Liliana Marie Prikler
2023-04-24 12:37                   ` Maxim Cournoyer
2023-04-28 14:28                 ` Josselin Poiret via Bug reports for GNU Guix
2023-05-01 16:38                   ` bug#58813: can't substitute etc/teams.scm command as doc suggests Maxim Cournoyer
2023-04-24  2:29               ` bug#58813: [PATCH v2 4/5] teams: Add a 'cc-mentors-header-cmd' action Maxim Cournoyer
2023-04-24  2:29               ` bug#58813: [PATCH v2 5/5] doc: Simplify contributing section by automating git configuration Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 4/5] teams: Add a 'cc-mentors-header-cmd' action Maxim Cournoyer
2023-04-23 16:04           ` bug#58813: [PATCH 5/5] doc: Simplify contributing section by automating git configuration Maxim Cournoyer
2023-03-07 11:35 ` bug#58813: [PATCH v2] doc: Document how to use Patman for patches submission Simon Tournier
2023-03-07 16:46   ` Maxim Cournoyer
2023-03-07 17:39     ` Simon Tournier
2023-03-08  5:29       ` Liliana Marie Prikler
2023-03-08  8:47         ` Simon Tournier
2023-03-08 16:26           ` Maxim Cournoyer
2023-03-08 17:05             ` Simon Tournier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2899162d279cdd940bc91459b38ff1e2c3f4f0ec.1682303142.git.maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=58813@debbugs.gnu.org \
    --cc=liliana.prikler@gmail.com \
    --cc=ludo@gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.