Skip to content

Commit 8e6a6bb

Browse files
mjggitster
authored andcommitted
merge: split write_merge_state in two
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, except when these non-atomic writes are interrupted: we write heads-mode-msg now when we used to write heads-msg-mode. Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62dc42b commit 8e6a6bb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

builtin/merge.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ static int setup_with_upstream(const char ***argv)
906906
return i;
907907
}
908908

909-
static void write_merge_state(struct commit_list *remoteheads)
909+
static void write_merge_heads(struct commit_list *remoteheads)
910910
{
911911
struct commit_list *j;
912912
struct strbuf buf = STRBUF_INIT;
@@ -922,15 +922,20 @@ static void write_merge_state(struct commit_list *remoteheads)
922922
strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
923923
}
924924
write_file_buf(git_path_merge_head(), buf.buf, buf.len);
925-
strbuf_addch(&merge_msg, '\n');
926-
write_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);
927925

928926
strbuf_reset(&buf);
929927
if (fast_forward == FF_NO)
930928
strbuf_addstr(&buf, "no-ff");
931929
write_file_buf(git_path_merge_mode(), buf.buf, buf.len);
932930
}
933931

932+
static void write_merge_state(struct commit_list *remoteheads)
933+
{
934+
write_merge_heads(remoteheads);
935+
strbuf_addch(&merge_msg, '\n');
936+
write_file_buf(git_path_merge_msg(), merge_msg.buf, merge_msg.len);
937+
}
938+
934939
static int default_edit_option(void)
935940
{
936941
static const char name[] = "GIT_MERGE_AUTOEDIT";

0 commit comments

Comments
 (0)