summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J Gruber <git@grubix.eu>2017-08-23 12:10:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-23 17:34:57 (GMT)
commit8e6a6bb36037da87ac98da280459269168b9f525 (patch)
tree3ccce8bed8d1251db8c735b2edf26b1bfa6c059e
parent62dc42b9370b123924ba3423d51976e78d13a924 (diff)
downloadgit-8e6a6bb36037da87ac98da280459269168b9f525.zip
git-8e6a6bb36037da87ac98da280459269168b9f525.tar.gz
git-8e6a6bb36037da87ac98da280459269168b9f525.tar.bz2
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>
-rw-r--r--builtin/merge.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 2d79e79..f239fd5 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -906,7 +906,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;
@@ -922,8 +922,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)
@@ -931,6 +929,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";