diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-14 12:56:08 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-14 12:56:08 -0700 |
| commit | 048625a6898f2bcc212f0d4baec1d18695b028a5 (patch) | |
| tree | 8a7ea947d64d5bd9a7fe79770b5056e8485cb14c /refs.c | |
| parent | ca5a44b15c0b47e4e2588541e735dfac7ebd888c (diff) | |
| parent | 22e7bc801cd9c5e5b5c4489b631be28e506fec42 (diff) | |
Merge branch 'sj/string-list'
The "string-list" API function to find where a given string would
be inserted got updated so that it can use unrealistically huge
array index that would only fit in size_t but not int or ssize_t
to achieve unstated goal.
* sj/string-list:
refs: enable sign compare warnings check
string-list: change "string_list_find_insert_index" return type to "size_t"
string-list: replace negative index encoding with "exact_match" parameter
string-list: use bool instead of int for "exact_match"
Diffstat (limited to 'refs.c')
| -rw-r--r-- | refs.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -3,7 +3,6 @@ */ #define USE_THE_REPOSITORY_VARIABLE -#define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h" #include "advice.h" @@ -1714,8 +1713,6 @@ const char *find_descendant_ref(const char *dirname, const struct string_list *extras, const struct string_list *skip) { - int pos; - if (!extras) return NULL; @@ -1725,7 +1722,7 @@ const char *find_descendant_ref(const char *dirname, * with dirname (remember, dirname includes the trailing * slash) and is not in skip, then we have a conflict. */ - for (pos = string_list_find_insert_index(extras, dirname, 0); + for (size_t pos = string_list_find_insert_index(extras, dirname, NULL); pos < extras->nr; pos++) { const char *extra_refname = extras->items[pos].string; @@ -2414,7 +2411,7 @@ static int run_transaction_hook(struct ref_transaction *transaction, struct child_process proc = CHILD_PROCESS_INIT; struct strbuf buf = STRBUF_INIT; const char *hook; - int ret = 0, i; + int ret = 0; hook = find_hook(transaction->ref_store->repo, "reference-transaction"); if (!hook) @@ -2431,7 +2428,7 @@ static int run_transaction_hook(struct ref_transaction *transaction, sigchain_push(SIGPIPE, SIG_IGN); - for (i = 0; i < transaction->nr; i++) { + for (size_t i = 0; i < transaction->nr; i++) { struct ref_update *update = transaction->updates[i]; if (update->flags & REF_LOG_ONLY) @@ -2824,9 +2821,7 @@ void ref_transaction_for_each_queued_update(struct ref_transaction *transaction, ref_transaction_for_each_queued_update_fn cb, void *cb_data) { - int i; - - for (i = 0; i < transaction->nr; i++) { + for (size_t i = 0; i < transaction->nr; i++) { struct ref_update *update = transaction->updates[i]; cb(update->refname, |
