git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
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 2/3] merge: split write_merge_state in two
Date: Mon, 21 Aug 2017 17:20:06 -0700	[thread overview]
Message-ID: <xmqqshgk4fnt.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1fa72c32925d98a5ce8c96a2b504b2e4278dcfff.1503319519.git.git@grubix.eu> (Michael J. Gruber's message of "Mon, 21 Aug 2017 14:53:15 +0200")

Michael J Gruber <git@grubix.eu> writes:

> write_merge_state() writes out the merge heads, mode, and msg. But we
> may want to write out heads, mode without the msg. So, split out heads
> (+mode) into a separate function write_merge_heads() that is called by
> write_merge_state().
>
> No funtional change so far.

"We may want to" leaves readers in suspense.  Hopefully 3/3 makes it
clear why we may in what situation.

One thing this changes is that we used to write merge-heads first,
then message and then finally mode, but now we write merge-heads,
then mode and finally message.  So killing us in the middle may
leave different set of files on the filesystem.  It is unclear from
the above description and the patch text if that is a potential
issue.

Let's keep reading ;-)

Thanks.

>
> Signed-off-by: Michael J Gruber <git@grubix.eu>
> ---
>  builtin/merge.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index cc57052993..86f0adde3b 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -908,7 +908,7 @@ static int setup_with_upstream(const char ***argv)
>  	return i;
>  }
>  
> -static void write_merge_state(struct commit_list *remoteheads)
> +static void write_merge_heads(struct commit_list *remoteheads)
>  {
>  	struct commit_list *j;
>  	struct strbuf buf = STRBUF_INIT;
> @@ -924,8 +924,6 @@ static void write_merge_state(struct commit_list *remoteheads)
>  		strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
>  	}
>  	write_file_buf(git_path_merge_head(), buf.buf, buf.len);
> -	strbuf_addch(&merge_msg, '\n');
> -	write_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);
>  
>  	strbuf_reset(&buf);
>  	if (fast_forward == FF_NO)
> @@ -933,6 +931,13 @@ static void write_merge_state(struct commit_list *remoteheads)
>  	write_file_buf(git_path_merge_mode(), buf.buf, buf.len);
>  }
>  
> +static void write_merge_state(struct commit_list *remoteheads)
> +{
> +	write_merge_heads(remoteheads);
> +	strbuf_addch(&merge_msg, '\n');
> +	write_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);
> +}
> +
>  static int default_edit_option(void)
>  {
>  	static const char name[] = "GIT_MERGE_AUTOEDIT";

  reply	other threads:[~2017-08-22  0:20 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 [this message]
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
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

  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=xmqqshgk4fnt.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@grubix.eu \
    --cc=git@vger.kernel.org \
    --cc=hippy2981@gmail.com \
    /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).