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 <git@grubix.eu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael J Gruber committed
Aug 23, 2017 at 14:10 UTC
8e6a6bb36037da87ac98da280459269168b9f525
1 file changed
+8
-3
builtin/merge.c
+8
-3
@@ -906,7 +906,7 @@ static int setup_with_upstream(const char ***argv)
906
return i;
907
}
908
909
-static void write_merge_state(struct commit_list *remoteheads)
909
+static void write_merge_heads(struct commit_list *remoteheads)
910
{
911
struct commit_list *j;
912
struct strbuf buf = STRBUF_INIT;
@@ -922,8 +922,6 @@ static void write_merge_state(struct commit_list *remoteheads)
922
strbuf_addf(&buf, "%s\n", oid_to_hex(oid));
923
}
924
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);
925
926
strbuf_reset(&buf);
927
if (fast_forward == FF_NO)
@@ -931,6 +929,13 @@ static void write_merge_state(struct commit_list *remoteheads)
929
write_file_buf(git_path_merge_mode(), buf.buf, buf.len);
930
}
931
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
+
939
static int default_edit_option(void)
940
{
941
static const char name[] = "GIT_MERGE_AUTOEDIT";