]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/difftool.c
Merge branch 'js/azure-pipelines-msvc'
[thirdparty/git.git] / builtin / difftool.c
index fa9c862e3aaa2c87a39de2254136beb2dcd810c0..c280e682b2aec8ba8d136576d2c3039b1d62b985 100644 (file)
@@ -125,12 +125,15 @@ struct working_tree_entry {
 };
 
 static int working_tree_entry_cmp(const void *unused_cmp_data,
-                                 const void *entry,
-                                 const void *entry_or_key,
+                                 const struct hashmap_entry *eptr,
+                                 const struct hashmap_entry *entry_or_key,
                                  const void *unused_keydata)
 {
-       const struct working_tree_entry *a = entry;
-       const struct working_tree_entry *b = entry_or_key;
+       const struct working_tree_entry *a, *b;
+
+       a = container_of(eptr, const struct working_tree_entry, entry);
+       b = container_of(entry_or_key, const struct working_tree_entry, entry);
+
        return strcmp(a->path, b->path);
 }
 
@@ -145,12 +148,14 @@ struct pair_entry {
 };
 
 static int pair_cmp(const void *unused_cmp_data,
-                   const void *entry,
-                   const void *entry_or_key,
+                   const struct hashmap_entry *eptr,
+                   const struct hashmap_entry *entry_or_key,
                    const void *unused_keydata)
 {
-       const struct pair_entry *a = entry;
-       const struct pair_entry *b = entry_or_key;
+       const struct pair_entry *a, *b;
+
+       a = container_of(eptr, const struct pair_entry, entry);
+       b = container_of(entry_or_key, const struct pair_entry, entry);
 
        return strcmp(a->path, b->path);
 }
@@ -162,7 +167,7 @@ static void add_left_or_right(struct hashmap *map, const char *path,
 
        FLEX_ALLOC_STR(e, path, path);
        hashmap_entry_init(&e->entry, strhash(path));
-       existing = hashmap_get_entry(map, e, NULL, struct pair_entry, entry);
+       existing = hashmap_get_entry(map, e, entry, NULL);
        if (existing) {
                free(e);
                e = existing;
@@ -179,12 +184,14 @@ struct path_entry {
 };
 
 static int path_entry_cmp(const void *unused_cmp_data,
-                         const void *entry,
-                         const void *entry_or_key,
+                         const struct hashmap_entry *eptr,
+                         const struct hashmap_entry *entry_or_key,
                          const void *key)
 {
-       const struct path_entry *a = entry;
-       const struct path_entry *b = entry_or_key;
+       const struct path_entry *a, *b;
+
+       a = container_of(eptr, const struct path_entry, entry);
+       b = container_of(entry_or_key, const struct path_entry, entry);
 
        return strcmp(a->path, key ? key : b->path);
 }
@@ -531,8 +538,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
         * temporary file to both the left and right directories to show the
         * change in the recorded SHA1 for the submodule.
         */
-       hashmap_iter_init(&submodules, &iter);
-       while ((entry = hashmap_iter_next(&iter))) {
+       hashmap_for_each_entry(&submodules, &iter, entry,
+                               entry /* member name */) {
                if (*entry->left) {
                        add_path(&ldir, ldir_len, entry->path);
                        ensure_leading_directories(ldir.buf);
@@ -550,8 +557,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
         * shows only the link itself, not the contents of the link target.
         * This loop replicates that behavior.
         */
-       hashmap_iter_init(&symlinks2, &iter);
-       while ((entry = hashmap_iter_next(&iter))) {
+       hashmap_for_each_entry(&symlinks2, &iter, entry,
+                               entry /* member name */) {
                if (*entry->left) {
                        add_path(&ldir, ldir_len, entry->path);
                        ensure_leading_directories(ldir.buf);