pull: pass --signoff/--no-signoff to "git merge"

merge can take --signoff, but without pull passing --signoff down, it is inconvenient to use; allow 'pull' to take the option and pass it through. The order of options in merge-options.txt is mostly alphabetical by long option since 7c85d274 (Documentation/merge-options.txt: order options in alphabetical groups, 2009-10-22). The long-option bit didn't make it into the commit message, but it's under the fold in [1]. I've put --signoff between --log and --stat to preserve the alphabetical order. [1]: https://public-inbox.org/git/87iqe7zspn.fsf@jondo.cante.net/ Signed-off-by: W. Trevor King <wking@tremily.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>

W. Trevor King committed Oct 12, 2017 at 11:35 UTC 3a4d2c743750dbc3c8165f362c0a3c0d1c775c8a
4 files changed +61 -8
Documentation/git-merge.txt
-8
@@ -64,14 +64,6 @@ OPTIONS
64 -------
65 include::merge-options.txt[]
66
67 ---signoff::
68 - Add Signed-off-by line by the committer at the end of the commit
69 - log message. The meaning of a signoff depends on the project,
70 - but it typically certifies that committer has
71 - the rights to submit this work under the same license and
72 - agrees to a Developer Certificate of Origin
73 - (see http://developercertificate.org/ for more information).
74 -
67 -S[<keyid>]::
68 --gpg-sign[=<keyid>]::
69 GPG-sign the resulting merge commit. The `keyid` argument is
Documentation/merge-options.txt
+10
@@ -51,6 +51,16 @@ set to `no` at the beginning of them.
51 With --no-log do not list one-line descriptions from the
52 actual commits being merged.
53
54 +--signoff::
55 +--no-signoff::
56 + Add Signed-off-by line by the committer at the end of the commit
57 + log message. The meaning of a signoff depends on the project,
58 + but it typically certifies that committer has
59 + the rights to submit this work under the same license and
60 + agrees to a Developer Certificate of Origin
61 + (see http://developercertificate.org/ for more information).
62 ++
63 +With --no-signoff do not add a Signed-off-by line.
64
65 --stat::
66 -n::
builtin/pull.c
+6
@@ -86,6 +86,7 @@ static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
86 static enum rebase_type opt_rebase = -1;
87 static char *opt_diffstat;
88 static char *opt_log;
89 +static char *opt_signoff;
90 static char *opt_squash;
91 static char *opt_commit;
92 static char *opt_edit;
@@ -142,6 +143,9 @@ static struct option pull_options[] = {
143 OPT_PASSTHRU(0, "log", &opt_log, N_("n"),
144 N_("add (at most <n>) entries from shortlog to merge commit message"),
145 PARSE_OPT_OPTARG),
146 + OPT_PASSTHRU(0, "signoff", &opt_signoff, NULL,
147 + N_("add Signed-off-by:"),
148 + PARSE_OPT_OPTARG),
149 OPT_PASSTHRU(0, "squash", &opt_squash, NULL,
150 N_("create a single commit instead of doing a merge"),
151 PARSE_OPT_NOARG),
@@ -594,6 +598,8 @@ static int run_merge(void)
598 argv_array_push(&args, opt_diffstat);
599 if (opt_log)
600 argv_array_push(&args, opt_log);
601 + if (opt_signoff)
602 + argv_array_push(&args, opt_signoff);
603 if (opt_squash)
604 argv_array_push(&args, opt_squash);
605 if (opt_commit)
t/t5521-pull-options.sh
+45
@@ -165,4 +165,49 @@ test_expect_success 'git pull --allow-unrelated-histories' '
165 )
166 '
167
168 +test_expect_success 'git pull does not add a sign-off line' '
169 + test_when_finished "rm -fr src dst actual" &&
170 + git init src &&
171 + test_commit -C src one &&
172 + git clone src dst &&
173 + test_commit -C src two &&
174 + git -C dst pull --no-ff &&
175 + git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
176 + test_must_be_empty actual
177 +'
178 +
179 +test_expect_success 'git pull --no-signoff does not add sign-off line' '
180 + test_when_finished "rm -fr src dst actual" &&
181 + git init src &&
182 + test_commit -C src one &&
183 + git clone src dst &&
184 + test_commit -C src two &&
185 + git -C dst pull --no-signoff --no-ff &&
186 + git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
187 + test_must_be_empty actual
188 +'
189 +
190 +test_expect_success 'git pull --signoff add a sign-off line' '
191 + test_when_finished "rm -fr src dst expected actual" &&
192 + echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
193 + git init src &&
194 + test_commit -C src one &&
195 + git clone src dst &&
196 + test_commit -C src two &&
197 + git -C dst pull --signoff --no-ff &&
198 + git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
199 + test_cmp expected actual
200 +'
201 +
202 +test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
203 + test_when_finished "rm -fr src dst actual" &&
204 + git init src &&
205 + test_commit -C src one &&
206 + git clone src dst &&
207 + test_commit -C src two &&
208 + git -C dst pull --signoff --no-signoff --no-ff &&
209 + git -C dst show -s --pretty="format:%(trailers)" HEAD >actual &&
210 + test_must_be_empty actual
211 +'
212 +
213 test_done