From: Junio C Hamano <gitster@pobox•com>
To: Michael J Gruber <git@grubix•eu>
Cc: git@vger•kernel.org, hIpPy <hippy2981@gmail•com>
Subject: Re: [PATCH v2 3/3] merge: save merge state earlier
Date: Mon, 21 Aug 2017 17:38:33 -0700 [thread overview]
Message-ID: <xmqqk21w4et2.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <407f205e2b824d56c652411256eea3c0047576ef.1503319519.git.git@grubix.eu> (Michael J. Gruber's message of "Mon, 21 Aug 2017 14:53:16 +0200")
Michael J Gruber <git@grubix•eu> writes:
> static void prepare_to_commit(struct commit_list *remoteheads)
> {
> struct strbuf msg = STRBUF_INIT;
> @@ -767,6 +768,8 @@ static void prepare_to_commit(struct commit_list *remoteheads)
> strbuf_commented_addf(&msg, _(merge_editor_comment), comment_line_char);
> if (signoff)
> append_signoff(&msg, ignore_non_trailer(msg.buf, msg.len), 0);
> + if (!squash)
> + write_merge_heads(remoteheads);
> write_file_buf(git_path_merge_msg(), msg.buf, msg.len);
> if (run_commit_hook(0 < option_edit, get_index_file(), "prepare-commit-msg",
> git_path_merge_msg(), "merge", NULL))
I can understand that you would never want to write out MERGE_HEAD
while squashing, but I somehow think it would be a bug in the caller
to call prepare_to_commit(), whose point is to prepare the merge
message to be recorded in the resulting merge commit, when the user
gave us the "--squash" option, which is an explicit instruction that
the user does not want the merge commit the message is used.
Can squash ever be true in this function?
This function has two callsites: merge_trivial() and
finish_automerge().
I think merge_trivial() will not be called under "--squash", which
turns option_commit off and the only callsite of it is inside an
else-if clause that requres option_commit to be true. You can do a
similar deduction around the "automerge_was_ok" variable to see if
finish_automerge() can be called when "--squash" is given; I suspect
the answer may be no.
> diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
> index 2ebda509ac..80194b79f9 100755
> --- a/t/t7600-merge.sh
> +++ b/t/t7600-merge.sh
> @@ -774,4 +774,19 @@ test_expect_success 'merge can be completed with --continue' '
> verify_parents $c0 $c1
> '
>
> +write_script .git/FAKE_EDITOR <<EOF
> +# kill -TERM command added below.
> +EOF
> +
> +test_expect_success EXECKEEPSPID 'killed merge can be completed with --continue' '
> + git reset --hard c0 &&
> + ! "$SHELL_PATH" -c '\''
> + echo kill -TERM $$ >> .git/FAKE_EDITOR
> + GIT_EDITOR=.git/FAKE_EDITOR
> + export GIT_EDITOR
> + exec git merge --no-ff --edit c1'\'' &&
This is a tricky construct. You "reserve" a process ID by using a
shell, arrange it to be killed and then using "exec" to make it the
"git merge" program to be killed. I kind of like the convolutedness.
> + git merge --continue &&
> + verify_parents $c0 $c1
> +'
> +
> test_done
next prev parent reply other threads:[~2017-08-22 0:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 22:35 Git makes a merge commit but as a normal (non-merge) commit hIpPy
2017-08-21 10:03 ` Michael J Gruber
2017-08-21 10:06 ` [PATCH] merge: save merge state earlier Michael J Gruber
2017-08-21 12:53 ` [PATCH v2 0/3] Keep merge during kills Michael J Gruber
2017-08-21 12:53 ` [PATCH v2 1/3] Documentation/git-merge: explain --continue Michael J Gruber
2017-08-21 16:43 ` Martin Ågren
2017-08-22 9:26 ` Michael J Gruber
2017-08-22 10:06 ` Martin Ågren
2017-08-22 15:24 ` hIpPy
2017-08-22 16:11 ` Junio C Hamano
2017-08-23 12:10 ` [PATCH v3 0/4] Keep merge during kills Michael J Gruber
2017-08-23 12:10 ` [PATCH v3 1/4] Documentation/git-merge: explain --continue Michael J Gruber
2017-08-23 12:10 ` [PATCH v3 2/4] merge: clarify call chain Michael J Gruber
2017-08-23 12:10 ` [PATCH v3 3/4] merge: split write_merge_state in two Michael J Gruber
2017-08-23 12:10 ` [PATCH v3 4/4] merge: save merge state earlier Michael J Gruber
2017-08-22 0:20 ` [PATCH v2 1/3] Documentation/git-merge: explain --continue Junio C Hamano
2017-08-21 12:53 ` [PATCH v2 2/3] merge: split write_merge_state in two Michael J Gruber
2017-08-22 0:20 ` Junio C Hamano
2017-08-21 12:53 ` [PATCH v2 3/3] merge: save merge state earlier Michael J Gruber
2017-08-22 0:38 ` Junio C Hamano [this message]
2017-08-22 9:36 ` Michael J Gruber
2017-08-22 16:03 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk21w4et2.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@grubix$(echo .)eu \
--cc=git@vger$(echo .)kernel.org \
--cc=hippy2981@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox