Skip to content

Commit 69f4ce5

Browse files
committed
send-email: do not reverse the command line arguments
The loop picks elements from @argv one by one, sifts them into arguments meant for format-patch and the script itself, and pushes them to @files and @rev_list_opts arrays. Pick elements from @argv starting at the beginning using shift, instead of at the end using pop, as push appends them to the end of the array. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f871c6 commit 69f4ce5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

git-send-email.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ ($)
421421
# Now that all the defaults are set, process the rest of the command line
422422
# arguments and collect up the files that need to be processed.
423423
my @rev_list_opts;
424-
while (my $f = pop @ARGV) {
424+
while (defined(my $f = shift @ARGV)) {
425425
if ($f eq "--") {
426426
push @rev_list_opts, "--", @ARGV;
427427
@ARGV = ();

t/t9001-send-email.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,17 @@ test_expect_success 'detects ambiguous reference/file conflict' '
300300
grep disambiguate errors
301301
'
302302

303+
test_expect_success 'feed two files' '
304+
rm -fr outdir &&
305+
git format-patch -2 -o outdir &&
306+
GIT_SEND_EMAIL_NOTTY=1 git send-email \
307+
--dry-run \
308+
--from="Example <[email protected]>" \
309+
310+
outdir/000?-*.patch 2>errors >out &&
311+
grep "^Subject: " out >subjects &&
312+
test "z$(sed -n -e 1p subjects)" = "zSubject: [PATCH 1/2] Second." &&
313+
test "z$(sed -n -e 2p subjects)" = "zSubject: [PATCH 2/2] add master"
314+
'
315+
303316
test_done

0 commit comments

Comments
 (0)