Merge branch 'js/maint-rebase-i-submodule'
[gitweb.git] / merge-tree.c
index a3511b76ca5f619024ac5fedd17e66ef75f717ab..f18201acdb21f7eb3e09a546382417851b572fd4 100644 (file)
@@ -2,6 +2,7 @@
 #include "tree-walk.h"
 #include "xdiff-interface.h"
 #include "blob.h"
+#include "exec_cmd.h"
 
 static const char merge_tree_usage[] = "git-merge-tree <base-tree> <branch1> <branch2>";
 static int resolve_directories = 1;
@@ -158,9 +159,8 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
 
 static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
 {
-       struct merge_list *res = xmalloc(sizeof(*res));
+       struct merge_list *res = xcalloc(1, sizeof(*res));
 
-       memset(res, 0, sizeof(*res));
        res->stage = stage;
        res->path = path;
        res->mode = mode;
@@ -287,31 +287,32 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
  * The successful merge rules are the same as for the three-way merge
  * in git-read-tree.
  */
-static void threeway_callback(int n, unsigned long mask, struct name_entry *entry, struct traverse_info *info)
+static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
 {
        /* Same in both? */
        if (same_entry(entry+1, entry+2)) {
                if (entry[0].sha1) {
                        resolve(info, NULL, entry+1);
-                       return;
+                       return mask;
                }
        }
 
        if (same_entry(entry+0, entry+1)) {
                if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
                        resolve(info, entry+1, entry+2);
-                       return;
+                       return mask;
                }
        }
 
        if (same_entry(entry+0, entry+2)) {
                if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
                        resolve(info, NULL, entry+1);
-                       return;
+                       return mask;
                }
        }
 
        unresolved(info, entry);
+       return mask;
 }
 
 static void merge_trees(struct tree_desc t[3], const char *base)
@@ -344,6 +345,8 @@ int main(int argc, char **argv)
        if (argc != 4)
                usage(merge_tree_usage);
 
+       git_extract_argv0_path(argv[0]);
+
        setup_git_directory();
 
        buf1 = get_tree_descriptor(t+0, argv[1]);