]> Pileus Git - ~andy/git/blobdiff - builtin/add.c
Call git_pathdup() rather than xstrdup(git_path("..."))
[~andy/git] / builtin / add.c
index b79336d712b4c71cc2f026b0e9f42ea0bcebfc6f..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;
 }
 
@@ -443,6 +444,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 
        if (pathspec) {
                int i;
+               struct path_exclude_check check;
+
+               path_exclude_check_init(&check, &dir);
                if (!seen)
                        seen = find_used_pathspec(pathspec);
                for (i = 0; pathspec[i]; i++) {
@@ -450,7 +454,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                            && !file_exists(pathspec[i])) {
                                if (ignore_missing) {
                                        int dtype = DT_UNKNOWN;
-                                       if (excluded(&dir, pathspec[i], &dtype))
+                                       if (path_excluded(&check, pathspec[i], -1, &dtype))
                                                dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i]));
                                } else
                                        die(_("pathspec '%s' did not match any files"),
@@ -458,6 +462,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                        }
                }
                free(seen);
+               path_exclude_check_clear(&check);
        }
 
        plug_bulk_checkin();