summaryrefslogtreecommitdiff
path: root/t/t9300-fast-import.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-08-29 17:33:48 (GMT)
committerJohannes Schindelin <johannes.schindelin@gmx.de>2019-12-04 12:20:04 (GMT)
commit019683025f1b14d7cb671312ab01f7330e9b33e7 (patch)
treec894009c7ed5f1ab0dd7a7a5cb2273197cdd576f /t/t9300-fast-import.sh
parente075dba3723875f478654068609f69b2a5af8566 (diff)
downloadgit-019683025f1b14d7cb671312ab01f7330e9b33e7.zip
git-019683025f1b14d7cb671312ab01f7330e9b33e7.tar.gz
git-019683025f1b14d7cb671312ab01f7330e9b33e7.tar.bz2
fast-import: delay creating leading directories for export-marks
When we parse the --export-marks option, we don't immediately open the file, but we do create any leading directories. This can be especially confusing when a command-line option overrides an in-stream one, in which case we'd create the leading directory for the in-stream file, even though we never actually write the file. Let's instead create the directories just before opening the file, which means we'll create only useful directories. Note that this could change the handling of relative paths if we chdir() in between, but we don't actually do so; the only permanent chdir is from setup_git_directory() which runs before either code path (potentially we should take the pre-setup dir into account to avoid surprising the user, but that's an orthogonal change). The test just adapts the existing "override" test to use paths with leading directories. This checks both that the correct directory is created (which worked before but was not tested), and that the overridden one is not (our new fix here). While we're here, let's also check the error result of safe_create_leading_directories(). We'd presumably notice any failure immediately after when we try to open the file itself, but we can give a more specific error message in this case. Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 't/t9300-fast-import.sh')
-rwxr-xr-xt/t9300-fast-import.sh13
1 files changed, 11 insertions, 2 deletions
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index c0d04ec..1ba20c1 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2132,8 +2132,17 @@ test_expect_success 'R: export-marks feature results in a marks file being creat
'
test_expect_success 'R: export-marks options can be overridden by commandline options' '
- git fast-import --export-marks=other.marks <input &&
- grep :1 other.marks
+ cat >input <<-\EOF &&
+ feature export-marks=feature-sub/git.marks
+ blob
+ mark :1
+ data 3
+ hi
+
+ EOF
+ git fast-import --export-marks=cmdline-sub/other.marks <input &&
+ grep :1 cmdline-sub/other.marks &&
+ test_path_is_missing feature-sub
'
test_expect_success 'R: catch typo in marks file name' '