* Write an error to `err` and return a nonzero value iff the same * refname appears multiple times in `refnames`. `refnames` must be * sorted on entry to this function. */
| 2558 | * sorted on entry to this function. |
| 2559 | */ |
| 2560 | static int ref_update_reject_duplicates(struct string_list *refnames, |
| 2561 | struct strbuf *err) |
| 2562 | { |
| 2563 | size_t i, n = refnames->nr; |
| 2564 | |
| 2565 | assert(err); |
| 2566 | |
| 2567 | for (i = 1; i < n; i++) { |
| 2568 | int cmp = strcmp(refnames->items[i - 1].string, |
| 2569 | refnames->items[i].string); |
| 2570 | |
| 2571 | if (!cmp) { |
| 2572 | strbuf_addf(err, |
| 2573 | _("multiple updates for ref '%s' not allowed"), |
| 2574 | refnames->items[i].string); |
| 2575 | return 1; |
| 2576 | } else if (cmp > 0) { |
| 2577 | BUG("ref_update_reject_duplicates() received unsorted list"); |
| 2578 | } |
| 2579 | } |
| 2580 | return 0; |
| 2581 | } |
| 2582 | |
| 2583 | struct transaction_feed_cb_data { |
| 2584 | size_t index; |
no test coverage detected