diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 3e7ec1f119..265d1b7d52 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -13,6 +13,7 @@
#include "delta.h"
#include "pack.h"
#include "path.h"
+#include "read-cache-ll.h"
#include "refs.h"
#include "csum-file.h"
#include "quote.h"
@@ -1468,8 +1469,6 @@ static int tree_content_set(
root->tree = t = grow_tree_content(t, t->entry_count);
e = new_tree_entry();
e->name = to_atom(p, n);
- if (is_dot_or_dotdot(e->name->str_dat))
- die("path %s contains invalid component", p);
e->versions[0].mode = 0;
oidclr(&e->versions[0].oid, the_repository->hash_algo);
t->entries[t->entry_count++] = e;
@@ -2416,6 +2415,9 @@ static void file_change_m(const char *p, struct branch *b)
tree_content_replace(&b->branch_tree, &oid, mode, NULL);
return;
}
+
+ if (!verify_path(path.buf, mode))
+ die("invalid path '%s'", path.buf);
tree_content_set(&b->branch_tree, path.buf, &oid, mode, NULL);
}
@@ -2453,6 +2455,8 @@ static void file_change_cr(const char *p, struct branch *b, int rename)
leaf.tree);
return;
}
+ if (!verify_path(dest.buf, leaf.versions[1].mode))
+ die("invalid path '%s'", dest.buf);
tree_content_set(&b->branch_tree, dest.buf,
&leaf.versions[1].oid,
leaf.versions[1].mode,
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 5a5127fffa..e2b1db6bc2 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -522,7 +522,7 @@ test_expect_success 'B: fail on invalid committer (5)' '
test_must_fail git fast-import input <<-INPUT_END &&
blob
mark :1
@@ -542,6 +542,86 @@ test_expect_success 'B: fail on invalid file path' '
test_must_fail git fast-import input <<-INPUT_END &&
+ blob
+ mark :1
+ data < $GIT_COMMITTER_DATE
+ data <input <<-INPUT_END &&
+ blob
+ mark :1
+ data < $GIT_COMMITTER_DATE
+ data <input <<-INPUT_END &&
+ blob
+ mark :1
+ data < $GIT_COMMITTER_DATE
+ data <input <<-INPUT_END &&
+ blob
+ mark :1
+ data < $GIT_COMMITTER_DATE
+ data <output &&
cut -d" " -f1,2,5 output >actual &&
test_cmp expect actual
@@ -3117,7 +3197,7 @@ test_path_eol_success () {
test_expect_success "S: paths at EOL with $test must work" '
test_when_finished "git branch -D S-path-eol" &&
- git fast-import --export-marks=marks.out <<-EOF >out 2>err &&
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF >out 2>err &&
blob
mark :401
data <err &&
+ git -c core.protectNTFS=false fast-import --export-marks=marks.out <<-EOF 2>err &&
blob
mark :401
data <expect &&
git init result &&
cd result &&
- git fast-import <../export.out &&
+ git -c core.protectNTFS=false fast-import <../export.out &&
git rev-list HEAD >actual &&
test_cmp ../expect actual
)