diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-03-04 10:53:01 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-03-04 10:53:01 -0800 |
| commit | 1ebfc2171310ed5ca2bcd8c1255d45f03e56dda7 (patch) | |
| tree | 1c68f1f53ae272a8edeae8f258fd3ef22a3b570d /t | |
| parent | 8f760e7e8b67c067b829d81a9f32fb7c3fbcd6b9 (diff) | |
| parent | 0fbf380daf1367a5c203eb25b744f55634dab251 (diff) | |
| download | git-1ebfc2171310ed5ca2bcd8c1255d45f03e56dda7.tar.xz | |
Merge branch 'jr/apply-directory-normalize'
"git apply --directory=./un/../normalized/path" now normalizes the
given path before using it.
* jr/apply-directory-normalize:
apply: normalize path in --directory argument
Diffstat (limited to 't')
| -rwxr-xr-x | t/t4128-apply-root.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh index f6db5a79dd..5eba15fa66 100755 --- a/t/t4128-apply-root.sh +++ b/t/t4128-apply-root.sh @@ -43,6 +43,47 @@ test_expect_success 'apply --directory -p (2) ' ' ' +test_expect_success 'apply --directory (./ prefix)' ' + git reset --hard initial && + git apply --directory=./some/sub -p3 --index patch && + echo Bello >expect && + git show :some/sub/dir/file >actual && + test_cmp expect actual && + test_cmp expect some/sub/dir/file +' + +test_expect_success 'apply --directory (double slash)' ' + git reset --hard initial && + git apply --directory=some//sub -p3 --index patch && + echo Bello >expect && + git show :some/sub/dir/file >actual && + test_cmp expect actual && + test_cmp expect some/sub/dir/file +' + +test_expect_success 'apply --directory (./ in the middle)' ' + git reset --hard initial && + git apply --directory=some/./sub -p3 --index patch && + echo Bello >expect && + git show :some/sub/dir/file >actual && + test_cmp expect actual && + test_cmp expect some/sub/dir/file +' + +test_expect_success 'apply --directory (../ in the middle)' ' + git reset --hard initial && + git apply --directory=some/../some/sub -p3 --index patch && + echo Bello >expect && + git show :some/sub/dir/file >actual && + test_cmp expect actual && + test_cmp expect some/sub/dir/file +' + +test_expect_success 'apply --directory rejects leading ../' ' + test_must_fail git apply --directory=../foo -p3 patch 2>err && + test_grep "unable to normalize directory" err +' + cat > patch << EOF diff --git a/newfile b/newfile new file mode 100644 |
