{"thread":{"id":"31214","subject":"[PATCH 1/2] t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming","startedAt":"2012-08-08T19:42:49Z","lastAt":"2012-08-08T22:04:11Z","messageCount":3,"participants":["Techlive Zheng","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"196694","messageId":"1344454971-19559-1-git-send-email-techlivezheng@gmail.com","threadId":"31214","inReplyTo":null,"subject":"[PATCH 1/2] t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2012-08-08T19:42:49Z","receivedAt":"2012-08-08T19:42:49Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"This test would fail at the moment.\n---\n t/t9300-fast-import.sh | 31 +++++++++++++++++++++++++++++++\n 1 file changed, 31 insertions(+)\n\ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex 2fcf269..2a8368e 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -1039,6 +1039,37 @@ test_expect_success \\\n \t git diff-tree -M -r M3^ M3 >actual &&\n \t compare_diff_raw expect actual'\n \n+cat >input <<INPUT_END\n+blob\n+mark :1\n+data 10\n+test file\n+\n+reset refs/heads/M4\n+commit refs/heads/M4\n+mark :2\n+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n+data 8\n+initial\n+M 100644 :1 testname\n+\n+commit refs/heads/M5\n+mark :3\n+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE\n+data 8\n+initial\n+from refs/heads/M4\n+M 100644 :1 testname/testfile\n+D testname\n+\n+INPUT_END\n+\n+test_expect_success \\\n+\t'M: rename file into new subdirectory with same name' \\\n+\t'git fast-import <input &&\n+\t git checkout M5 &&\n+\t test -d testname && test -f testname/testfile'\n+\n ###\n ### series N\n ###\n-- \n1.7.11.4\n"},{"id":"196695","messageId":"1344454971-19559-2-git-send-email-techlivezheng@gmail.com","threadId":"31214","inReplyTo":"1344454971-19559-1-git-send-email-techlivezheng@gmail.com","subject":"[PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly","fromName":"Techlive Zheng","fromEmail":"techlivezheng@gmail.com","sentAt":"2012-08-08T19:42:50Z","receivedAt":"2012-08-08T19:42:50Z","isPatch":true,"sender":{"key":"techlivezheng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/816673?v=4"},"body":"The current git-fast-import would not correctly handle such a commit stream\nin which a file was deleted and at the same time a directory with the same\nname was created. All paths under the newly created directory will be lost\nafter the importing.\n---\n fast-import.c | 9 +++++++++\n 1 file changed, 9 insertions(+)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex eed97c8..8874b4b 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1595,6 +1595,15 @@ static int tree_content_remove(\n \t\t\t\t * exist and need not be deleted.\n \t\t\t\t */\n \t\t\t\treturn 1;\n+\t\t\tif (!slash1 && S_ISREG(e->versions[0].mode) && S_ISDIR(e->versions[1].mode))\n+\t\t\t    /*\n+\t\t\t     * If p names a file in some subdirectory and in\n+\t\t\t     * some commit that file got deleted, a directory\n+\t\t\t     * with the same name was set up in the same directory,\n+\t\t\t     * then there is no need to step into for further\n+\t\t\t     * iteration or deletion.\n+\t\t\t     */\n+\t\t\t\treturn 0;\n \t\t\tif (!slash1 || !S_ISDIR(e->versions[1].mode))\n \t\t\t\tgoto del_entry;\n \t\t\tif (!e->tree)\n-- \n1.7.11.4\n"},{"id":"196712","messageId":"7vd331qbvo.fsf@alter.siamese.dyndns.org","threadId":"31214","inReplyTo":"1344454971-19559-2-git-send-email-techlivezheng@gmail.com","subject":"Re: [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-08T22:04:11Z","receivedAt":"2012-08-08T22:04:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Judging from \"git shortlog --since=6.months fast-import.c\", Jonathan\nmay be the most qualified to see if this makes sense, among the\nactive list regulars, so....\n\n-- >8 --\nFrom: Techlive Zheng <techlivezheng@gmail.com>\nSubject: [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly\nDate: Thu,  9 Aug 2012 03:42:50 +0800\n\nThe current git-fast-import would not correctly handle such a commit stream\nin which a file was deleted and at the same time a directory with the same\nname was created. All paths under the newly created directory will be lost\nafter the importing.\n---\n fast-import.c | 9 +++++++++\n 1 file changed, 9 insertions(+)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex eed97c8..8874b4b 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -1595,6 +1595,15 @@ static int tree_content_remove(\n \t\t\t\t * exist and need not be deleted.\n \t\t\t\t */\n \t\t\t\treturn 1;\n+\t\t\tif (!slash1 && S_ISREG(e->versions[0].mode) && S_ISDIR(e->versions[1].mode))\n+\t\t\t    /*\n+\t\t\t     * If p names a file in some subdirectory and in\n+\t\t\t     * some commit that file got deleted, a directory\n+\t\t\t     * with the same name was set up in the same directory,\n+\t\t\t     * then there is no need to step into for further\n+\t\t\t     * iteration or deletion.\n+\t\t\t     */\n+\t\t\t\treturn 0;\n \t\t\tif (!slash1 || !S_ISDIR(e->versions[1].mode))\n \t\t\t\tgoto del_entry;\n \t\t\tif (!e->tree)\n-- \n1.7.11.4\n"}]}