From: RenĂ© Scharfe Date: Mon, 8 Nov 2010 18:01:54 +0000 (+0100) Subject: add OPT__FORCE X-Git-Tag: v1.7.4-rc0~120^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=76946b76fe3d26507d61cae97aa0676fad24ed92;p=git.git add OPT__FORCE Add OPT__FORCE as a helper macro in the same spirit as OPT__VERBOSE et.al. to simplify defining -f/--force options. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt index 248a66dff..f6a4a361b 100644 --- a/Documentation/technical/api-parse-options.txt +++ b/Documentation/technical/api-parse-options.txt @@ -121,6 +121,9 @@ There are some macros to easily define options: `OPT__DRY_RUN(&int_var, description)`:: Add `-n, \--dry-run`. +`OPT__FORCE(&int_var, description)`:: + Add `-f, \--force`. + `OPT__QUIET(&int_var, description)`:: Add `-q, \--quiet`. diff --git a/builtin/add.c b/builtin/add.c index 9625ceeb5..71f9b04fe 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -319,7 +319,7 @@ static struct option builtin_add_options[] = { OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"), OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"), OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"), - OPT_BOOLEAN('f', "force", &ignored_too, "allow adding otherwise ignored files"), + OPT__FORCE(&ignored_too, "allow adding otherwise ignored files"), OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"), OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, "record only the fact that the path will be added later"), OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"), diff --git a/builtin/branch.c b/builtin/branch.c index 10788fc1d..e388edc41 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -651,7 +651,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) OPT_BIT('m', NULL, &rename, "move/rename a branch and its reflog", 1), OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2), OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"), - OPT_BOOLEAN('f', "force", &force_create, "force creation (when already exists)"), + OPT__FORCE(&force_create, "force creation (when already exists)"), { OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref, "commit", "print only not merged branches", diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 7ba09130c..91fb9bfc6 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -217,8 +217,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) struct option builtin_checkout_index_options[] = { OPT_BOOLEAN('a', "all", &all, "checks out all files in the index"), - OPT_BOOLEAN('f', "force", &force, - "forces overwrite of existing files"), + OPT__FORCE(&force, "forces overwrite of existing files"), OPT__QUIET(&quiet, "be quiet"), OPT_BOOLEAN('n', "no-create", ¬_new, "don't checkout new files"), diff --git a/builtin/checkout.c b/builtin/checkout.c index a952477d1..f275570cb 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -699,7 +699,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) 2), OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files", 3), - OPT_BOOLEAN('f', "force", &opts.force, "force checkout (throw away local modifications)"), + OPT__FORCE(&opts.force, "force checkout (throw away local modifications)"), OPT_BOOLEAN('m', "merge", &opts.merge, "perform a 3-way merge with the new branch"), OPT_STRING(0, "conflict", &conflict_style, "style", "conflict style (merge or diff3)"), diff --git a/builtin/clean.c b/builtin/clean.c index 449d2a323..9146bf3c1 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -50,7 +50,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) struct option options[] = { OPT__QUIET(&quiet, "be quiet"), OPT__DRY_RUN(&show_only, "dry run"), - OPT_BOOLEAN('f', "force", &force, "force"), + OPT__FORCE(&force, "force"), OPT_BOOLEAN('d', NULL, &remove_directories, "remove whole directories"), { OPTION_CALLBACK, 'e', "exclude", &exclude_list, "pattern", diff --git a/builtin/fetch.c b/builtin/fetch.c index d35f000c0..6aaf8e96b 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -43,8 +43,7 @@ static struct option builtin_fetch_options[] = { "append to .git/FETCH_HEAD instead of overwriting"), OPT_STRING(0, "upload-pack", &upload_pack, "PATH", "path to upload pack on remote end"), - OPT_BOOLEAN('f', "force", &force, - "force overwrite of local branch"), + OPT__FORCE(&force, "force overwrite of local branch"), OPT_BOOLEAN('m', "multiple", &multiple, "fetch from multiple remotes"), OPT_SET_INT('t', "tags", &tags, diff --git a/builtin/mv.c b/builtin/mv.c index 8677bd2e4..93e8995d9 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -56,7 +56,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) int verbose = 0, show_only = 0, force = 0, ignore_errors = 0; struct option builtin_mv_options[] = { OPT__DRY_RUN(&show_only, "dry run"), - OPT_BOOLEAN('f', "force", &force, "force move/rename even if target exists"), + OPT__FORCE(&force, "force move/rename even if target exists"), OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"), OPT_END(), }; diff --git a/builtin/notes.c b/builtin/notes.c index 2ab070fa0..c85cbf5a4 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -538,7 +538,7 @@ static int add(int argc, const char **argv, const char *prefix) { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT", "reuse specified note object", PARSE_OPT_NONEG, parse_reuse_arg}, - OPT_BOOLEAN('f', "force", &force, "replace existing notes"), + OPT__FORCE(&force, "replace existing notes"), OPT_END() }; @@ -594,7 +594,7 @@ static int copy(int argc, const char **argv, const char *prefix) struct notes_tree *t; const char *rewrite_cmd = NULL; struct option options[] = { - OPT_BOOLEAN('f', "force", &force, "replace existing notes"), + OPT__FORCE(&force, "replace existing notes"), OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"), OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command", "load rewriting config for (implies " diff --git a/builtin/rm.c b/builtin/rm.c index 49461b60c..9a5990513 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -142,7 +142,7 @@ static struct option builtin_rm_options[] = { OPT__DRY_RUN(&show_only, "dry run"), OPT__QUIET(&quiet, "be quiet"), OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"), - OPT_BOOLEAN('f', "force", &force, "override the up-to-date check"), + OPT__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"), diff --git a/builtin/tag.c b/builtin/tag.c index d311491e4..d1d7d8701 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -390,7 +390,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"), OPT_STRING('u', NULL, &keyid, "key-id", "use another key to sign the tag"), - OPT_BOOLEAN('f', "force", &force, "replace the tag if exists"), + OPT__FORCE(&force, "replace the tag if exists"), OPT_GROUP("Tag listing options"), { diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c index 2b3fddcc6..b90dce635 100644 --- a/builtin/update-server-info.c +++ b/builtin/update-server-info.c @@ -11,8 +11,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix) { int force = 0; struct option options[] = { - OPT_BOOLEAN('f', "force", &force, - "update the info files from scratch"), + OPT__FORCE(&force, "update the info files from scratch"), OPT_END() }; diff --git a/parse-options.h b/parse-options.h index 3dd3a94f2..ae8647d89 100644 --- a/parse-options.h +++ b/parse-options.h @@ -206,6 +206,7 @@ extern int parse_opt_tertiary(const struct option *, const char *, int); { OPTION_CALLBACK, 'q', "quiet", (var), NULL, "be more quiet", \ PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 } #define OPT__DRY_RUN(var, h) OPT_BOOLEAN('n', "dry-run", (var), (h)) +#define OPT__FORCE(var, h) OPT_BOOLEAN('f', "force", (var), (h)) #define OPT__ABBREV(var) \ { OPTION_CALLBACK, 0, "abbrev", (var), "n", \ "use digits to display SHA-1s", \