Merge branch 'bw/commit-partial-from-subdirectory-fix'

"cd sub/dir && git commit ../path" ought to record the changes to
the file "sub/path", but this regressed long time ago.

* bw/commit-partial-from-subdirectory-fix:
  commit: allow partial commits with relative paths
This commit is contained in:
Junio C Hamano 2018-04-25 13:28:53 +09:00
commit 8295f2028f
2 changed files with 13 additions and 2 deletions

View file

@ -218,8 +218,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
if (with_tree) {
char *max_prefix = common_prefix(pattern);
overlay_tree_on_index(&the_index, with_tree,
max_prefix ? max_prefix : prefix);
overlay_tree_on_index(&the_index, with_tree, max_prefix);
free(max_prefix);
}

View file

@ -52,6 +52,18 @@ test_expect_success PERL 'can use paths with --interactive' '
git reset --hard HEAD^
'
test_expect_success 'removed files and relative paths' '
test_when_finished "rm -rf foo" &&
git init foo &&
>foo/foo.txt &&
git -C foo add foo.txt &&
git -C foo commit -m first &&
git -C foo rm foo.txt &&
mkdir -p foo/bar &&
git -C foo/bar commit -m second ../foo.txt
'
test_expect_success 'using invalid commit with -C' '
test_must_fail git commit --allow-empty -C bogus
'