git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] pull: pass --signoff/--no-signoff to "git merge"
@ 2017-10-11 20:10 W. Trevor King
  2017-10-12  1:17 ` Junio C Hamano
  2017-10-12  8:46 ` [PATCH v2] " W. Trevor King
  0 siblings, 2 replies; 11+ messages in thread
From: W. Trevor King @ 2017-10-11 20:10 UTC (permalink / raw)
  To: Git; +Cc: Junio C Hamano, Łukasz Gryglicki, W. Trevor King

Following 09c2cb87 (pull: pass --allow-unrelated-histories to "git
merge", 2016-03-18) with the tests also drawing on 14d01b4f (merge:
add a --signoff flag, 2017-07-04).

The order of options in merge-options.txt isn't clear to me, but I've
put --signoff between --log and --stat as somewhat alphabetized and
having an "add to the commit message" function like --log.

The tests aren't as extensive as t7614-merge-signoff.sh, but they
exercises both the --signoff and --no-signoff options.  There may be a
more efficient way to set them up (like t7614-merge-signoff.sh's
test_setup), but with all the pull options packed into a single test
script it seemed easiest to just copy/paste the duplicate setup code.

09c2cb87 didn't motivate the addition of --allow-unrelated-histories
to pull; only citing the reason from e379fdf3 (merge: refuse to create
too cool a merge by default, 2016-03-18) gave for *not* including it.
I like having both exposed in pull because while the fetch-and-merge
approach might be a more popular way to judge "how well they fit
together", you can also do that after an optimistic pull.  And in
cases where an optimistic pull is likely to succeed, suggesting it is
easier to explain to Git newbies than a FETCH_HEAD merge.

Signed-off-by: W. Trevor King <wking@tremily.us>
---
 Documentation/git-merge.txt     |  8 --------
 Documentation/merge-options.txt | 10 ++++++++++
 builtin/pull.c                  |  8 ++++++++
 t/t5521-pull-options.sh         | 43 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 4df6431c34..0ada8c856b 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -64,14 +64,6 @@ OPTIONS
 -------
 include::merge-options.txt[]
 
---signoff::
-	Add Signed-off-by line by the committer at the end of the commit
-	log message.  The meaning of a signoff depends on the project,
-	but it typically certifies that committer has
-	the rights to submit this work under the same license and
-	agrees to a Developer Certificate of Origin
-	(see http://developercertificate.org/ for more information).
-
 -S[<keyid>]::
 --gpg-sign[=<keyid>]::
 	GPG-sign the resulting merge commit. The `keyid` argument is
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 4e32304301..f394622d65 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -51,6 +51,16 @@ set to `no` at the beginning of them.
 With --no-log do not list one-line descriptions from the
 actual commits being merged.
 
+--signoff::
+--no-signoff::
+	Add Signed-off-by line by the committer at the end of the commit
+	log message.  The meaning of a signoff depends on the project,
+	but it typically certifies that committer has
+	the rights to submit this work under the same license and
+	agrees to a Developer Certificate of Origin
+	(see http://developercertificate.org/ for more information).
++
+With --no-signoff do not add a Signed-off-by line.
 
 --stat::
 -n::
diff --git a/builtin/pull.c b/builtin/pull.c
index 6f772e8a22..4469342f51 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -97,6 +97,7 @@ static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
 static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
 static char *opt_gpg_sign;
 static int opt_allow_unrelated_histories;
+static int opt_signoff;
 
 /* Options passed to git-fetch */
 static char *opt_all;
@@ -175,6 +176,9 @@ static struct option pull_options[] = {
 	OPT_SET_INT(0, "allow-unrelated-histories",
 		    &opt_allow_unrelated_histories,
 		    N_("allow merging unrelated histories"), 1),
+	OPT_BOOL(0, "signoff",
+		    &opt_signoff,
+		    N_("add Signed-off-by:")),
 
 	/* Options passed to git-fetch */
 	OPT_GROUP(N_("Options related to fetching")),
@@ -610,6 +614,10 @@ static int run_merge(void)
 		argv_array_push(&args, opt_gpg_sign);
 	if (opt_allow_unrelated_histories > 0)
 		argv_array_push(&args, "--allow-unrelated-histories");
+	if (opt_signoff > 0)
+		argv_array_push(&args, "--signoff");
+	else
+		argv_array_push(&args, "--no-signoff");
 
 	argv_array_push(&args, "FETCH_HEAD");
 	ret = run_command_v_opt(args.argv, RUN_GIT_CMD);
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index ded8f98dbe..d95789ab8c 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -165,4 +165,47 @@ test_expect_success 'git pull --allow-unrelated-histories' '
 	)
 '
 
+test_expect_success 'git pull --signoff add a sign-off line' '
+	test_when_finished "rm -fr src dst actual expected" &&
+	cat >expected <<-EOF &&
+		Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
+	EOF
+	git init src &&
+	(
+		cd src &&
+		test_commit one
+	) &&
+	git clone src dst &&
+	(
+		cd src &&
+		test_commit two
+	) &&
+	(
+		cd dst &&
+		git pull --signoff --no-ff &&
+		git cat-file commit HEAD | tail -n1 >../actual
+	) &&
+	test_cmp expected actual
+'
+
+test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
+	test_when_finished "rm -fr src dst actual" &&
+	git init src &&
+	(
+		cd src &&
+		test_commit one
+	) &&
+	git clone src dst &&
+	(
+		cd src &&
+		test_commit two
+	) &&
+	(
+		cd dst &&
+		git pull --signoff --no-signoff --no-ff &&
+		git cat-file commit HEAD | sed -n /Signed-off-by/p >../actual
+	) &&
+	test_must_be_empty actual
+'
+
 test_done
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-13  1:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11 20:10 [PATCH] pull: pass --signoff/--no-signoff to "git merge" W. Trevor King
2017-10-12  1:17 ` Junio C Hamano
2017-10-12  5:30   ` W. Trevor King
2017-10-12  5:42     ` Junio C Hamano
2017-10-12  6:23       ` W. Trevor King
2017-10-12 11:08   ` Junio C Hamano
2017-10-12  8:46 ` [PATCH v2] " W. Trevor King
2017-10-12  9:18   ` W. Trevor King
2017-10-12 10:11   ` Junio C Hamano
2017-10-12 18:35   ` [PATCH v3] " W. Trevor King
2017-10-13  1:48     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).