mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Check that git patches only touch files under root
This commit is contained in:
parent
8e1dce7068
commit
f5b1d49e0d
@ -1039,9 +1039,12 @@ def applydiff(ui, fp, changed, strip=1, sourcefile=None, reverse=False,
|
||||
continue
|
||||
elif state == 'git':
|
||||
gitpatches = values
|
||||
cwd = os.getcwd()
|
||||
for gp in gitpatches:
|
||||
if gp.op in ('COPY', 'RENAME'):
|
||||
copyfile(gp.oldpath, gp.path)
|
||||
src, dst = [util.canonpath(cwd, cwd, x)
|
||||
for x in [gp.oldpath, gp.path]]
|
||||
copyfile(src, dst)
|
||||
changed[gp.path] = (gp.op, gp)
|
||||
else:
|
||||
raise util.Abort(_('unsupported parser state: %s') % state)
|
||||
|
@ -261,3 +261,15 @@ EOF
|
||||
hg status
|
||||
cat a
|
||||
cd ..
|
||||
|
||||
echo % 'test paths outside repo root'
|
||||
mkdir outside
|
||||
touch outside/foo
|
||||
hg init inside
|
||||
cd inside
|
||||
hg import - <<EOF
|
||||
diff --git a/a b/b
|
||||
rename from ../outside/foo
|
||||
rename to bar
|
||||
EOF
|
||||
cd ..
|
||||
|
@ -260,3 +260,6 @@ a
|
||||
adding a
|
||||
applying patch from stdin
|
||||
bb
|
||||
% test paths outside repo root
|
||||
applying patch from stdin
|
||||
abort: ../outside/foo not under root
|
||||
|
Loading…
Reference in New Issue
Block a user