Skip to content

Commit aca7061

Browse files
johnkeepinggitster
authored andcommitted
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 <[email protected]> Signed-off-by: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit aca7061

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

t/t9300-fast-import.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,32 @@ test_expect_success \
10311031
git diff-tree -M -r M3^ M3 >actual &&
10321032
compare_diff_raw expect actual'
10331033

1034+
cat >input <<INPUT_END
1035+
commit refs/heads/M4
1036+
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1037+
data <<COMMIT
1038+
rename root
1039+
COMMIT
1040+
1041+
from refs/heads/M2^0
1042+
R "" sub
1043+
1044+
INPUT_END
1045+
1046+
cat >expect <<EOF
1047+
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
1048+
:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
1049+
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
1050+
:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
1051+
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
1052+
EOF
1053+
test_expect_failure \
1054+
'M: rename root to subdirectory' \
1055+
'git fast-import <input &&
1056+
git diff-tree -M -r M4^ M4 >actual &&
1057+
cat actual &&
1058+
compare_diff_raw expect actual'
1059+
10341060
###
10351061
### series N
10361062
###
@@ -1227,6 +1253,29 @@ test_expect_success \
12271253
git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
12281254
compare_diff_raw expect actual'
12291255

1256+
test_expect_failure \
1257+
'N: copy root by path' \
1258+
'cat >expect <<-\EOF &&
1259+
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
1260+
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
1261+
:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
1262+
:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
1263+
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
1264+
EOF
1265+
cat >input <<-INPUT_END &&
1266+
commit refs/heads/N-copy-root-path
1267+
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
1268+
data <<COMMIT
1269+
copy root directory by (empty) path
1270+
COMMIT
1271+
1272+
from refs/heads/branch^0
1273+
C "" oldroot
1274+
INPUT_END
1275+
git fast-import <input &&
1276+
git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
1277+
compare_diff_raw expect actual'
1278+
12301279
test_expect_success \
12311280
'N: delete directory by copying' \
12321281
'cat >expect <<-\EOF &&
@@ -2934,4 +2983,20 @@ test_expect_success 'S: ls with garbage after sha1 must fail' '
29342983
test_i18ngrep "space after tree-ish" err
29352984
'
29362985

2986+
###
2987+
### series T (ls)
2988+
###
2989+
# Setup is carried over from series S.
2990+
2991+
test_expect_failure 'T: ls root tree' '
2992+
sed -e "s/Z\$//" >expect <<-EOF &&
2993+
040000 tree $(git rev-parse S^{tree}) Z
2994+
EOF
2995+
sha1=$(git rev-parse --verify S) &&
2996+
git fast-import --import-marks=marks <<-EOF >actual &&
2997+
ls $sha1 ""
2998+
EOF
2999+
test_cmp expect actual
3000+
'
3001+
29373002
test_done

0 commit comments

Comments
 (0)