diff options
author | shejialuo <shejialuo@gmail.com> | 2025-06-29 12:27:57 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-07-07 08:07:46 -0700 |
commit | 885becd9c4aec6c3764b4c701baf41853b49899e (patch) | |
tree | bc5d9ccd36a5948478571da2fe65353f3807cef0 /builtin/commit-graph.c | |
parent | 394e063bf9ab88f2117fe8bb8115809420ecfeda (diff) |
string-list: return index directly when inserting an existing element
When inserting an existing element, "add_entry" would convert "index"
value to "-1-index" to indicate the caller that this element is in the
list already. However, in "string_list_insert", we would simply convert
this to the original positive index without any further action.
In 8fd2cb4069 (Extract helper bits from c-merge-recursive work,
2006-07-25), we create "path-list.c" and then introduce above code path.
Let's directly return the index as we don't care about whether the
element is in the list by using "add_entry". In the future, if we want
to let "add_entry" tell the caller, we may add "int *exact_match"
parameter to "add_entry" instead of converting the index to negative to
indicate.
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-graph.c')
0 files changed, 0 insertions, 0 deletions