Skip to content

Commit fb4cd88

Browse files
committed
Merge branch 'wk/pull-signoff'
"git pull" has been taught to accept "--[no-]signoff" option and pass it down to "git merge". * wk/pull-signoff: pull: pass --signoff/--no-signoff to "git merge"
2 parents a1bf46e + 3a4d2c7 commit fb4cd88

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
-m <msg>::
7668
Set the commit message to be used for the merge commit (in
7769
case one is created).

Documentation/merge-options.txt

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

60+
--signoff::
61+
--no-signoff::
62+
Add Signed-off-by line by the committer at the end of the commit
63+
log message. The meaning of a signoff depends on the project,
64+
but it typically certifies that committer has
65+
the rights to submit this work under the same license and
66+
agrees to a Developer Certificate of Origin
67+
(see http://developercertificate.org/ for more information).
68+
+
69+
With --no-signoff do not add a Signed-off-by line.
6070

6171
--stat::
6272
-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)