]> git.ipfire.org Git - thirdparty/git.git/commit
read-tree: explicitly disallow prefixes with a leading '/'
authorVictoria Dye <vdye@github.com>
Tue, 1 Mar 2022 20:24:26 +0000 (20:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Mar 2022 20:36:00 +0000 (12:36 -0800)
commitcc89331ddc92cd89012eaf7937d167b3e0beaecc
tree78663939bf347fdc04f0d2171830a4463194bb7f
parent2c521b0e4900d8e7ff1f611ed956cfdd67f03eb0
read-tree: explicitly disallow prefixes with a leading '/'

Exit with an error if a prefix provided to `git read-tree --prefix` begins
with '/'. In most cases, prefixes like this result in an "invalid path"
error; however, the repository root would be interpreted as valid when
specified as '--prefix=/'. This is due to leniency around trailing directory
separators on prefixes (e.g., allowing both '--prefix=my-dir' and
'--prefix=my-dir/') - the '/' in the prefix is actually the *trailing*
slash, although it could be misinterpreted as a *leading* slash.

To remove the confusing repo root-as-'/' case and make it clear that
prefixes should not begin with '/', exit with an error if the first
character of the provided prefix is '/'.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/read-tree.c
t/t1003-read-tree-prefix.sh