MCPcopy Create free account
hub / github.com/git/git / ref_update_reject_duplicates

Function ref_update_reject_duplicates

refs.c:2560–2581  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

2558 * sorted on entry to this function.
2559 */
2560static 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
2583struct transaction_feed_cb_data {
2584 size_t index;

Callers 1

ref_transaction_prepareFunction · 0.85

Calls 1

strbuf_addfFunction · 0.85

Tested by

no test coverage detected