git-commit-vandalism/t/t4120-apply-popt.sh
Andreas Gruenbacher 1586208727 builtin-apply.c: Skip filenames without enough components
find_name() wrongly returned the whole filename for filenames without
enough leading pathname components (e.g., when applying a patch to a
top-level file with -p2).

Include the -p value used in the error message when no filenames can be
found.

[jc: squashed a test from Nanako Shiraishi]

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-18 10:32:05 -08:00

31 lines
525 B
Bash
Executable File

#!/bin/sh
#
# Copyright (c) 2007 Shawn O. Pearce
#
test_description='git apply -p handling.'
. ./test-lib.sh
test_expect_success setup '
mkdir sub &&
echo A >sub/file1 &&
cp sub/file1 file1 &&
git add sub/file1 &&
echo B >sub/file1 &&
git diff >patch.file &&
rm sub/file1 &&
rmdir sub
'
test_expect_success 'apply git diff with -p2' '
git apply -p2 patch.file
'
test_expect_success 'apply with too large -p' '
test_must_fail git apply --stat -p3 patch.file 2>err &&
grep "removing 3 leading" err
'
test_done