Skip to contentSkip to conversation

submodule operations: tighten pathspec errors

PATCH In review Stefan Beller 2 participants 6 messages Jun 16, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 submodule operations: tighten pathspec errors

when the pathspec did not match any path, error out. Add the --error-unmatch switch to use the old behavior.

---

This was taken from the Left Over Bits:
git submodule $cmd $pathspec may want to error out when the $pathspec does not match any submodules. There must be an --unmatch-ok option to override this safety, though. Cf. $gmane/289535

It's a first initial version with no tests (and probably conflicting with some topics in flight), but I was curious how involved this issue actually is, so I took a stab at implementing it.

I was debating if inside git-submodules.sh we want to pass around a variable or instead export an environment variable GIT_SUBMODULE_UNMATCH, such that we do not give it as an argument to the submodule--helper builtin.

(This version is developed on top of the sb/submodule-deinit-all)

 Documentation/git-submodule.txt | 15 ++++++++++-----
 builtin/submodule--helper.c     | 19 +++++++++++--------
 git-submodule.sh                | 41 ++++++++++++++++++++++++++++++-----------
 3 files changed, 51 insertions(+), 24 deletions(-)
Documentation/git-submodule.txt +10 -5
index ad85183..ceacc02 100644
@@ -11,16 +11,16 @@ SYNOPSIS
 [verse]
 'git submodule' [--quiet] add [-b <branch>] [-f|--force] [--name <name>]
 	      [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
-'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
-'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] deinit [-f|--force] (--all|[--] <path>...)
-'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
+'git submodule' [--quiet] status [--error-unmatch] [--cached] [--recursive] [--] [<path>...]
+'git submodule' [--quiet] init [--error-unmatch] [--] [<path>...]
+'git submodule' [--quiet] deinit [--error-unmatch] [-f|--force] (--all|[--] <path>...)
+'git submodule' [--quiet] update [--error-unmatch] [--init] [--remote] [-N|--no-fetch]
 	      [-f|--force] [--rebase|--merge] [--reference <repository>]
 	      [--depth <depth>] [--recursive] [--] [<path>...]
 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
 	      [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach [--recursive] <command>
-'git submodule' [--quiet] sync [--recursive] [--] [<path>...]
+'git submodule' [--quiet] sync [--error-unmatch] [--recursive] [--] [<path>...]
 
 
 DESCRIPTION
@@ -260,6 +260,11 @@ OPTIONS
 	The name of the branch is recorded as `submodule.<name>.branch` in
 	`.gitmodules` for `update --remote`.
 
+--error-unmatch::
+	If the pathspec included a specification that did not match,
+	the usual operation is to error out. This switch suppresses
+	error reporting and continues the operation.
+
 -f::
 --force::
 	This option is only valid for add, deinit and update commands.
builtin/submodule--helper.c +11 -8
index 5295b72..91c49ec 100644
@@ -19,7 +19,8 @@ struct module_list {
 static int module_list_compute(int argc, const char **argv,
 			       const char *prefix,
 			       struct pathspec *pathspec,
-			       struct module_list *list)
+			       struct module_list *list,
+			       int unmatch)
 {
 	int i, result = 0;
 	char *ps_matched = NULL;
@@ -36,10 +37,9 @@ static int module_list_compute(int argc, const char **argv,
 
 	for (i = 0; i < active_nr; i++) {
 		const struct cache_entry *ce = active_cache[i];
-
-		if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
-				    0, ps_matched, 1) ||
-		    !S_ISGITLINK(ce->ce_mode))
+		if (!S_ISGITLINK(ce->ce_mode) ||
+		    !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+				    0, ps_matched, 1))
 			continue;
 
 		ALLOC_GROW(list->entries, list->nr + 1, list->alloc);
@@ -53,7 +53,9 @@ static int module_list_compute(int argc, const char **argv,
 			i++;
 	}
 
-	if (ps_matched && report_path_error(ps_matched, pathspec, prefix))
+	if (!unmatch &&
+	    ps_matched &&
+	    report_path_error(ps_matched, pathspec, prefix))
 		result = -1;
 
 	free(ps_matched);
@@ -63,11 +65,12 @@ static int module_list_compute(int argc, const char **argv,
 
 static int module_list(int argc, const char **argv, const char *prefix)
 {
-	int i;
+	int i, unmatch = 0;
 	struct pathspec pathspec;
 	struct module_list list = MODULE_LIST_INIT;
 
 	struct option module_list_options[] = {
+		OPT_BOOL(0, "unmatch", &unmatch, N_("Do not report error if no matches are found")),
 		OPT_STRING(0, "prefix", &prefix,
 			   N_("path"),
 			   N_("alternative anchor for relative paths")),
@@ -82,7 +85,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
 	argc = parse_options(argc, argv, prefix, module_list_options,
 			     git_submodule_helper_usage, 0);
 
-	if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) {
+	if (module_list_compute(argc, argv, prefix, &pathspec, &list, unmatch) < 0) {
 		printf("#unmatched\n");
 		return 1;
 	}
git-submodule.sh +30 -11

121 lines not on this page · raw message

Signature · 1 line
2.8.0.2.gaa9b48a.dirty
#1 lore raw
Quoted 3 lines · Stefan Beller

It's a first initial version with no tests (and probably conflicting with some topics in flight), but I was curious how involved this issue actually is, so I took a stab at implementing it.

I take it to mean "This is s/PATCH/RFC/".

Documentation/git-submodule.txt OPTIONS · line 266

Quoted 4 lines

+--error-unmatch::

Documentation/git-submodule.txt +3 -0
+	If the pathspec included a specification that did not match,
+	the usual operation is to error out. This switch suppresses
+	error reporting and continues the operation.

The behaviour described is a total opposite of the option with the same name "ls-files" has, no?

If there were no default, --error-unmatch would make an unmatching pathspec an error and --no-error-unmatch would make it a non-error.

If the default is to error out, there is no need for --error-unmatch to exist, but you do want --no-error-unmatch aka --unmatch-ok.

If the default is not to error out, --error-unmatch should make it notice and turn it into an error.

I am guessing that you were debating yourself which should be the default and the patch ended up in an inconsistent state, the description assuming a more strict default, while the option name assuming a less strict default.

builtin/submodule--helper.c struct module_list { · line 23

Quoted 11 lines
builtin/submodule--helper.c +2 -1
index 5295b72..91c49ec 100644
@@ -19,7 +19,8 @@ struct module_list {
 static int module_list_compute(int argc, const char **argv,
 			       const char *prefix,
 			       struct pathspec *pathspec,
-			       struct module_list *list)
+			       struct module_list *list,
+			       int unmatch)

What is "unmatch"? "Catch unmatch errors, please?" "Do not check and report unmatch errors?"

My cursory read of a few hunks below tells me that you meant the latter, i.e. "unmatch_ok".

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 43

Quoted 12 lines
builtin/submodule--helper.c +3 -4
@@ -36,10 +37,9 @@ static int module_list_compute(int argc, const char **argv,
 
 	for (i = 0; i < active_nr; i++) {
 		const struct cache_entry *ce = active_cache[i];
-
-		if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
-				    0, ps_matched, 1) ||
-		    !S_ISGITLINK(ce->ce_mode))
+		if (!S_ISGITLINK(ce->ce_mode) ||
+		    !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+				    0, ps_matched, 1))
 			continue;

OK, this is the crucial bit in this patch. pathspec matches are now done only against gitlinks, so any unmatch is "pattern or path given, but there was no such submodule".

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 59

Quoted 9 lines
builtin/submodule--helper.c +3 -1
@@ -53,7 +53,9 @@ static int module_list_compute(int argc, const char **argv,
 			i++;
 	}
 
-	if (ps_matched && report_path_error(ps_matched, pathspec, prefix))
+	if (!unmatch &&
+	    ps_matched &&
+	    report_path_error(ps_matched, pathspec, prefix))
 		result = -1;

If unmatch is not true, then check if ps_matched records "aw, this pathspec element did not get used" and complain. If unmatch is true, we do not do that.

Which confirms my earlier "'unmatch' here means 'unmatch_ok'".

It is tempting to update report_path_error() return "OK" when its first parameter is NULL.

git-submodule.sh cmd_foreach() · line 396

Quoted 11 lines
git-submodule.sh +3 -0
index fb68f1f..f10e10a 100755
@@ -391,6 +391,9 @@ cmd_foreach()
 		--recursive)
 			recursive=1
 			;;
+		--error-unmatch)
+			unmatch=1
+			;;

So "--error-unmatch" does pass "--unmatch" which is "please ignore unmatch errors". That is a bit strange (see above).

git-submodule.sh cmd_foreach() · line 413

Quoted 6 lines
git-submodule.sh +1 -1
@@ -407,7 +410,7 @@ cmd_foreach()
 	# command in the subshell (and a recursive call to this function)
 	exec 3<&0
 
-	git submodule--helper list --prefix "$wt_prefix"|
+	git submodule--helper list ${unmatch:+--unmatch} --prefix "$wt_prefix"|

For this to work, somebody must ensure that the variable unmatch is either unset or set to empty unless the user gave --error-unmatch to us. There is a block of empty assignments hear the beginning of this file for that very purpose, i.e. resetting a stray environment variable that could be in user's environment.

The patch itself does not look too bad. I do not have an opinion on which one should be the default, and I certainly would understand if you want to keep the default loose (i.e. not complaining) with an optional error checking, but whichever default you choose, the option and variable names need to be clarified to avoid confusion.

#2 lore raw
Quoted 22 lines · Junio C Hamano
Quoted 3 lines · Stefan Beller

It's a first initial version with no tests (and probably conflicting with some topics in flight), but I was curious how involved this issue actually is, so I took a stab at implementing it.

I take it to mean "This is s/PATCH/RFC/".

Documentation/git-submodule.txt OPTIONS · line 266

Quoted 4 lines

+--error-unmatch::

Documentation/git-submodule.txt +3 -0
+     If the pathspec included a specification that did not match,
+     the usual operation is to error out. This switch suppresses
+     error reporting and continues the operation.

The behaviour described is a total opposite of the option with the same name "ls-files" has, no?

If there were no default, --error-unmatch would make an unmatching pathspec an error and --no-error-unmatch would make it a non-error.

If the default is to error out, there is no need for --error-unmatch to exist, but you do want --no-error-unmatch aka --unmatch-ok.

Quoted 7 lines

If the default is not to error out, --error-unmatch should make it notice and turn it into an error.

I am guessing that you were debating yourself which should be the default and the patch ended up in an inconsistent state, the description assuming a more strict default, while the option name assuming a less strict default.

Yes.

Quoted 21 lines

builtin/submodule--helper.c struct module_list { · line 23

Quoted 12 lines
builtin/submodule--helper.c +2 -1
index 5295b72..91c49ec 100644
@@ -19,7 +19,8 @@ struct module_list {
 static int module_list_compute(int argc, const char **argv,
                             const char *prefix,
                             struct pathspec *pathspec,
-                            struct module_list *list)
+                            struct module_list *list,
+                            int unmatch)

What is "unmatch"? "Catch unmatch errors, please?" "Do not check and report unmatch errors?"

My cursory read of a few hunks below tells me that you meant the latter, i.e. "unmatch_ok".

Quoted 2 lines
builtin/submodule--helper.c +0 -0
@@ -36,10 +37,9 @@ static int module_list_compute(int argc, const char **argv,
 
Quoted 14 lines

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 43

Quoted 10 lines
builtin/submodule--helper.c +3 -4
      for (i = 0; i < active_nr; i++) {
              const struct cache_entry *ce = active_cache[i];
-
-             if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
-                                 0, ps_matched, 1) ||
-                 !S_ISGITLINK(ce->ce_mode))
+             if (!S_ISGITLINK(ce->ce_mode) ||
+                 !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+                                 0, ps_matched, 1))
                      continue;

OK, this is the crucial bit in this patch. pathspec matches are now done only against gitlinks, so any unmatch is "pattern or path given, but there was no such submodule".

right.

Quoted 15 lines

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 59

Quoted 10 lines
builtin/submodule--helper.c +3 -1
@@ -53,7 +53,9 @@ static int module_list_compute(int argc, const char **argv,
                      i++;
      }
 
-     if (ps_matched && report_path_error(ps_matched, pathspec, prefix))
+     if (!unmatch &&
+         ps_matched &&
+         report_path_error(ps_matched, pathspec, prefix))
              result = -1;

If unmatch is not true, then check if ps_matched records "aw, this pathspec element did not get used" and complain. If unmatch is true, we do not do that.

Quoted 4 lines

Which confirms my earlier "'unmatch' here means 'unmatch_ok'".

It is tempting to update report_path_error() return "OK" when its first parameter is NULL.

such that we can do a

if (report_path_error(unmatch_ok ? NULL : ps_matched, pathspec, prefix)))
result = -1;

That looks good and inside of report_path_error we would only need a

    if (!ps_matched)
        return 0;

at the beginning.

Quoted 29 lines

git-submodule.sh cmd_foreach() · line 396

Quoted 12 lines
git-submodule.sh +3 -0
index fb68f1f..f10e10a 100755
@@ -391,6 +391,9 @@ cmd_foreach()
              --recursive)
                      recursive=1
                      ;;
+             --error-unmatch)
+                     unmatch=1
+                     ;;

So "--error-unmatch" does pass "--unmatch" which is "please ignore unmatch errors". That is a bit strange (see above).

git-submodule.sh cmd_foreach() · line 413

Quoted 6 lines
git-submodule.sh +1 -1
@@ -407,7 +410,7 @@ cmd_foreach()
      # command in the subshell (and a recursive call to this function)
      exec 3<&0
 
-     git submodule--helper list --prefix "$wt_prefix"|
+     git submodule--helper list ${unmatch:+--unmatch} --prefix "$wt_prefix"|

For this to work, somebody must ensure that the variable unmatch is either unset or set to empty unless the user gave --error-unmatch to us. There is a block of empty assignments hear the beginning of this file for that very purpose, i.e. resetting a stray environment variable that could be in user's environment.

Quoted 5 lines

The patch itself does not look too bad. I do not have an opinion on which one should be the default, and I certainly would understand if you want to keep the default loose (i.e. not complaining) with an optional error checking, but whichever default you choose, the option and variable names need to be clarified to avoid confusion.

Ok I'll fix the variable names; I think for consistency with e.g. ls-files --error-unmatch
we would want to be loose by default and strict on that option.

Thanks,
Stefan

Quoted 1 line
#3 lore raw
Quoted 19 lines · Stefan Beller
Quoted 16 lines · Junio C Hamano

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 43

Quoted 12 lines
builtin/submodule--helper.c +3 -4
@@ -36,10 +37,9 @@ static int module_list_compute(int argc, const char **argv,
 
      for (i = 0; i < active_nr; i++) {
              const struct cache_entry *ce = active_cache[i];
-
-             if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
-                                 0, ps_matched, 1) ||
-                 !S_ISGITLINK(ce->ce_mode))
+             if (!S_ISGITLINK(ce->ce_mode) ||
+                 !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+                                 0, ps_matched, 1))
                      continue;

OK, this is the crucial bit in this patch. pathspec matches are now done only against gitlinks, so any unmatch is "pattern or path given, but there was no such submodule".

Quoted 1 line

right.

That changes the semantics, and its user visible effect may deserve to be in the documentation, no?

It used to be that "git submodule--helper list COPYING" did not complain, but with this change, it would. Which may be a good change, but "git submodule--helper list sub*" where most but not all of glob expansion done by the shell are submodule directories may be a common thing people may do, and it may be irritating to see the unmatch complaints. I dunno.

When we know we are not going to complain (i.e. --unmatch-ok option is given from the command line), I think it is perfectly fine (and it is even preferrable) to swap the order of the check. The mode check done with S_ISGITLINK() is much cheaper and it is likely to yield true much less often, which in turn would allow us to make fewer calls to more expensive match_pathspec().

But when we want to diagnose typo (i.e. --unmatch-ok was not given), we may want to preserve the current order, so that the "sub*" example in a few paragraphs ago would not irritate the users.

Quoted 7 lines
Quoted 2 lines

It is tempting to update report_path_error() return "OK" when its first parameter is NULL.

such that we can do a

if (report_path_error(unmatch_ok ? NULL : ps_matched, pathspec, prefix)))
result = -1;

I actually was thinking about setting ps_matched to NULL so that both match_pathspec() and report_path_error() would get NULL. match_pathspec() has to do _more_ work when ps_matched[] aka seen[] is given.

Quoted 19 lines
Quoted 13 lines

git-submodule.sh cmd_foreach() · line 413

Quoted 6 lines
git-submodule.sh +1 -1
@@ -407,7 +410,7 @@ cmd_foreach()
      # command in the subshell (and a recursive call to this function)
      exec 3<&0
 
-     git submodule--helper list --prefix "$wt_prefix"|
+     git submodule--helper list ${unmatch:+--unmatch} --prefix "$wt_prefix"|

For this to work, somebody must ensure that the variable unmatch is either unset or set to empty unless the user gave --error-unmatch to us. There is a block of empty assignments hear the beginning of this file for that very purpose, i.e. resetting a stray environment variable that could be in user's environment.

Quoted 5 lines

The patch itself does not look too bad. I do not have an opinion on which one should be the default, and I certainly would understand if you want to keep the default loose (i.e. not complaining) with an optional error checking, but whichever default you choose, the option and variable names need to be clarified to avoid confusion.

Quoted 3 lines

Ok I'll fix the variable names; I think for consistency with e.g. ls-files --error-unmatch
we would want to be loose by default and strict on that option.

I do not think the "typo-prevention" safety measure should suddenly be turned into opt-in; I'd suggest "--unmatch-ok" instead.

#4 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 3 lines

Ok I'll fix the variable names; I think for consistency with e.g. ls-files --error-unmatch
we would want to be loose by default and strict on that option.

I do not think the "typo-prevention" safety measure should suddenly be turned into opt-in; I'd suggest "--unmatch-ok" instead.

Sorry, I should have grepped before hitting "send". I think this is in line with "git rm --ignore-unmatch". We complain by default, but the user can choose to squelch.

#5 lore raw
In reply to Junio C Hamano
Quoted 26 lines · Junio C Hamano
Quoted 19 lines · Stefan Beller
Quoted 16 lines · Junio C Hamano

builtin/submodule--helper.c static int module_list_compute(int argc, const char **argv, · line 43

Quoted 12 lines
builtin/submodule--helper.c +3 -4
@@ -36,10 +37,9 @@ static int module_list_compute(int argc, const char **argv,
 
      for (i = 0; i < active_nr; i++) {
              const struct cache_entry *ce = active_cache[i];
-
-             if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
-                                 0, ps_matched, 1) ||
-                 !S_ISGITLINK(ce->ce_mode))
+             if (!S_ISGITLINK(ce->ce_mode) ||
+                 !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+                                 0, ps_matched, 1))
                      continue;

OK, this is the crucial bit in this patch. pathspec matches are now done only against gitlinks, so any unmatch is "pattern or path given, but there was no such submodule".

Quoted 1 line

right.

That changes the semantics, and its user visible effect may deserve to be in the documentation, no?

Quoted 6 lines

It used to be that "git submodule--helper list COPYING" did not complain, but with this change, it would. Which may be a good change, but "git submodule--helper list sub*" where most but not all of glob expansion done by the shell are submodule directories may be a common thing people may do, and it may be irritating to see the unmatch complaints. I dunno.

I fixed all the variable names and was confident with what I had, but this is an issue indeed as the error message is plain wrong:
git$ git submodule--helper list sub*
error: pathspec 'submodule.c' did not match any file(s) known to git.
error: pathspec 'submodule-config.c' did not match any file(s) known to git.
error: pathspec 'submodule-config.h' did not match any file(s) known to git.
error: pathspec 'submodule-config.o' did not match any file(s) known to git.
error: pathspec 'submodule.h' did not match any file(s) known to git.
error: pathspec 'submodule_multiple_references' did not match any
file(s) known to git.
error: pathspec 'submodule.o' did not match any file(s) known to git.
error: pathspec 'submodulespec.o' did not match any file(s) known to git.

(I realize I have some stray object files laying around)

So I do not think we can do

- if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
- 0, ps_matched, 1) ||
- !S_ISGITLINK(ce->ce_mode))
+ if (!S_ISGITLINK(ce->ce_mode) ||
+ !match_pathspec(pathspec, ce->name, ce_namelen(ce),
+ 0, ps_matched, 1))

or we need to have custom error reporting, which checks if any file still matches the pathspec (and ignore non gitlinks)

Quoted 2 lines

When we know we are not going to complain (i.e. --unmatch-ok option

I'd rather go with ignore-unmatch as git-rm does use that.

Quoted 5 lines

is given from the command line), I think it is perfectly fine (and it is even preferrable) to swap the order of the check. The mode check done with S_ISGITLINK() is much cheaper and it is likely to yield true much less often, which in turn would allow us to make fewer calls to more expensive match_pathspec().

As said, in that case we would then need a

    pathspec_mark_ps_matched(ce->name, ce_namelen(ce), ps_matched)
Quoted 4 lines

But when we want to diagnose typo (i.e. --unmatch-ok was not given), we may want to preserve the current order, so that the "sub*" example in a few paragraphs ago would not irritate the users.

I see.

     if (!S_ISGITLINK(ce->ce_mode)) {
        pathspec_mark_ps_matched(...);
        continue;
    } else {
        if ( !match_pathspec(pathspec, ce->name, ce_namelen(ce),
                                     0, ps_matched, 1))
        continue;
    }
    ...

doesn't look very appealing, so I guess we'd just keep the current behavior of
- if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
- 0, ps_matched, 1) ||
- !S_ISGITLINK(ce->ce_mode))

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

It is tempting to update report_path_error() return "OK" when its first parameter is NULL.

such that we can do a

Quoted 7 lines
Quoted 2 lines

if (report_path_error(unmatch_ok ? NULL : ps_matched, pathspec, prefix)))
result = -1;

I actually was thinking about setting ps_matched to NULL so that both match_pathspec() and report_path_error() would get NULL. match_pathspec() has to do _more_ work when ps_matched[] aka seen[] is given.

Yes for one call; No from the birds eye view;
the first lines that use the seen[]:

    if (seen && seen[i] == MATCHED_EXACTLY)
        continue;

so if we have ps->nr > 0 then it is beneficial to have a seen array, I think?

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
git-submodule.sh +0 -0
@@ -407,7 +410,7 @@ cmd_foreach()
      # command in the subshell (and a recursive call to this function)
      exec 3<&0
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

git-submodule.sh cmd_foreach() · line 413

Quoted 2 lines
git-submodule.sh +1 -1
-     git submodule--helper list --prefix "$wt_prefix"|
+     git submodule--helper list ${unmatch:+--unmatch} --prefix "$wt_prefix"|

For this to work, somebody must ensure that the variable unmatch is either unset or set to empty unless the user gave --error-unmatch to us. There is a block of empty assignments hear the beginning of this file for that very purpose, i.e. resetting a stray environment variable that could be in user's environment.

done.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

The patch itself does not look too bad. I do not have an opinion on which one should be the default, and I certainly would understand if you want to keep the default loose (i.e. not complaining) with an optional error checking, but whichever default you choose, the option and variable names need to be clarified to avoid confusion.

Quoted 6 lines
Quoted 3 lines

Ok I'll fix the variable names; I think for consistency with e.g. ls-files --error-unmatch
we would want to be loose by default and strict on that option.

I do not think the "typo-prevention" safety measure should suddenly be turned into opt-in; I'd suggest "--unmatch-ok" instead.

--ignore-unmatch has the same meaning and is taken by git-rm already?