diff.c: die on unknown color-moved ws mode
diff mbox series

Message ID 20181011225928.76051-1-sbeller@google.com
State New
Headers show
Series
  • diff.c: die on unknown color-moved ws mode
Related show

Commit Message

Stefan Beller Oct. 11, 2018, 10:59 p.m. UTC
Noticed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
--- 


   There is no "ignore-any" supported by the feature---I think that
   the parser for the option should have noticed and barfed, but it
   did not.  It merely emitted a message to the standard output and
   let it scroll away with the huge diff before the reader noticed
   it.
   
Addressed in this patch.

   Am I missing something [...] ?

Note that this parsing is used for both the parsing from command line
as well as options, i.e.

  git config diff.colorMovedWS asdf
  git format-patch HEAD^
fatal: ignoring unknown color-moved-ws mode 'asdf'
  git config --unset diff.colorMovedWS

(format-patch parses these color specific things, but doesn't apply it)
   
 diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Beller Oct. 11, 2018, 11:01 p.m. UTC | #1
On Thu, Oct 11, 2018 at 3:59 PM Stefan Beller <sbeller@google.com> wrote:

> -                       error(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
> +                       die(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);

s/ignoring// as it was sent in a haste.
Junio C Hamano Oct. 12, 2018, 1:22 a.m. UTC | #2
Stefan Beller <sbeller@google.com> writes:

> Noticed-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> --- 
>
>
>    There is no "ignore-any" supported by the feature---I think that
>    the parser for the option should have noticed and barfed, but it
>    did not.  It merely emitted a message to the standard output and
>    let it scroll away with the huge diff before the reader noticed
>    it.
>    
> Addressed in this patch.
>
>    Am I missing something [...] ?
>
> Note that this parsing is used for both the parsing from command line
> as well as options, i.e.

Hmph, is it our convention for a value that is not yet known to the
current version of Git found in a configuration file to cause it to
die?  I somehow thought that command line options are checked more
strictly and configuration variables are parsed more leniently.

If that is the case, the place that dies need to be raised in the
callchain; iow, instead of dying inside the parser, it is necessary
to let it only detect a problem and allow the caller to decide what
to do with the problem, I would think.

>   git config diff.colorMovedWS asdf
>   git format-patch HEAD^
> fatal: ignoring unknown color-moved-ws mode 'asdf'
>   git config --unset diff.colorMovedWS



>
> (format-patch parses these color specific things, but doesn't apply it)
>    
>  diff.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/diff.c b/diff.c
> index 145cfbae59..bdf4535d69 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -313,7 +313,7 @@ static int parse_color_moved_ws(const char *arg)
>  		else if (!strcmp(sb.buf, "allow-indentation-change"))
>  			ret |= COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE;
>  		else
> -			error(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
> +			die(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
>  
>  		strbuf_release(&sb);
>  	}

Patch
diff mbox series

diff --git a/diff.c b/diff.c
index 145cfbae59..bdf4535d69 100644
--- a/diff.c
+++ b/diff.c
@@ -313,7 +313,7 @@  static int parse_color_moved_ws(const char *arg)
 		else if (!strcmp(sb.buf, "allow-indentation-change"))
 			ret |= COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE;
 		else
-			error(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
+			die(_("ignoring unknown color-moved-ws mode '%s'"), sb.buf);
 
 		strbuf_release(&sb);
 	}