diff mbox series

[v2,1/2] send-email: extract execute_cmd from recipients_cmd

Message ID 20230425162631.13684-2-maxim.cournoyer@gmail.com (mailing list archive)
State Superseded
Headers show
Series send-email: add --header-cmd option | expand

Commit Message

Maxim Cournoyer April 25, 2023, 4:26 p.m. UTC
This refactor is to pave the way for the addition of the new
'--header-cmd' option to the send-email command.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
---
 git-send-email.perl | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Comments

Eric Sunshine April 25, 2023, 5:04 p.m. UTC | #1
On Tue, Apr 25, 2023 at 12:46 PM Maxim Cournoyer
<maxim.cournoyer@gmail.com> wrote:
> diff --git 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>

Let's avoid this change, please. Many people have worked on this file
over the years -- often making changes far more substantial than those
made by this patch series -- who have not staked such a claim.
Maxim Cournoyer April 25, 2023, 7:09 p.m. UTC | #2
Hi Eric,

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Tue, Apr 25, 2023 at 12:46 PM Maxim Cournoyer
> <maxim.cournoyer@gmail.com> wrote:
>> diff --git 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>
>
> Let's avoid this change, please. Many people have worked on this file
> over the years -- often making changes far more substantial than those
> made by this patch series -- who have not staked such a claim.

I don't mind to drop this hunk if it's unwelcome/not current practice.
I didn't mean to try to steal anyone's spotlight :-).  I know this
contribution is tiny; I barely write Perl (it's still enough of a change
to be protected by copyright though, but I don't mind too much).

Cheers,
Felipe Contreras May 2, 2023, 6:39 p.m. UTC | #3
Maxim Cournoyer wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> 
> > On Tue, Apr 25, 2023 at 12:46 PM Maxim Cournoyer
> > <maxim.cournoyer@gmail.com> wrote:
> >> diff --git 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>
> >
> > Let's avoid this change, please. Many people have worked on this file
> > over the years -- often making changes far more substantial than those
> > made by this patch series -- who have not staked such a claim.
> 
> I don't mind to drop this hunk if it's unwelcome/not current practice.

In most open source projects the practice is that only the top one or two
contributors are mentioned.

> it's still enough of a change to be protected by copyright though, but
> I don't mind too much.

My understanding is that your work is protected by copyright laws
regardless of whether or not a copyright notice exists. Not that it
would matter much in practice though, because the cases where copyright
matters in open source projects is very fringe.

Cheers.
Maxim Cournoyer May 2, 2023, 8:46 p.m. UTC | #4
Hi,

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Maxim Cournoyer wrote:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>> 
>> > On Tue, Apr 25, 2023 at 12:46 PM Maxim Cournoyer
>> > <maxim.cournoyer@gmail.com> wrote:
>> >> diff --git 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>
>> >
>> > Let's avoid this change, please. Many people have worked on this file
>> > over the years -- often making changes far more substantial than those
>> > made by this patch series -- who have not staked such a claim.
>> 
>> I don't mind to drop this hunk if it's unwelcome/not current practice.
>
> In most open source projects the practice is that only the top one or two
> contributors are mentioned.

I see.  I got used adding copyright lines from contributing to GNU Guix,
which retains everyone's minimally substantial changes copyright notices
(if they wish), but that's probably not too common, given even the GNU
maintainer's manual says [0]:

   But if contributors are not all assigning their copyrights to a
   single copyright holder, it can easily happen that one file has
   several copyright holders. Each contributor of nontrivial text is a
   copyright holder.

   In that case, you should always include a copyright notice in the
   name of main copyright holder of the file. You can also include
   copyright notices for other copyright holders as well, and this is a
   good idea for those who have contributed a large amount and for those
   who specifically ask for notices in their names. (Sometimes the
   license on code that you copy in may require preserving certain
   copyright notices.) But you don’t have to include a notice for
   everyone who contributed to the file (which would be rather
   inconvenient).

[0]  https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html

>> it's still enough of a change to be protected by copyright though, but
>> I don't mind too much.
>
> My understanding is that your work is protected by copyright laws
> regardless of whether or not a copyright notice exists. Not that it
> would matter much in practice though, because the cases where copyright
> matters in open source projects is very fringe.

You are right; written works are automatically protected by copyright.
I think copyright ownership would matter in case the copyright holders
want to intent legal action against an entity violating the license of
the Git project (GPL v2).  Hopefully that'll never be necessary.
Felipe Contreras May 2, 2023, 9:50 p.m. UTC | #5
Maxim Cournoyer wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > Maxim Cournoyer wrote:
> >> Eric Sunshine <sunshine@sunshineco.com> writes:
> >> 
> >> > On Tue, Apr 25, 2023 at 12:46 PM Maxim Cournoyer
> >> > <maxim.cournoyer@gmail.com> wrote:
> >> >> diff --git 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>
> >> >
> >> > Let's avoid this change, please. Many people have worked on this file
> >> > over the years -- often making changes far more substantial than those
> >> > made by this patch series -- who have not staked such a claim.
> >> 
> >> I don't mind to drop this hunk if it's unwelcome/not current practice.
> >
> > In most open source projects the practice is that only the top one or two
> > contributors are mentioned.
> 
> I see.  I got used adding copyright lines from contributing to GNU Guix,
> which retains everyone's minimally substantial changes copyright notices
> (if they wish), but that's probably not too common, given even the GNU
> maintainer's manual says [0]:

I would say GNU practices are not what most OSS projects follow.

> >> it's still enough of a change to be protected by copyright though, but
> >> I don't mind too much.
> >
> > My understanding is that your work is protected by copyright laws
> > regardless of whether or not a copyright notice exists. Not that it
> > would matter much in practice though, because the cases where copyright
> > matters in open source projects is very fringe.
> 
> You are right; written works are automatically protected by copyright.
> I think copyright ownership would matter in case the copyright holders
> want to intent legal action against an entity violating the license of
> the Git project (GPL v2).  Hopefully that'll never be necessary.

Yes, that is one instance, but it only matters if your wishes contradict those
of the other copyright holders, that is: they want to sue, and you don't, or
you don't want to sue, and they do. As long as your wishes align the those of
the other developers in the Git community, it doesn't matter.

Cheers.
diff mbox series

Patch

diff --git a/git-send-email.perl b/git-send-email.perl
index fd8cd0d46f..b8d77ad214 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)
 #
@@ -2006,15 +2007,29 @@  sub process_file {
 	}
 }
 
+# Execute a command 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 +2038,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;
 }