X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-add.c;h=f9a65803d8dcbb9ae7eb3a3c61d8ac345b84d1cd;hb=182af8343c307436bb5364309aa6d4d46fa5911d;hp=b08e68831a3d3b5ff91e679b4e1862bf65f22bff;hpb=480611d170e1c013b06a49e81a178fefd278b313;p=git.git diff --git a/builtin-add.c b/builtin-add.c index b08e68831..f9a65803d 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -71,12 +71,8 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec, baselen = common_prefix(pathspec); path = "."; base = ""; - if (baselen) { - char *common = xmalloc(baselen + 1); - memcpy(common, *pathspec, baselen); - common[baselen] = 0; - path = base = common; - } + if (baselen) + path = base = xmemdupz(*pathspec, baselen); /* Read the directory and prune it */ read_directory(dir, path, base, baselen, pathspec); @@ -95,14 +91,14 @@ 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: remove_file_from_cache(path); - cache_tree_invalidate_path(active_cache_tree, path); if (verbose) printf("remove '%s'\n", path); break; @@ -155,7 +151,7 @@ static int git_add_config(const char *var, const char *value) 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) @@ -250,12 +246,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++)