Skip to content

Commit 3a4d2c7

Browse files
wkinggitster
authored andcommitted
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 7c85d27 (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/[email protected]/ Signed-off-by: W. Trevor King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 111ef79 commit 3a4d2c7

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

Documentation/git-merge.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ OPTIONS
6464
-------
6565
include::merge-options.txt[]
6666

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-
7567
-S[<keyid>]::
7668
--gpg-sign[=<keyid>]::
7769
GPG-sign the resulting merge commit. The `keyid` argument is

Documentation/merge-options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ set to `no` at the beginning of them.
5151
With --no-log do not list one-line descriptions from the
5252
actual commits being merged.
5353

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.
5464

5565
--stat::
5666
-n::

builtin/pull.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
8686
static enum rebase_type opt_rebase = -1;
8787
static char *opt_diffstat;
8888
static char *opt_log;
89+
static char *opt_signoff;
8990
static char *opt_squash;
9091
static char *opt_commit;
9192
static char *opt_edit;
@@ -142,6 +143,9 @@ static struct option pull_options[] = {
142143
OPT_PASSTHRU(0, "log", &opt_log, N_("n"),
143144
N_("add (at most <n>) entries from shortlog to merge commit message"),
144145
PARSE_OPT_OPTARG),
146+
OPT_PASSTHRU(0, "signoff", &opt_signoff, NULL,
147+
N_("add Signed-off-by:"),
148+
PARSE_OPT_OPTARG),
145149
OPT_PASSTHRU(0, "squash", &opt_squash, NULL,
146150
N_("create a single commit instead of doing a merge"),
147151
PARSE_OPT_NOARG),
@@ -594,6 +598,8 @@ static int run_merge(void)
594598
argv_array_push(&args, opt_diffstat);
595599
if (opt_log)
596600
argv_array_push(&args, opt_log);
601+
if (opt_signoff)
602+
argv_array_push(&args, opt_signoff);
597603
if (opt_squash)
598604
argv_array_push(&args, opt_squash);
599605
if (opt_commit)

t/t5521-pull-options.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,49 @@ test_expect_success 'git pull --allow-unrelated-histories' '
165165
)
166166
'
167167

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+
168213
test_done

0 commit comments

Comments
 (0)