Merge branch 'bw/commit-partial-from-subdirectory-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:28:53 +0000 (13:28 +0900)
"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

builtin/commit.c
t/t7501-commit.sh
index 37fcb55ab0a03a5fdabaca1913bc700201fd8e10..5571d4a3e2be5ee8a71b7d5dba72b782c848f15e 100644 (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);
        }
 
index fa61b1a4ee4a1d5ba457cb30e5cc045f724ed503..9dbbd01fc07724e378a864e3fe735269665a9bc3 100755 (executable)
@@ -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
 '