@@ -291,7 +291,7 @@ static int parse_color_moved(const char *arg)
291291 return error (_ ("color moved setting must be one of 'no', 'default', 'blocks', 'zebra', 'dimmed-zebra', 'plain'" ));
292292}
293293
294- static int parse_color_moved_ws (const char * arg )
294+ static unsigned parse_color_moved_ws (const char * arg )
295295{
296296 int ret = 0 ;
297297 struct string_list l = STRING_LIST_INIT_DUP ;
@@ -312,15 +312,19 @@ static int parse_color_moved_ws(const char *arg)
312312 ret |= XDF_IGNORE_WHITESPACE ;
313313 else if (!strcmp (sb .buf , "allow-indentation-change" ))
314314 ret |= COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE ;
315- else
316- error (_ ("ignoring unknown color-moved-ws mode '%s'" ), sb .buf );
315+ else {
316+ ret |= COLOR_MOVED_WS_ERROR ;
317+ error (_ ("unknown color-moved-ws mode '%s', possible values are 'ignore-space-change', 'ignore-space-at-eol', 'ignore-all-space', 'allow-indentation-change'" ), sb .buf );
318+ }
317319
318320 strbuf_release (& sb );
319321 }
320322
321323 if ((ret & COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE ) &&
322- (ret & XDF_WHITESPACE_FLAGS ))
323- die (_ ("color-moved-ws: allow-indentation-change cannot be combined with other white space modes" ));
324+ (ret & XDF_WHITESPACE_FLAGS )) {
325+ error (_ ("color-moved-ws: allow-indentation-change cannot be combined with other white space modes" ));
326+ ret |= COLOR_MOVED_WS_ERROR ;
327+ }
324328
325329 string_list_clear (& l , 0 );
326330
@@ -341,8 +345,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
341345 return 0 ;
342346 }
343347 if (!strcmp (var , "diff.colormovedws" )) {
344- int cm = parse_color_moved_ws (value );
345- if (cm < 0 )
348+ unsigned cm = parse_color_moved_ws (value );
349+ if (cm & COLOR_MOVED_WS_ERROR )
346350 return -1 ;
347351 diff_color_moved_ws_default = cm ;
348352 return 0 ;
@@ -5034,10 +5038,13 @@ int diff_opt_parse(struct diff_options *options,
50345038 else if (skip_prefix (arg , "--color-moved=" , & arg )) {
50355039 int cm = parse_color_moved (arg );
50365040 if (cm < 0 )
5037- die ("bad --color-moved argument: %s" , arg );
5041+ return error ("bad --color-moved argument: %s" , arg );
50385042 options -> color_moved = cm ;
50395043 } else if (skip_prefix (arg , "--color-moved-ws=" , & arg )) {
5040- options -> color_moved_ws_handling = parse_color_moved_ws (arg );
5044+ unsigned cm = parse_color_moved_ws (arg );
5045+ if (cm & COLOR_MOVED_WS_ERROR )
5046+ return -1 ;
5047+ options -> color_moved_ws_handling = cm ;
50415048 } else if (skip_to_optional_arg_default (arg , "--color-words" , & options -> word_regex , NULL )) {
50425049 options -> use_color = 1 ;
50435050 options -> word_diff = DIFF_WORDS_COLOR ;
0 commit comments