Browse Source

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
maint
Junio C Hamano 7 years ago
parent
commit
8295f2028f
  1. 3
      builtin/commit.c
  2. 12
      t/t7501-commit.sh

3
builtin/commit.c

@ -218,8 +218,7 @@ static int list_paths(struct string_list *list, const char *with_tree, @@ -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);
}


12
t/t7501-commit.sh

@ -52,6 +52,18 @@ test_expect_success PERL 'can use paths with --interactive' ' @@ -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
'

Loading…
Cancel
Save