Merge branch 'ps/pathspec-empty-prefix-origin'
A recent update broke "git add -p ../foo" from a subdirectory. * ps/pathspec-empty-prefix-origin: pathspec: honor `PATHSPEC_PREFIX_ORIGIN` with empty prefix
This commit is contained in:
commit
44427a0c18
@ -505,7 +505,7 @@ static void init_pathspec_item(struct pathspec_item *item, unsigned flags,
|
|||||||
* original. Useful for passing to another command.
|
* original. Useful for passing to another command.
|
||||||
*/
|
*/
|
||||||
if ((flags & PATHSPEC_PREFIX_ORIGIN) &&
|
if ((flags & PATHSPEC_PREFIX_ORIGIN) &&
|
||||||
prefixlen && !get_literal_global()) {
|
!get_literal_global()) {
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
/* Preserve the actual prefix length of each pattern */
|
/* Preserve the actual prefix length of each pattern */
|
||||||
|
@ -436,6 +436,28 @@ test_expect_success 'add -p handles globs' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'add -p handles relative paths' '
|
||||||
|
git reset --hard &&
|
||||||
|
|
||||||
|
echo base >relpath.c &&
|
||||||
|
git add "*.c" &&
|
||||||
|
git commit -m relpath &&
|
||||||
|
|
||||||
|
echo change >relpath.c &&
|
||||||
|
mkdir -p subdir &&
|
||||||
|
git -C subdir add -p .. 2>error <<-\EOF &&
|
||||||
|
y
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_must_be_empty error &&
|
||||||
|
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
relpath.c
|
||||||
|
EOF
|
||||||
|
git diff --cached --name-only >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'add -p does not expand argument lists' '
|
test_expect_success 'add -p does not expand argument lists' '
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user