git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] commit: allow partial commits with relative paths
@ 2018-04-03 17:57 Brandon Williams
  0 siblings, 0 replies; 5+ messages in thread
From: Brandon Williams @ 2018-04-03 17:57 UTC (permalink / raw)
  To: git, bmwill; +Cc: Brandon Williams

Commit 8894d53580 (commit: allow partial commits with relative paths,
2011-07-30) ensured that partial commits were allowed when a user
supplies a relative pathspec but then this was regressed in 5879f5684c
(remove prefix argument from pathspec_prefix, 2011-09-04) when the
prefix argument to 'pathspec_prefix' removed and the 'list_paths'
function wasn't properly adjusted to cope with the change, resulting in
over-eager pruning of the tree that is overlayed on the index.

This fixes the regression and adds a regression test so this can be
prevented in the future.

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/commit.c  |  3 +--
 t/t7501-commit.sh | 12 ++++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 37fcb55ab0..5571d4a3e2 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -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);
 	}
 
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index fa61b1a4ee..9dbbd01fc0 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -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
 '
-- 
2.17.0.rc1.321.gba9d0f2565-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* Possible bug
@ 2011-07-23 20:25 Reuben Thomas
  2011-07-25  7:42 ` [RFC/PATCH] commit: allow partial commits with relative paths Michael J Gruber
  0 siblings, 1 reply; 5+ messages in thread
From: Reuben Thomas @ 2011-07-23 20:25 UTC (permalink / raw)
  To: git

Observe the following exchange with git 1.7.4.1, which I found rather
perplexing:

$ cat ~/reportbug-git
$ git rm -f ../INSTALL
rm 'INSTALL'
$ git ci -m "INSTALL is now provided by gnulib." ../INSTALL
error: pathspec 'ALL' did not match any file(s) known to git.
$ cd ..
$ git ci -m "INSTALL is now provided by gnulib." INSTALL
[master 0895314] INSTALL is now provided by gnulib.
 1 files changed, 0 insertions(+), 1 deletions(-)
 delete mode 120000 INSTALL

Is this a bug, or merely some magic I don't know about?

-- 
http://rrt.sc3d.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-03 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 17:57 [PATCH] commit: allow partial commits with relative paths Brandon Williams
  -- strict thread matches above, loose matches on Subject: below --
2011-07-23 20:25 Possible bug Reuben Thomas
2011-07-25  7:42 ` [RFC/PATCH] commit: allow partial commits with relative paths Michael J Gruber
2011-07-29 13:35   ` [PATCH] " Clemens Buchacher
2011-07-30 16:45     ` Michael J Gruber
2011-07-30 17:00       ` Clemens Buchacher
2011-07-30 17:04         ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).