All of lore.kernel.org
 help / color / mirror / Atom feed
* git rm --pathspec-from-file does not work in subdirectories
@ 2021-05-28  4:20 Dietrich Epp
  2021-05-28  4:59 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Dietrich Epp @ 2021-05-28  4:20 UTC (permalink / raw)
  To: git

How to reproduce: cd into a subdirectory and use git rm
--pathspec-from-file. For example, in Git's repo, at the top level:

$ git rm --pathspec-from-file=/dev/null
fatal: No pathspec was given. Which files should I remove?
$ cd compat
$ git rm --pathspec-from-file=/dev/null
fatal: --pathspec-from-file is incompatible with pathspec arguments

However, git add works as expected.

Tested on commit 5afd72a96f0a3f65a832fd1448d9de1c534aaa69 (master)

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

* Re: git rm --pathspec-from-file does not work in subdirectories
  2021-05-28  4:20 git rm --pathspec-from-file does not work in subdirectories Dietrich Epp
@ 2021-05-28  4:59 ` Junio C Hamano
  2021-05-28  5:08   ` Eric Sunshine
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2021-05-28  4:59 UTC (permalink / raw)
  To: Dietrich Epp; +Cc: git

Dietrich Epp <depp@moria.us> writes:

> How to reproduce: cd into a subdirectory and use git rm
> --pathspec-from-file. For example, in Git's repo, at the top level:
>
> $ git rm --pathspec-from-file=/dev/null
> fatal: No pathspec was given. Which files should I remove?
> $ cd compat
> $ git rm --pathspec-from-file=/dev/null
> fatal: --pathspec-from-file is incompatible with pathspec arguments

Thanks for a report.

I think this reveals issues with not just the --pathspec-from-file
which has been added relatively recently, but potentially a larger
issue "git rm" from subdirectory has.

When run from a subdirectory, "git rm" without pathspec behaves
as if a single "." (i.e. everything underneath the current
directory) is given as the pathspec.  Of course, this is incompatible
with reading of the pathspec elements from a file and unfortunately
it cannot be disabled, so there currently is no way to use the option
if you are in a subdirectory.

But a potentially larger problem is that "git rm -r" will remove
everything under the current directory unless you are at the top
level of the working tree, even when the user does not give "." to
explicitly say "I want everything under the current directory gone".

I wonder if the attached patch would make both issues better.


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

* Re: git rm --pathspec-from-file does not work in subdirectories
  2021-05-28  4:59 ` Junio C Hamano
@ 2021-05-28  5:08   ` Eric Sunshine
  2021-05-28  5:56     ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Sunshine @ 2021-05-28  5:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Dietrich Epp, Git List

On Fri, May 28, 2021 at 1:07 AM Junio C Hamano <gitster@pobox.com> wrote:
> I wonder if the attached patch would make both issues better.

The "attached patch" is missing.

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

* Re: git rm --pathspec-from-file does not work in subdirectories
  2021-05-28  5:08   ` Eric Sunshine
@ 2021-05-28  5:56     ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2021-05-28  5:56 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Dietrich Epp, Git List

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Fri, May 28, 2021 at 1:07 AM Junio C Hamano <gitster@pobox.com> wrote:
>> I wonder if the attached patch would make both issues better.
>
> The "attached patch" is missing.

Heh.  Something along this line, but I think pathspec-from-file
still needs a bit more work even with this patch.

 builtin/rm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git c/builtin/rm.c w/builtin/rm.c
index 8a24c715e0..a4a8a1ad8d 100644
--- c/builtin/rm.c
+++ w/builtin/rm.c
@@ -265,7 +265,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 			     builtin_rm_usage, 0);
 
 	parse_pathspec(&pathspec, 0,
-		       PATHSPEC_PREFER_CWD,
+		       PATHSPEC_PREFER_FULL,
 		       prefix, argv);
 
 	if (pathspec_from_file) {
@@ -273,7 +273,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 			die(_("--pathspec-from-file is incompatible with pathspec arguments"));
 
 		parse_pathspec_file(&pathspec, 0,
-				    PATHSPEC_PREFER_CWD,
+				    PATHSPEC_PREFER_FULL,
 				    prefix, pathspec_from_file, pathspec_file_nul);
 	} else if (pathspec_file_nul) {
 		die(_("--pathspec-file-nul requires --pathspec-from-file"));

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

end of thread, other threads:[~2021-05-28  5:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28  4:20 git rm --pathspec-from-file does not work in subdirectories Dietrich Epp
2021-05-28  4:59 ` Junio C Hamano
2021-05-28  5:08   ` Eric Sunshine
2021-05-28  5:56     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.