@@ -291,7 +291,7 @@ static int parse_color_moved(const char *arg)
291
291
return error (_ ("color moved setting must be one of 'no', 'default', 'blocks', 'zebra', 'dimmed-zebra', 'plain'" ));
292
292
}
293
293
294
- static int parse_color_moved_ws (const char * arg )
294
+ static unsigned parse_color_moved_ws (const char * arg )
295
295
{
296
296
int ret = 0 ;
297
297
struct string_list l = STRING_LIST_INIT_DUP ;
@@ -312,15 +312,19 @@ static int parse_color_moved_ws(const char *arg)
312
312
ret |= XDF_IGNORE_WHITESPACE ;
313
313
else if (!strcmp (sb .buf , "allow-indentation-change" ))
314
314
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
+ }
317
319
318
320
strbuf_release (& sb );
319
321
}
320
322
321
323
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
+ }
324
328
325
329
string_list_clear (& l , 0 );
326
330
@@ -341,8 +345,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
341
345
return 0 ;
342
346
}
343
347
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 )
346
350
return -1 ;
347
351
diff_color_moved_ws_default = cm ;
348
352
return 0 ;
@@ -5034,10 +5038,13 @@ int diff_opt_parse(struct diff_options *options,
5034
5038
else if (skip_prefix (arg , "--color-moved=" , & arg )) {
5035
5039
int cm = parse_color_moved (arg );
5036
5040
if (cm < 0 )
5037
- die ("bad --color-moved argument: %s" , arg );
5041
+ return error ("bad --color-moved argument: %s" , arg );
5038
5042
options -> color_moved = cm ;
5039
5043
} 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 ;
5041
5048
} else if (skip_to_optional_arg_default (arg , "--color-words" , & options -> word_regex , NULL )) {
5042
5049
options -> use_color = 1 ;
5043
5050
options -> word_diff = DIFF_WORDS_COLOR ;
0 commit comments