зеркало из https://github.com/microsoft/git.git
ref_update_reject_duplicates(): add a sanity check
It's pretty cheap to make sure that the caller didn't pass us an unsorted list by accident, so do so. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
a552e50e5a
Коммит
8556f8d613
10
refs.c
10
refs.c
|
@ -1709,13 +1709,19 @@ int ref_update_reject_duplicates(struct string_list *refnames,
|
|||
|
||||
assert(err);
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
if (!strcmp(refnames->items[i - 1].string, refnames->items[i].string)) {
|
||||
for (i = 1; i < n; i++) {
|
||||
int cmp = strcmp(refnames->items[i - 1].string,
|
||||
refnames->items[i].string);
|
||||
|
||||
if (!cmp) {
|
||||
strbuf_addf(err,
|
||||
"multiple updates for ref '%s' not allowed.",
|
||||
refnames->items[i].string);
|
||||
return 1;
|
||||
} else if (cmp > 0) {
|
||||
die("BUG: ref_update_reject_duplicates() received unsorted list");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче