Skip to content

Commit 8295f20

Browse files
committed
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
2 parents ff6eb82 + 86238e0 commit 8295f20

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

builtin/commit.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ static int list_paths(struct string_list *list, const char *with_tree,
218218

219219
if (with_tree) {
220220
char *max_prefix = common_prefix(pattern);
221-
overlay_tree_on_index(&the_index, with_tree,
222-
max_prefix ? max_prefix : prefix);
221+
overlay_tree_on_index(&the_index, with_tree, max_prefix);
223222
free(max_prefix);
224223
}
225224

t/t7501-commit.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ test_expect_success PERL 'can use paths with --interactive' '
5252
git reset --hard HEAD^
5353
'
5454

55+
test_expect_success 'removed files and relative paths' '
56+
test_when_finished "rm -rf foo" &&
57+
git init foo &&
58+
>foo/foo.txt &&
59+
git -C foo add foo.txt &&
60+
git -C foo commit -m first &&
61+
git -C foo rm foo.txt &&
62+
63+
mkdir -p foo/bar &&
64+
git -C foo/bar commit -m second ../foo.txt
65+
'
66+
5567
test_expect_success 'using invalid commit with -C' '
5668
test_must_fail git commit --allow-empty -C bogus
5769
'

0 commit comments

Comments
 (0)