diff.c: emit_diff_symbol learns about DIFF_SYMBOL_SUMMARY
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index beb49fb2979fe7780e721237cc0e4d7c47c355ee..eef1a7b67de48d1c929921549889112fe1f5d934 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
  */
 
 #include "cache.h"
+#include "config.h"
 #include "hashmap.h"
 #include "lockfile.h"
 #include "iterator.h"
@@ -1259,6 +1260,11 @@ struct ref_iterator *refs_ref_iterator_begin(
 {
        struct ref_iterator *iter;
 
+       if (ref_paranoia < 0)
+               ref_paranoia = git_env_bool("GIT_REF_PARANOIA", 0);
+       if (ref_paranoia)
+               flags |= DO_FOR_EACH_INCLUDE_BROKEN;
+
        iter = refs->be->iterator_begin(refs, prefix, flags);
 
        /*
@@ -1336,6 +1342,18 @@ int for_each_ref_in_submodule(const char *submodule, const char *prefix,
                                    prefix, fn, cb_data);
 }
 
+int for_each_fullref_in_submodule(const char *submodule, const char *prefix,
+                                 each_ref_fn fn, void *cb_data,
+                                 unsigned int broken)
+{
+       unsigned int flag = 0;
+
+       if (broken)
+               flag = DO_FOR_EACH_INCLUDE_BROKEN;
+       return do_for_each_ref(get_submodule_ref_store(submodule),
+                              prefix, fn, 0, flag, cb_data);
+}
+
 int for_each_replace_ref(each_ref_fn fn, void *cb_data)
 {
        return do_for_each_ref(get_main_ref_store(),
@@ -1507,7 +1525,8 @@ struct ref_store_hash_entry
        char name[FLEX_ARRAY];
 };
 
-static int ref_store_hash_cmp(const void *entry, const void *entry_or_key,
+static int ref_store_hash_cmp(const void *unused_cmp_data,
+                             const void *entry, const void *entry_or_key,
                              const void *keydata)
 {
        const struct ref_store_hash_entry *e1 = entry, *e2 = entry_or_key;
@@ -1590,7 +1609,7 @@ static void register_ref_store_map(struct hashmap *map,
                                   const char *name)
 {
        if (!map->tablesize)
-               hashmap_init(map, ref_store_hash_cmp, 0);
+               hashmap_init(map, ref_store_hash_cmp, NULL, 0);
 
        if (hashmap_put(map, alloc_ref_store_hash_entry(name, refs)))
                die("BUG: %s ref_store '%s' initialized twice", type, name);
@@ -1705,17 +1724,23 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
 int ref_update_reject_duplicates(struct string_list *refnames,
                                 struct strbuf *err)
 {
-       int i, n = refnames->nr;
+       size_t i, n = refnames->nr;
 
        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;
 }