git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 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; 38+ 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] 38+ messages in thread
* [PATCH] commit: allow partial commits with relative paths
@ 2018-04-03 17:57 Brandon Williams
  0 siblings, 0 replies; 38+ 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] 38+ messages in thread

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

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-25 19:02   ` Junio C Hamano
2011-07-25 19:32     ` Junio C Hamano
2011-07-27  8:22     ` Michael J Gruber
2011-07-27  9:45       ` Reuben Thomas
2011-07-27  9:53         ` Michael J Gruber
2011-07-27 10:00           ` Reuben Thomas
2011-07-27 10:19           ` John Szakmeister
2011-07-27 11:56             ` [RFC/PATCH] ls-files: fix pathspec display on error Michael J Gruber
2011-07-29 13:03               ` Clemens Buchacher
2011-08-01  0:01                 ` Junio C Hamano
2011-08-01 18:03                   ` [PATCH] test ls-files with relative paths Clemens Buchacher
2011-08-01 20:14                     ` Junio C Hamano
2011-08-01 21:19                       ` [PATCH v2] ls-files: fix pathspec display on error Clemens Buchacher
2011-08-01 22:30                         ` Junio C Hamano
2011-07-28  7:38             ` [RFC/PATCH] commit: allow partial commits with relative paths Erik Faye-Lund
2011-07-27 15:37       ` Junio C Hamano
2011-07-27 15:41       ` Junio C Hamano
2011-07-27 15:50         ` 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
2011-07-30 17:13           ` [PATCH v2] " Clemens Buchacher
2011-08-01  0:05             ` Junio C Hamano
2011-08-02 21:31             ` Junio C Hamano
2011-08-03 19:28               ` Clemens Buchacher
2011-08-03 22:07                 ` Junio C Hamano
2011-09-04 10:41               ` renaming pathspec_prefix (was: Re: [PATCH v2] commit: allow partial commits with relative paths) Clemens Buchacher
2011-09-04 10:41                 ` [PATCH 1/3] remove prefix argument from pathspec_prefix Clemens Buchacher
2011-09-06 19:02                   ` Junio C Hamano
2011-09-06 19:58                     ` Junio C Hamano
2011-09-08  7:12                       ` Clemens Buchacher
2011-09-08 16:51                         ` Junio C Hamano
2011-09-04 10:42                 ` [PATCH 2/3] consolidate pathspec_prefix and common_prefix Clemens Buchacher
2011-09-04 10:42                 ` [PATCH 3/3] rename pathspec_prefix -> common_prefix and move to dir.[ch] Clemens Buchacher
  -- strict thread matches above, loose matches on Subject: below --
2018-04-03 17:57 [PATCH] commit: allow partial commits with relative paths Brandon Williams

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).