git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming
@ 2012-08-08 19:42 Techlive Zheng
  2012-08-08 19:42 ` [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly Techlive Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Techlive Zheng @ 2012-08-08 19:42 UTC (permalink / raw)
  To: git, gitster; +Cc: Techlive Zheng, Shawn O. Pearce

This test would fail at the moment.
---
 t/t9300-fast-import.sh | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 2fcf269..2a8368e 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1039,6 +1039,37 @@ test_expect_success \
 	 git diff-tree -M -r M3^ M3 >actual &&
 	 compare_diff_raw expect actual'
 
+cat >input <<INPUT_END
+blob
+mark :1
+data 10
+test file
+
+reset refs/heads/M4
+commit refs/heads/M4
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 8
+initial
+M 100644 :1 testname
+
+commit refs/heads/M5
+mark :3
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 8
+initial
+from refs/heads/M4
+M 100644 :1 testname/testfile
+D testname
+
+INPUT_END
+
+test_expect_success \
+	'M: rename file into new subdirectory with same name' \
+	'git fast-import <input &&
+	 git checkout M5 &&
+	 test -d testname && test -f testname/testfile'
+
 ###
 ### series N
 ###
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly
  2012-08-08 19:42 [PATCH 1/2] t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming Techlive Zheng
@ 2012-08-08 19:42 ` Techlive Zheng
  2012-08-08 22:04   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Techlive Zheng @ 2012-08-08 19:42 UTC (permalink / raw)
  To: git, gitster; +Cc: Techlive Zheng, Elijah Newren, Shawn O. Pearce

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly
  2012-08-08 19:42 ` [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly Techlive Zheng
@ 2012-08-08 22:04   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2012-08-08 22:04 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git, Elijah Newren, Shawn O. Pearce, Techlive Zheng

Judging from "git shortlog --since=6.months fast-import.c", Jonathan
may be the most qualified to see if this makes sense, among the
active list regulars, so....

-- >8 --
From: Techlive Zheng <techlivezheng@gmail.com>
Subject: [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly
Date: Thu,  9 Aug 2012 03:42:50 +0800

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-08 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-08 19:42 [PATCH 1/2] t9300: Add a test covering 'sub/testname' to 'sub/testname/testfile' renaming Techlive Zheng
2012-08-08 19:42 ` [PATCH 2/2] fast-import: Handle 'sub/testname' to 'sub/testname/testfile' renaming correctly Techlive Zheng
2012-08-08 22:04   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).