format-patch: document and test --reroll-count
PATCH 1/2 format-patch: document and test --reroll-count
---
* This comes on top of the 7 patches that have been cooking on 'pu'
(http://thread.gmane.org/gmane.comp.version-control.git/212036),
and I am planning to squash this to 7/7 that adds --reroll-count option to the code. This is sent as a separate patch to keep reviewing easier.
Documentation/git-format-patch.txt | 10 +++++++++- t/t4014-format-patch.sh | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
Documentation/git-format-patch.txt +9 -1
@@ -18,7 +18,7 @@ SYNOPSIS [--start-number <n>] [--numbered-files] [--in-reply-to=Message-Id] [--suffix=.<sfx>] [--ignore-if-in-upstream] - [--subject-prefix=Subject-Prefix] + [--subject-prefix=Subject-Prefix] [--reroll-count <n>] [--to=<email>] [--cc=<email>] [--cover-letter] [--quiet] [<common diff options>]
@@ -166,6 +166,14 @@ will want to ensure that threading is disabled for `git send-email`. allows for useful naming of a patch series, and can be combined with the `--numbered` option. +--reroll-count=<n>:: + Mark the series as the <n>-th iteration of the topic. The + output filenames have `v<n>` pretended to them, and the + subject prefix ("PATCH" by default, but configurable via the + `--subject-prefix` option) has ` v<n>` appended to it. E.g. + `--reroll-count=4` may produce `v4-0001-add-makefile.patch` + file that has "Subject: [PATCH v4 1/20] Add makefile" in it. + --to=<email>:: Add a `To:` header to the email headers. This is in addition to any configured headers, and may be used multiple times.
t/t4014-format-patch.sh +8 -0
@@ -237,6 +237,14 @@ test_expect_success 'multiple files' ' ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch ' +test_expect_success 'reroll count' ' + rm -fr patches && + git format-patch -o patches --cover-letter --reroll-count 4 master..side >list && + ! grep -v "^patches/v4-000[0-3]-" list && + sed -n -e "/^Subject: /p" $(cat list) >subjects && + ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects +' + check_threading () { expect="$1" && shift &&
Signature · 1 line
1.8.0.9.g5e84801
PATCH 2/2 format-patch: give --reroll-count a short synonym -v
Accept "-v" as a synonym to "--reroll-count", so that users can say "git format-patch -v4 master", instead of having to fully spell it out as "git format-patch --reroll-count=4 master".
---
* As I do not think of a reason why users would want to tell the command to be "verbose", I think it may be OK to squat on the short and sweet single letter option, but I do not mind dropping it.
Documentation/git-format-patch.txt | 3 ++- builtin/log.c | 2 +- t/t4014-format-patch.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-)
Documentation/git-format-patch.txt +2 -1
@@ -18,7 +18,7 @@ SYNOPSIS [--start-number <n>] [--numbered-files] [--in-reply-to=Message-Id] [--suffix=.<sfx>] [--ignore-if-in-upstream] - [--subject-prefix=Subject-Prefix] [--reroll-count <n>] + [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>] [--to=<email>] [--cc=<email>] [--cover-letter] [--quiet] [<common diff options>]
@@ -166,6 +166,7 @@ will want to ensure that threading is disabled for `git send-email`. allows for useful naming of a patch series, and can be combined with the `--numbered` option. +-v <n>:: --reroll-count=<n>:: Mark the series as the <n>-th iteration of the topic. The output filenames have `v<n>` pretended to them, and the
builtin/log.c +1 -1
@@ -1081,7 +1081,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) N_("use <sfx> instead of '.patch'")),OPT_INTEGER (0 ,"start-number" , &start_number,N_ ("start numbering patches at <n> instead of 1" )), -OPT_INTEGER (0 ,"reroll-count" , &reroll_count, +OPT_INTEGER ('v' ,"reroll-count" , &reroll_count,N_ ("mark the series as Nth re-roll" )), { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"), N_("Use [<prefix>] instead of [PATCH]"),
t/t4014-format-patch.sh +8 -0
@@ -245,6 +245,14 @@ test_expect_success 'reroll count' ' ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects ' +test_expect_success 'reroll count (-v)' ' + rm -fr patches && + git format-patch -o patches --cover-letter -v 4 master..side >list && + ! grep -v "^patches/v4-000[0-3]-" list && + sed -n -e "/^Subject: /p" $(cat list) >subjects && + ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects +' + check_threading () { expect="$1" && shift &&
Signature · 1 line
1.8.0.9.g5e84801
Re: [PATCH 2/2] format-patch: give --reroll-count a short synonym -v
From: "Junio C Hamano" <[email protected]> Sent: Wednesday, January 02, 2013 10:42 PM
Quoted 60 lines
Accept "-v" as a synonym to "--reroll-count", so that users can say "git format-patch -v4 master", instead of having to fully spell it out as "git format-patch --reroll-count=4 master".
Signed-off-by Junio C Hamano <[email protected]>---
* As I do not think of a reason why users would want to tell the command to be "verbose", I think it may be OK to squat on the short and sweet single letter option, but I do not mind dropping it.Documentation/git-format-patch.txt | 3 ++- builtin/log.c | 2 +- t/t4014-format-patch.sh | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-)Documentation/git-format-patch.txt +1
-1@@ -18,7 +18,7 @@ SYNOPSIS [--start-number <n>] [--numbered-files] [--in-reply-to=Message-Id] [--suffix=.<sfx>] [--ignore-if-in-upstream] - [--subject-prefix=Subject-Prefix] [--reroll-count <n>] + [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>] [--to=<email>] [--cc=<email>] [--cover-letter] [--quiet] [<common diff options>]@@ -166,6 +166,7 @@ will want to ensure that threading is disabled for
git send-email.
allows for useful naming of a patch series, and can be combined with the--numberedoption.+-v <n>::
--reroll-count=<n>::
Mark the series as the <n>-th iteration of the topic. The output filenames havev<n>pretended to them, and thebuiltin/log.c +1
-1@@ -1081,7 +1081,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) N_("use <sfx> instead of '.patch'")),OPT_INTEGER (0 ,"start-number" , &start_number,N_ ("start numbering patches at <n> instead of 1" )), -OPT_INTEGER (0 ,"reroll-count" , &reroll_count, +OPT_INTEGER ('v' ,"reroll-count" , &reroll_count,N_ ("mark the series as Nth re-roll" )), { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),N_("Use [<prefix>] instead of [PATCH]"),t/t4014-format-patch.sh +0
-0@@ -245,6 +245,14 @@ test_expect_success 'reroll count' ' ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects'
Quoted 4 lines
+test_expect_success 'reroll count (-v)' '
+ rm -fr patches &&
+ git format-patch -o patches --cover-letter -v 4 master..side >list &&
Shouldn't this be using the sticked form -v4 as described in the commit message and gitcli? Or is this being too picky?
Quoted 11 lines
+ ! grep -v "^patches/v4-000[0-3]-" list &&
+ sed -n -e "/^Subject: /p" $(cat list) >subjects &&
+ ! grep -v "^Subject: \[PATCH v4 [0-3]/3\] " subjects +'
+check_threading() {
expect="$1" &&
shift &&Signature · 1 line
1.8.0.9.g5e84801
Re: [PATCH 2/2] format-patch: give --reroll-count a short synonym -v
Quoted 7 lines · Philip Oakley
Quoted 4 lines
+test_expect_success 'reroll count (-v)' '
+ rm -fr patches &&
+ git format-patch -o patches --cover-letter -v 4 master..side >list &&Shouldn't this be using the sticked form -v4 as described in the commit message and gitcli?
I personally do not care too deeply either way.
Both styles seem to work, and if/when we break parse-options API implementation, this test will break and we will notice, which might be an added plus ;-)
Re: [PATCH 2/2] format-patch: give --reroll-count a short synonym -v
Quoted 11 lines · Junio C Hamano
Quoted 7 lines · Philip Oakley
Quoted 4 lines
+test_expect_success 'reroll count (-v)' '
+ rm -fr patches &&
+ git format-patch -o patches --cover-letter -v 4 master..side >list &&Shouldn't this be using the sticked form -v4 as described in the commit message and gitcli?
I personally do not care too deeply either way.
Actually, I do care. And in this case both should work.
Separating argument from the option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can write the mandatory option parameter to an option as a separate word on the command line. That means that all the following uses work:
----------------------------
$ git foo --long-opt=Arg
$ git foo --long-opt Arg
$ git foo -oArg
$ git foo -o Arg
----------------------------
As "reroll-count" must always be followed by nth (in other words, it is not optional), the following does not apply.
However, this is *NOT* allowed for switches with an optional value, where the 'sticked' form must be used: