git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly

From
Techlive Zheng <techlivezheng@gmail.com>
Date
Aug 8, 2012, 19:42 UTC
Message-ID
<1344454971-19559-2-git-send-email-techlivezheng@gmail.com>
In-Reply-To
<1344454971-19559-1-git-send-email-techlivezheng@gmail.com>
The current git-fast-import would not correctly handle such a commit stream
in which a file was deleted and at the same time a directory with the same
name was created. All paths under the newly created directory will be lost
after the importing.
---
 fast-import.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/fast-import.c b/fast-import.c
index eed97c8..8874b4b 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1595,6 +1595,15 @@ static int tree_content_remove(
 				 * exist and need not be deleted.
 				 */
 				return 1;
+			if (!slash1 && S_ISREG(e->versions[0].mode) && S_ISDIR(e->versions[1].mode))
+			    /*
+			     * If p names a file in some subdirectory and in
+			     * some commit that file got deleted, a directory
+			     * with the same name was set up in the same directory,
+			     * then there is no need to step into for further
+			     * iteration or deletion.
+			     */
+				return 0;
 			if (!slash1 || !S_ISDIR(e->versions[1].mode))
 				goto del_entry;
 			if (!e->tree)
-- 
1.7.11.4
Previous: Techlive ZhengNext: Junio C Hamano
Message 2 of 3 in “t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming”
  1. 1/2 t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renamingTechlive Zheng, Aug 8, 2012
  2. 2/2 fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctlyTechlive Zheng, Aug 8, 2012
  3. Junio C HamanoAug 8, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.