summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-08-21 13:46:59 -0700
committerJunio C Hamano <gitster@pobox.com>2025-08-21 13:46:59 -0700
commit971ba42dd426f2531d5448488bcd3bd3282e6999 (patch)
tree90b087657b1dfcc37763734ad7b749e13bd2cab3 /diff.c
parent5a404a70c789707225d5c402510dd3d2e777f43a (diff)
parent2ab2aac73d234ae75096e2186b07cc14c57d2586 (diff)
Merge branch 'jc/string-list-split'
string_list_split*() family of functions have been extended to simplify common use cases. * jc/string-list-split: string-list: split-then-remove-empty can be done while splitting string-list: optionally omit empty string pieces in string_list_split*() diff: simplify parsing of diff.colormovedws string-list: optionally trim string pieces split by string_list_split*() string-list: unify string_list_split* functions string-list: align string_list_split() with its _in_place() counterpart string-list: report programming error with BUG
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/diff.c b/diff.c
index dca87e164f..70666ad2cd 100644
--- a/diff.c
+++ b/diff.c
@@ -327,29 +327,23 @@ static unsigned parse_color_moved_ws(const char *arg)
struct string_list l = STRING_LIST_INIT_DUP;
struct string_list_item *i;
- string_list_split(&l, arg, ',', -1);
+ string_list_split_f(&l, arg, ",", -1, STRING_LIST_SPLIT_TRIM);
for_each_string_list_item(i, &l) {
- struct strbuf sb = STRBUF_INIT;
- strbuf_addstr(&sb, i->string);
- strbuf_trim(&sb);
-
- if (!strcmp(sb.buf, "no"))
+ if (!strcmp(i->string, "no"))
ret = 0;
- else if (!strcmp(sb.buf, "ignore-space-change"))
+ else if (!strcmp(i->string, "ignore-space-change"))
ret |= XDF_IGNORE_WHITESPACE_CHANGE;
- else if (!strcmp(sb.buf, "ignore-space-at-eol"))
+ else if (!strcmp(i->string, "ignore-space-at-eol"))
ret |= XDF_IGNORE_WHITESPACE_AT_EOL;
- else if (!strcmp(sb.buf, "ignore-all-space"))
+ else if (!strcmp(i->string, "ignore-all-space"))
ret |= XDF_IGNORE_WHITESPACE;
- else if (!strcmp(sb.buf, "allow-indentation-change"))
+ else if (!strcmp(i->string, "allow-indentation-change"))
ret |= COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE;
else {
ret |= COLOR_MOVED_WS_ERROR;
- 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);
+ error(_("unknown color-moved-ws mode '%s', possible values are 'ignore-space-change', 'ignore-space-at-eol', 'ignore-all-space', 'allow-indentation-change'"), i->string);
}
-
- strbuf_release(&sb);
}
if ((ret & COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE) &&