]> git.ipfire.org Git - thirdparty/git.git/blobdiff - merge-recursive.c
hashmap_get_next returns "struct hashmap_entry *"
[thirdparty/git.git] / merge-recursive.c
index 12300131fc12b15fbc9514e90ca45d76113d7267..a685b4fb6982b8892ec74eec741bec202b54e843 100644 (file)
@@ -61,9 +61,9 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
 
        if (dir == NULL)
                return NULL;
-       hashmap_entry_init(&key, strhash(dir));
+       hashmap_entry_init(&key.ent, strhash(dir));
        key.dir = dir;
-       return hashmap_get(hashmap, &key, NULL);
+       return hashmap_get(hashmap, &key.ent, NULL);
 }
 
 static int dir_rename_cmp(const void *unused_cmp_data,
@@ -85,7 +85,7 @@ static void dir_rename_init(struct hashmap *map)
 static void dir_rename_entry_init(struct dir_rename_entry *entry,
                                  char *directory)
 {
-       hashmap_entry_init(entry, strhash(directory));
+       hashmap_entry_init(&entry->ent, strhash(directory));
        entry->dir = directory;
        entry->non_unique_new_dir = 0;
        strbuf_init(&entry->new_dir, 0);
@@ -97,9 +97,9 @@ static struct collision_entry *collision_find_entry(struct hashmap *hashmap,
 {
        struct collision_entry key;
 
-       hashmap_entry_init(&key, strhash(target_file));
+       hashmap_entry_init(&key.ent, strhash(target_file));
        key.target_file = target_file;
-       return hashmap_get(hashmap, &key, NULL);
+       return hashmap_get(hashmap, &key.ent, NULL);
 }
 
 static int collision_cmp(void *unused_cmp_data,
@@ -454,8 +454,8 @@ static int save_files_dirs(const struct object_id *oid,
        strbuf_addstr(base, path);
 
        FLEX_ALLOC_MEM(entry, path, base->buf, base->len);
-       hashmap_entry_init(entry, path_hash(entry->path));
-       hashmap_add(&opt->current_file_dir_set, entry);
+       hashmap_entry_init(&entry->e, path_hash(entry->path));
+       hashmap_add(&opt->current_file_dir_set, &entry->e);
 
        strbuf_setlen(base, baselen);
        return (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
@@ -731,8 +731,8 @@ static char *unique_path(struct merge_options *opt, const char *path, const char
        }
 
        FLEX_ALLOC_MEM(entry, path, newpath.buf, newpath.len);
-       hashmap_entry_init(entry, path_hash(entry->path));
-       hashmap_add(&opt->current_file_dir_set, entry);
+       hashmap_entry_init(&entry->e, path_hash(entry->path));
+       hashmap_add(&opt->current_file_dir_set, &entry->e);
        return strbuf_detach(&newpath, NULL);
 }
 
@@ -2001,7 +2001,7 @@ static void remove_hashmap_entries(struct hashmap *dir_renames,
 
        for (i = 0; i < items_to_remove->nr; i++) {
                entry = items_to_remove->items[i].util;
-               hashmap_remove(dir_renames, entry, NULL);
+               hashmap_remove(dir_renames, &entry->ent, NULL);
        }
        string_list_clear(items_to_remove, 0);
 }
@@ -2229,7 +2229,7 @@ static struct hashmap *get_directory_renames(struct diff_queue_struct *pairs)
                if (!entry) {
                        entry = xmalloc(sizeof(*entry));
                        dir_rename_entry_init(entry, old_dir);
-                       hashmap_put(dir_renames, entry);
+                       hashmap_put(dir_renames, &entry->ent);
                } else {
                        free(old_dir);
                }
@@ -2358,8 +2358,9 @@ static void compute_collisions(struct hashmap *collisions,
                if (!collision_ent) {
                        collision_ent = xcalloc(1,
                                                sizeof(struct collision_entry));
-                       hashmap_entry_init(collision_ent, strhash(new_path));
-                       hashmap_put(collisions, collision_ent);
+                       hashmap_entry_init(&collision_ent->ent,
+                                               strhash(new_path));
+                       hashmap_put(collisions, &collision_ent->ent);
                        collision_ent->target_file = new_path;
                } else {
                        free(new_path);
@@ -2863,7 +2864,8 @@ static int detect_and_process_renames(struct merge_options *opt,
        head_pairs = get_diffpairs(opt, common, head);
        merge_pairs = get_diffpairs(opt, common, merge);
 
-       if (opt->detect_directory_renames) {
+       if ((opt->detect_directory_renames == 2) ||
+           (opt->detect_directory_renames == 1 && !opt->call_depth)) {
                dir_re_head = get_directory_renames(head_pairs);
                dir_re_merge = get_directory_renames(merge_pairs);