Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-05-22 17:17:45 +0300
committerJunio C Hamano <gitster@pobox.com>2017-05-23 08:29:55 +0300
commit2ced105cb1df064b9400aef5f4d35e20026ab267 (patch)
treef9a32c742c83422971c9694d71d67e5d4fe0ba18 /refs.c
parent30173b8851bb7203de938a638386cb9e6d7c501b (diff)
ref_update_reject_duplicates(): expose function to whole refs module
It will soon have some other users. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index b3860a9e33..beb49fb297 100644
--- a/refs.c
+++ b/refs.c
@@ -1702,6 +1702,23 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
refs_heads_master, logmsg);
}
+int ref_update_reject_duplicates(struct string_list *refnames,
+ struct strbuf *err)
+{
+ int i, n = refnames->nr;
+
+ assert(err);
+
+ for (i = 1; i < n; i++)
+ if (!strcmp(refnames->items[i - 1].string, refnames->items[i].string)) {
+ strbuf_addf(err,
+ "multiple updates for ref '%s' not allowed.",
+ refnames->items[i].string);
+ return 1;
+ }
+ return 0;
+}
+
int ref_transaction_prepare(struct ref_transaction *transaction,
struct strbuf *err)
{