X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-rm.c;h=fdac34f2423409add48706497fa01010219baf72;hb=e32c0a9c38a126c9eb8ff8f2fdc1fb8875400bbe;hp=bca2bd97036fdaf2e2bf99e308ba62e1acf4d9e8;hpb=140dd77a5cb2e61dcb942e245a2474fae95e42a5;p=git.git diff --git a/builtin-rm.c b/builtin-rm.c index bca2bd970..fdac34f24 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -11,7 +11,7 @@ #include "parse-options.h" static const char * const builtin_rm_usage[] = { - "git-rm [options] [--] ...", + "git rm [options] [--] ...", NULL }; @@ -104,7 +104,7 @@ static int check_local_mod(unsigned char *head, int index_only) "from both the file and the HEAD\n" "(use -f to force removal)", name); else if (!index_only) { - /* It's not dangerous to git-rm --cached a + /* It's not dangerous to "git rm --cached" a * file if the index matches the file or the * HEAD, since it means the deleted content is * still available somewhere. @@ -131,7 +131,7 @@ static struct option builtin_rm_options[] = { OPT__DRY_RUN(&show_only), OPT__QUIET(&quiet), OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"), - OPT_BOOLEAN('f', NULL, &force, "override the up-to-date check"), + OPT_BOOLEAN('f', "force", &force, "override the up-to-date check"), OPT_BOOLEAN('r', NULL, &recursive, "allow recursive removal"), OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch, "exit with a zero status even if nothing matched"), @@ -144,17 +144,20 @@ int cmd_rm(int argc, const char **argv, const char *prefix) const char **pathspec; char *seen; - git_config(git_default_config); + git_config(git_default_config, NULL); + + argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0); + if (!argc) + usage_with_options(builtin_rm_usage, builtin_rm_options); + + if (!index_only) + setup_work_tree(); newfd = hold_locked_index(&lock_file, 1); if (read_cache() < 0) die("index file corrupt"); - argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0); - if (!argc) - usage_with_options(builtin_rm_usage, builtin_rm_options); - pathspec = get_pathspec(prefix, argv); seen = NULL; for (i = 0; pathspec[i] ; i++) @@ -218,7 +221,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) printf("rm '%s'\n", path); if (remove_file_from_cache(path)) - die("git-rm: unable to remove %s", path); + die("git rm: unable to remove %s", path); } if (show_only) @@ -241,13 +244,13 @@ int cmd_rm(int argc, const char **argv, const char *prefix) continue; } if (!removed) - die("git-rm: %s: %s", path, strerror(errno)); + die("git rm: %s: %s", path, strerror(errno)); } } if (active_cache_changed) { if (write_cache(newfd, active_cache, active_nr) || - close(newfd) || commit_locked_index(&lock_file)) + commit_locked_index(&lock_file)) die("Unable to write new index file"); }