From aca70610b6dea395995790c2eda58535d4cbe12e Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 23 Jun 2013 15:58:19 +0100 Subject: t9300: document fast-import empty path issues When given an empty path, fast-import sometimes reports "missing" instead of using the root tree object. On top of this, for "ls" and file copy (but not move) it dies with "Empty path component found in input". Document this behaviour with failing test cases. Reported-by: Dave Abrahams Signed-off-by: John Keeping Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 't') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index ac6f3b6af2..f4b93557a6 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1031,6 +1031,32 @@ test_expect_success \ git diff-tree -M -r M3^ M3 >actual && compare_diff_raw expect actual' +cat >input < $GIT_COMMITTER_DATE +data <expect <actual && + cat actual && + compare_diff_raw expect actual' + ### ### series N ### @@ -1227,6 +1253,29 @@ test_expect_success \ git diff-tree -C --find-copies-harder -r N4 N6 >actual && compare_diff_raw expect actual' +test_expect_failure \ + 'N: copy root by path' \ + 'cat >expect <<-\EOF && + :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf + :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf + :100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4 + :100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh + :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting + EOF + cat >input <<-INPUT_END && + commit refs/heads/N-copy-root-path + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data <actual && + compare_diff_raw expect actual' + test_expect_success \ 'N: delete directory by copying' \ 'cat >expect <<-\EOF && @@ -2934,4 +2983,20 @@ test_expect_success 'S: ls with garbage after sha1 must fail' ' test_i18ngrep "space after tree-ish" err ' +### +### series T (ls) +### +# Setup is carried over from series S. + +test_expect_failure 'T: ls root tree' ' + sed -e "s/Z\$//" >expect <<-EOF && + 040000 tree $(git rev-parse S^{tree}) Z + EOF + sha1=$(git rev-parse --verify S) && + git fast-import --import-marks=marks <<-EOF >actual && + ls $sha1 "" + EOF + test_cmp expect actual +' + test_done -- cgit v1.2.3 From e0eb6b9720db743993d9374e366cb6b7664f0a6d Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 23 Jun 2013 15:58:21 +0100 Subject: fast-import: allow ls or filecopy of the root tree Commit 178e1de (fast-import: don't allow 'ls' of path with empty components, 2012-03-09) restricted paths which: . contain an empty directory component (e.g. foo//bar is invalid), . end with a directory separator (e.g. foo/ is invalid), . start with a directory separator (e.g. /foo is invalid). However, the implementation also caught the empty path, which should represent the root tree. Relax this restriction so that the empty path is explicitly allowed and refers to the root tree. Reported-by: Dave Abrahams Signed-off-by: John Keeping Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index f4b93557a6..04385a7250 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1253,7 +1253,7 @@ test_expect_success \ git diff-tree -C --find-copies-harder -r N4 N6 >actual && compare_diff_raw expect actual' -test_expect_failure \ +test_expect_success \ 'N: copy root by path' \ 'cat >expect <<-\EOF && :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf @@ -2988,7 +2988,7 @@ test_expect_success 'S: ls with garbage after sha1 must fail' ' ### # Setup is carried over from series S. -test_expect_failure 'T: ls root tree' ' +test_expect_success 'T: ls root tree' ' sed -e "s/Z\$//" >expect <<-EOF && 040000 tree $(git rev-parse S^{tree}) Z EOF -- cgit v1.2.3 From 62bfa11cc9a8cb0aacbba0aed503e85cdc6ba0a4 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 23 Jun 2013 15:58:22 +0100 Subject: fast-import: allow moving the root tree Because fast-import.c::tree_content_remove does not check for the empty path, it is not possible to move the root tree to a subdirectory. Instead the error "Path not in branch" is produced (note the double space where the empty path has been inserted). Fix this by explicitly checking for the empty path and handling it. Signed-off-by: John Keeping Signed-off-by: Junio C Hamano --- t/t9300-fast-import.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 04385a7250..31a770d9bc 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1050,7 +1050,7 @@ cat >expect <actual && -- cgit v1.2.3