summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-12-02 11:27:13 -0800
committerJunio C Hamano <gitster@pobox.com>2010-12-02 11:27:13 -0800
commit47f16e8b110d84bacb586a1b7183ee4bb781c980 (patch)
treea95b90d7863c72c41ba825d21c21fc1daf0edbba /builtin
parent54d04f2b077496739f9fdf04ff8abf24feb33576 (diff)
parent172b6428d06ff4eb0812f087a497d50b6c878fe1 (diff)
downloadgit-47f16e8b110d84bacb586a1b7183ee4bb781c980.tar.gz
Merge branch 'cb/maint-orphan-merge-noclobber' into maint
* cb/maint-orphan-merge-noclobber: do not overwrite untracked during merge from unborn branch
Diffstat (limited to 'builtin')
-rw-r--r--builtin/merge.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 5f65c0c8a6..d0bd651725 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -233,6 +233,24 @@ static void save_state(void)
die("not a valid object: %s", buffer.buf);
}
+static void read_empty(unsigned const char *sha1, int verbose)
+{
+ int i = 0;
+ const char *args[7];
+
+ args[i++] = "read-tree";
+ if (verbose)
+ args[i++] = "-v";
+ args[i++] = "-m";
+ args[i++] = "-u";
+ args[i++] = EMPTY_TREE_SHA1_HEX;
+ args[i++] = sha1_to_hex(sha1);
+ args[i] = NULL;
+
+ if (run_command_v_opt(args, RUN_GIT_CMD))
+ die("read-tree failed");
+}
+
static void reset_hard(unsigned const char *sha1, int verbose)
{
int i = 0;
@@ -993,7 +1011,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die("%s - not something we can merge", argv[0]);
update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
DIE_ON_ERR);
- reset_hard(remote_head->sha1, 0);
+ read_empty(remote_head->sha1, 0);
return 0;
} else {
struct strbuf merge_names = STRBUF_INIT;