From: Felipe Contreras Date: Mon, 01 Sep 2008 13:20:14 GMT Subject: [PATCH 1/1] fast-import: show a warning for non-existent files. Message-ID: <1220275214-6178-1-git-send-email-felipe.contreras@gmail.com> This is useful in certain SCMs like monotone, where each 'merge revision' has the changes of all the micro-branches merged. So it appears as duplicated commands. The delete command was ignoring the issue completely. The rename/copy commands where throwing a fatal exception. --- fast-import.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fast-import.c b/fast-import.c index 7089e6f..3dd2ab6 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1945,6 +1945,7 @@ static void file_change_d(struct branch *b) const char *p = command_buf.buf + 2; static struct strbuf uq = STRBUF_INIT; const char *endp; + struct tree_entry leaf; strbuf_reset(&uq); if (!unquote_c_style(&uq, p, &endp)) { @@ -1952,7 +1953,13 @@ static void file_change_d(struct branch *b) die("Garbage after path in: %s", command_buf.buf); p = uq.buf; } - tree_content_remove(&b->branch_tree, p, NULL); + memset(&leaf, 0, sizeof(leaf)); + tree_content_remove(&b->branch_tree, p, &leaf); + if (!leaf.versions[1].mode) + { + warning("Path %s not in branch", p); + return; + } } static void file_change_cr(struct branch *b, int rename) @@ -1994,7 +2001,10 @@ static void file_change_cr(struct branch *b, int rename) else tree_content_get(&b->branch_tree, s, &leaf); if (!leaf.versions[1].mode) - die("Path %s not in branch", s); + { + warning("Path %s not in branch", s); + return; + } tree_content_set(&b->branch_tree, d, leaf.versions[1].sha1, leaf.versions[1].mode, -- 1.6.0.1