]> Pileus Git - ~andy/git/blobdiff - builtin/add.c
Call git_pathdup() rather than xstrdup(git_path("..."))
[~andy/git] / builtin / add.c
index 87446cf92a686ed69717c85a6b38302f59351460..2fc267742239c6360c4a38cab7a0277d3407bac2 100644 (file)
@@ -260,7 +260,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)
 
 static int edit_patch(int argc, const char **argv, const char *prefix)
 {
-       char *file = xstrdup(git_path("ADD_EDIT.patch"));
+       char *file = git_pathdup("ADD_EDIT.patch");
        const char *apply_argv[] = { "apply", "--recount", "--cached",
                NULL, NULL };
        struct child_process child;
@@ -281,7 +281,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
        argc = setup_revisions(argc, argv, &rev, NULL);
        rev.diffopt.output_format = DIFF_FORMAT_PATCH;
        DIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);
-       out = open(file, O_CREAT | O_WRONLY, 0644);
+       out = open(file, O_CREAT | O_WRONLY, 0666);
        if (out < 0)
                die (_("Could not open '%s' for writing."), file);
        rev.diffopt.file = xfdopen(out, "w");
@@ -303,6 +303,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
                die (_("Could not apply '%s'"), file);
 
        unlink(file);
+       free(file);
        return 0;
 }