Merge branch 'cb/maint-orphan-merge-noclobber'

* cb/maint-orphan-merge-noclobber:
  do not overwrite untracked during merge from unborn branch
This commit is contained in:
Junio C Hamano
2010-11-24 15:55:36 -08:00
2 changed files with 35 additions and 1 deletions

View File

@ -234,6 +234,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;
@ -985,7 +1003,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;