@matheusbsbs / matheus-bagliano / commits / 69f4ce5537
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Nov 30, 2008 at 22:38 UTC 69f4ce553708ee5ce474faaa9c45312f38aad563
2 files changed +14 -1
git-send-email.perl
+1 -1
@@ -421,7 +421,7 @@ EOF
421 # Now that all the defaults are set, process the rest of the command line
422 # arguments and collect up the files that need to be processed.
423 my @rev_list_opts;
424 -while (my $f = pop @ARGV) {
424 +while (defined(my $f = shift @ARGV)) {
425 if ($f eq "--") {
426 push @rev_list_opts, "--", @ARGV;
427 @ARGV = ();
t/t9001-send-email.sh
+13
@@ -300,4 +300,17 @@ test_expect_success 'detects ambiguous reference/file conflict' '
300 grep disambiguate errors
301 '
302
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 <nobody@example.com>" \
309 + --to=nobody@example.com \
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 +
316 test_done