Code

bundle create: keep symbolic refs' names instead of resolving them
[git.git] / builtin-add.c
index 3dd4ded937e20d326737d17cceeebb1f3f744f07..850e1c23e545e8f84e5a72ea7a7bdd1a99746938 100644 (file)
 #include "revision.h"
 
 static const char builtin_add_usage[] =
-"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--] <filepattern>...";
+"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] <filepattern>...";
 
 static int take_worktree_changes;
-static const char *excludes_file;
 
 static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
 {
@@ -44,6 +43,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
                        die("pathspec '%s' did not match any files",
                                        pathspec[i]);
        }
+        free(seen);
 }
 
 static void fill_directory(struct dir_struct *dir, const char **pathspec,
@@ -56,12 +56,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);
        }
 
        /*
@@ -95,9 +90,10 @@ static void update_callback(struct diff_queue_struct *q,
                const char *path = p->one->path;
                switch (p->status) {
                default:
-                       die("unexpacted diff status %c", p->status);
+                       die("unexpected diff status %c", p->status);
                case DIFF_STATUS_UNMERGED:
                case DIFF_STATUS_MODIFIED:
+               case DIFF_STATUS_TYPE_CHANGED:
                        add_file_to_cache(path, verbose);
                        break;
                case DIFF_STATUS_DELETED:
@@ -139,23 +135,12 @@ static void refresh(int verbose, const char **pathspec)
                if (!seen[i])
                        die("pathspec '%s' did not match any files", pathspec[i]);
        }
-}
-
-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);
+        free(seen);
 }
 
 static struct lock_file lock_file;
 
-static const char ignore_warning[] =
+static const char ignore_error[] =
 "The following paths are ignored by one of your .gitignore files:\n";
 
 int cmd_add(int argc, const char **argv, const char *prefix)
@@ -180,7 +165,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                exit(1);
        }
 
-       git_config(git_add_config);
+       git_config(git_default_config);
 
        newfd = hold_locked_index(&lock_file, 1);
 
@@ -250,12 +235,12 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                die("index file corrupt");
 
        if (dir.ignored_nr) {
-               fprintf(stderr, ignore_warning);
+               fprintf(stderr, ignore_error);
                for (i = 0; i < dir.ignored_nr; i++) {
                        fprintf(stderr, "%s\n", dir.ignored[i]->name);
                }
                fprintf(stderr, "Use -f if you really want to add them.\n");
-               exit(1);
+               die("no files added");
        }
 
        for (i = 0; i < dir.nr; i++)