From: Junio C Hamano <gitster@pobox.com>
To: "W. Trevor King" <wking@tremily.us>
Cc: Git <git@vger.kernel.org>, "Łukasz Gryglicki" <lukaszgryglicki@o2.pl>
Subject: Re: [PATCH v2] pull: pass --signoff/--no-signoff to "git merge"
Date: Thu, 12 Oct 2017 19:11:14 +0900 [thread overview]
Message-ID: <xmqqk200znel.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <51d67d6d707182d4973d9961ab29358f26c4988a.1507796638.git.wking@tremily.us> (W. Trevor King's message of "Thu, 12 Oct 2017 01:46:39 -0700")
"W. Trevor King" <wking@tremily.us> writes:
> e379fdf3 (merge: refuse to create too cool a merge by default,
> 2016-03-18) gave a reason for *not* passing options from pull to
> merge:
>
> ...because such a "two project merge" would be done after fetching
> the other project into some location in the working tree of an
> existing project and making sure how well they fit together...
Read the above again and notice the phrase "two project merge". The
reasoning applies only to the --allow-unrelated-histories option.
It gave a reason for not passing *THAT* option and nothing else, and
does not mean to say anything about passing or not passing any other
options.
That is why I said the reference to that commit was irrelevant in
the context of this patch.
If you find somebody saying "we should not pass --signoff from pull
to merge" when we taught "--signoff" to "merge", then that may be
worth referring to, as this commit _will_ be changing that earlier
decision. I however do not think that is a case. Just saying
"merge can take --signoff, but without pull passing --signoff down,
it is inconvenient, so let's pass it through" is sufficient to
justify this change.
> diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
> index ded8f98dbe..82680a30f8 100755
> --- a/t/t5521-pull-options.sh
> +++ b/t/t5521-pull-options.sh
> @@ -165,4 +165,44 @@ test_expect_success 'git pull --allow-unrelated-histories' '
> )
> '
>
> +test_expect_success 'git pull does not add a sign-off line' '
> + test_when_finished "rm -fr src dst" &&
> + git init src &&
> + test_commit -C src one &&
> + git clone src dst &&
> + test_commit -C src two &&
> + git -C dst pull --no-ff &&
> + ! test_has_trailer -C dst HEAD Signed-off-by
> +'
> +
> +test_expect_success 'git pull --no-signoff does not add sign-off line' '
> + test_when_finished "rm -fr src dst" &&
> + git init src &&
> + test_commit -C src one &&
> + git clone src dst &&
> + test_commit -C src two &&
> + git -C dst pull --no-signoff --no-ff &&
> + ! test_has_trailer -C dst HEAD Signed-off-by
> +'
> +
> +test_expect_success 'git pull --signoff add a sign-off line' '
> + test_when_finished "rm -fr src dst" &&
> + git init src &&
> + test_commit -C src one &&
> + git clone src dst &&
> + test_commit -C src two &&
> + git -C dst pull --signoff --no-ff &&
> + test_has_trailer -C dst HEAD Signed-off-by "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
> +'
> +
> +test_expect_success 'git pull --no-signoff flag cancels --signoff flag' '
> + test_when_finished "rm -fr src dst actual" &&
> + git init src &&
> + test_commit -C src one &&
> + git clone src dst &&
> + test_commit -C src two &&
> + git -C dst pull --signoff --no-signoff --no-ff &&
> + ! test_has_trailer -C dst HEAD Signed-off-by
> +'
> +
> test_done
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index 1701fe2a06..08409b1c25 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -726,6 +726,49 @@ test_must_be_empty () {
> fi
> }
>
> +# Call test_has_trailer with the arguments:
> +# [-C <directory>] <object> <token> [<value>]
> +# where <object> is an object name as described in gitrevisions(7),
> +# <token> is a trailer token (e.g. 'Signed-off-by'), and
> +# <value> is an optional value (e.g. 'A U Thor <author@example.com>').
> +# test_has_trailer returns success if the specified trailer is found
> +# in the object content. If <value> is unset, any value will match.
> +#
> +# Both <token> and <value> are basic regular expressions.
> +#
> +# If the first argument is "-C", the second argument is used as a path for
> +# the git invocations.
> +test_has_trailer () {
> + INDIR=
> + case "$1" in
> + -C)
> + INDIR="$2"
> + shift 2 || error "<directory> not specified"
> + ;;
> + esac
> + INDIR="${INDIR:+${INDIR}/}"
> + OBJECT="$1"
> + shift || error "<object> not specified"
> + TOKEN="$1"
> + shift || error "<token> not specified"
> + SEP=':' # FIXME: read from trailer.separators?
> + CONTENT="$(git ${INDIR:+ -C "${INDIR}"} cat-file -p "${OBJECT}")" || error "object ${OBJECT} not found${INDIR:+ in ${INDIR}}"
> + PATTERN="^${TOKEN}${SEP}"
> + if test 0 -lt "$#"
> + then
> + VALUE="$1"
> + PATTERN="${PATTERN} *${VALUE}$"
> + fi
> + if (echo "${CONTENT}" | grep -q "${PATTERN}")
> + then
> + printf "%s found in:\n%s\n" "${PATTERN}" "${CONTENT}"
> + return 0
> + else
> + printf "%s not found in:\n%s\n" "${PATTERN}" "${CONTENT}"
> + return 1
> + fi
> +}
The reason why I suggested a simple "sed -n -e ...p" you used in
your original was because it could be used to extract not just one
Signed-off-by: lines to store in >actual, to be compared with an
expect that has multiple S-o-b lines and the output is in correct
order, etc. An elaborate filter that can onlyl give "found/not
found" boolean looks a bit over-engineered for no real gain.
> # Tests that its two parameters refer to the same revision
> test_cmp_rev () {
> git rev-parse --verify "$1" >expect.rev &&
next prev parent reply other threads:[~2017-10-12 10:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2017-10-12 18:35 ` [PATCH v3] " W. Trevor King
2017-10-13 1:48 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk200znel.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=lukaszgryglicki@o2.pl \
--cc=wking@tremily.us \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).