Code

Don't use $author_name undefined when $from contains no /\s</.
[git.git] / merge-recursive.c
index 48b2763de6892be60ab6be8a6e490d15e4ff81ac..2ba43ae84b20f993ba175f728297cf5360066872 100644 (file)
@@ -513,8 +513,8 @@ static char *unique_path(const char *path, const char *branch)
 
 static int mkdir_p(const char *path, unsigned long mode)
 {
-       /* path points to cache entries, so strdup before messing with it */
-       char *buf = strdup(path);
+       /* path points to cache entries, so xstrdup before messing with it */
+       char *buf = xstrdup(path);
        int result = safe_create_leading_directories(buf);
        free(buf);
        return result;
@@ -668,9 +668,9 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
                        git_unpack_file(a->sha1, src1);
                        git_unpack_file(b->sha1, src2);
 
-                       argv[2] = la = strdup(mkpath("%s/%s", branch1, a->path));
-                       argv[6] = lb = strdup(mkpath("%s/%s", branch2, b->path));
-                       argv[4] = lo = strdup(mkpath("orig/%s", o->path));
+                       argv[2] = la = xstrdup(mkpath("%s/%s", branch1, a->path));
+                       argv[6] = lb = xstrdup(mkpath("%s/%s", branch2, b->path));
+                       argv[4] = lo = xstrdup(mkpath("orig/%s", o->path));
                        argv[7] = src1;
                        argv[8] = orig;
                        argv[9] = src2,
@@ -1235,13 +1235,10 @@ int merge(struct commit *h1,
        if (merged_common_ancestors == NULL) {
                /* if there is no common ancestor, make an empty tree */
                struct tree *tree = xcalloc(1, sizeof(struct tree));
-               unsigned char hdr[40];
-               int hdrlen;
 
                tree->object.parsed = 1;
                tree->object.type = OBJ_TREE;
-               write_sha1_file_prepare(NULL, 0, tree_type, tree->object.sha1,
-                                       hdr, &hdrlen);
+               hash_sha1_file(NULL, 0, tree_type, tree->object.sha1);
                merged_common_ancestors = make_virtual_commit(tree, "ancestor");
        }
 
@@ -1314,9 +1311,9 @@ int main(int argc, char *argv[])
        original_index_file = getenv("GIT_INDEX_FILE");
 
        if (!original_index_file)
-               original_index_file = strdup(git_path("index"));
+               original_index_file = xstrdup(git_path("index"));
 
-       temporary_index_file = strdup(git_path("mrg-rcrsv-tmp-idx"));
+       temporary_index_file = xstrdup(git_path("mrg-rcrsv-tmp-idx"));
 
        if (argc < 4)
                die("Usage: %s <base>... -- <head> <remote> ...\n", argv[0]);