fast-import: treat filemodify with empty tree as delete
Normal git processes do not allow one to build a tree with an empty
subtree entry without trying hard at it. This is in keeping with the
general UI philosophy: git tracks content, not empty directories.
v1.7.3-rc0~75^2 (2010-06-30) changed that by making it easy to include
an empty subtree in fast-import's active commit:
M 040000 4b825dc642
subdir
One can trigger this by reading an empty tree (for example, the tree
corresponding to an empty root commit) and trying to move it to a
subtree. It is better and more closely analogous to 'git read-tree
--prefix' to treat such commands as requests to remove the subtree.
Noticed-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
334fba656b
commit
8fe533f686
@ -2163,6 +2163,12 @@ static void file_change_m(struct branch *b)
|
||||
p = uq.buf;
|
||||
}
|
||||
|
||||
/* Git does not track empty, non-toplevel directories. */
|
||||
if (S_ISDIR(mode) && !memcmp(sha1, EMPTY_TREE_SHA1_BIN, 20) && *p) {
|
||||
tree_content_remove(&b->branch_tree, p, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (S_ISGITLINK(mode)) {
|
||||
if (inline_data)
|
||||
die("Git links cannot be specified 'inline': %s",
|
||||
|
Reference in New Issue
Block a user