{"thread":{"id":"48215","subject":"[PATCH] commit: allow partial commits with relative paths","startedAt":"2018-04-03T17:57:54Z","lastAt":"2018-04-03T17:57:54Z","messageCount":1,"participants":["Brandon Williams"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"343732","messageId":"20180403175745.140638-1-bmwill@google.com","threadId":"48215","inReplyTo":null,"subject":"[PATCH] commit: allow partial commits with relative paths","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-04-03T17:57:45Z","receivedAt":"2018-04-03T17:57:54Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"Commit 8894d53580 (commit: allow partial commits with relative paths,\n2011-07-30) ensured that partial commits were allowed when a user\nsupplies a relative pathspec but then this was regressed in 5879f5684c\n(remove prefix argument from pathspec_prefix, 2011-09-04) when the\nprefix argument to 'pathspec_prefix' removed and the 'list_paths'\nfunction wasn't properly adjusted to cope with the change, resulting in\nover-eager pruning of the tree that is overlayed on the index.\n\nThis fixes the regression and adds a regression test so this can be\nprevented in the future.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\n---\n builtin/commit.c  |  3 +--\n t/t7501-commit.sh | 12 ++++++++++++\n 2 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 37fcb55ab0..5571d4a3e2 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -218,8 +218,7 @@ static int list_paths(struct string_list *list, const char *with_tree,\n \n \tif (with_tree) {\n \t\tchar *max_prefix = common_prefix(pattern);\n-\t\toverlay_tree_on_index(&the_index, with_tree,\n-\t\t\t\t      max_prefix ? max_prefix : prefix);\n+\t\toverlay_tree_on_index(&the_index, with_tree, max_prefix);\n \t\tfree(max_prefix);\n \t}\n \ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex fa61b1a4ee..9dbbd01fc0 100755\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -52,6 +52,18 @@ test_expect_success PERL 'can use paths with --interactive' '\n \tgit reset --hard HEAD^\n '\n \n+test_expect_success 'removed files and relative paths' '\n+\ttest_when_finished \"rm -rf foo\" &&\n+\tgit init foo &&\n+\t>foo/foo.txt &&\n+\tgit -C foo add foo.txt &&\n+\tgit -C foo commit -m first &&\n+\tgit -C foo rm foo.txt &&\n+\n+\tmkdir -p foo/bar &&\n+\tgit -C foo/bar commit -m second ../foo.txt\n+'\n+\n test_expect_success 'using invalid commit with -C' '\n \ttest_must_fail git commit --allow-empty -C bogus\n '\n-- \n2.17.0.rc1.321.gba9d0f2565-goog\n\n"}]}