]> git.neil.brown.name Git - git.git/commitdiff
Merge branch 'sb/hashmap-customize-comparison'
authorJunio C Hamano <gitster@pobox.com>
Thu, 13 Jul 2017 23:14:54 +0000 (16:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Jul 2017 23:14:54 +0000 (16:14 -0700)
Update the hashmap API so that data to customize the behaviour of
the comparison function can be specified at the time a hashmap is
initialized.

* sb/hashmap-customize-comparison:
  hashmap: migrate documentation from Documentation/technical into header
  patch-ids.c: use hashmap correctly
  hashmap.h: compare function has access to a data field

1  2 
builtin/describe.c
config.c
refs.c
sha1_file.c
submodule-config.c

Simple merge
diff --cc config.c
Simple merge
diff --cc refs.c
Simple merge
diff --cc sha1_file.c
Simple merge
index 37cfcceb950b1777b46abecd5415196c76e11826,0e1126183dbb75d3ebbf391004b2fe9f5708bd76..eeb154a894d6bfdec877d94d5922438b5f934730
@@@ -33,9 -31,13 +33,10 @@@ enum lookup_type 
        lookup_path
  };
  
- static int config_path_cmp(const struct submodule_entry *a,
 -static struct submodule_cache the_submodule_cache;
 -static int is_cache_init;
 -
+ static int config_path_cmp(const void *unused_cmp_data,
+                          const struct submodule_entry *a,
                           const struct submodule_entry *b,
-                          const void *unused)
+                          const void *unused_keydata)
  {
        return strcmp(a->config->path, b->config->path) ||
               hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
@@@ -49,16 -52,10 +51,16 @@@ static int config_name_cmp(const void *
               hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
  }
  
 -static void cache_init(struct submodule_cache *cache)
 +static struct submodule_cache *submodule_cache_alloc(void)
 +{
 +      return xcalloc(1, sizeof(struct submodule_cache));
 +}
 +
 +static void submodule_cache_init(struct submodule_cache *cache)
  {
-       hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, 0);
-       hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, 0);
+       hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, NULL, 0);
+       hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, NULL, 0);
 +      cache->initialized = 1;
  }
  
  static void free_one_config(struct submodule_entry *entry)