quote_path: fix collapsing of relative paths
[gitweb.git] / builtin-add.c
index 77dcde6936155953b5a7321dcbf7430cb5aa73a3..03508d3dcb18d161f799001067d5caf3e54fa160 100644 (file)
@@ -21,7 +21,6 @@ static const char * const builtin_add_usage[] = {
 };
 
 static int take_worktree_changes;
-static const char *excludes_file;
 
 static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
 {
@@ -61,12 +60,7 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec,
        memset(dir, 0, sizeof(*dir));
        if (!ignored_too) {
                dir->collect_ignored = 1;
-               dir->exclude_per_dir = ".gitignore";
-               path = git_path("info/exclude");
-               if (!access(path, R_OK))
-                       add_excludes_from_file(dir, path);
-               if (excludes_file != NULL && !access(excludes_file, R_OK))
-                       add_excludes_from_file(dir, excludes_file);
+               setup_standard_excludes(dir);
        }
 
        /*
@@ -111,12 +105,12 @@ static void update_callback(struct diff_queue_struct *q,
        }
 }
 
-void add_files_to_cache(int verbose, const char *prefix, const char **files)
+void add_files_to_cache(int verbose, const char *prefix, const char **pathspec)
 {
        struct rev_info rev;
        init_revisions(&rev, prefix);
        setup_revisions(0, NULL, &rev, NULL);
-       rev.prune_data = get_pathspec(prefix, files);
+       rev.prune_data = pathspec;
        rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = update_callback;
        rev.diffopt.format_callback_data = &verbose;
@@ -141,18 +135,6 @@ static void refresh(int verbose, const char **pathspec)
         free(seen);
 }
 
-static int git_add_config(const char *var, const char *value)
-{
-       if (!strcmp(var, "core.excludesfile")) {
-               if (!value)
-                       die("core.excludesfile without value");
-               excludes_file = xstrdup(value);
-               return 0;
-       }
-
-       return git_default_config(var, value);
-}
-
 int interactive_add(void)
 {
        const char *argv[2] = { "add--interactive", NULL };
@@ -193,14 +175,16 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                exit(interactive_add());
        }
 
-       git_config(git_add_config);
+       git_config(git_default_config);
 
        newfd = hold_locked_index(&lock_file, 1);
 
        if (take_worktree_changes) {
+               const char **pathspec;
                if (read_cache() < 0)
                        die("index file corrupt");
-               add_files_to_cache(verbose, prefix, argv);
+               pathspec = get_pathspec(prefix, argv);
+               add_files_to_cache(verbose, prefix, pathspec);
                goto finish;
        }