From d52ee6e6131f65bb4360743ebea2e7b400b544e4 Mon Sep 17 00:00:00 2001 From: RenĂ© Scharfe Date: Mon, 8 Nov 2010 19:06:54 +0100 Subject: add description parameter to OPT__QUIET Allows better help text to be defined than "be quiet". Also make use of the macro in a place that already had a different description. No object code changes intended. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- builtin/checkout-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/checkout-index.c') diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 65cbee0552..7ba09130cc 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -219,7 +219,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) "checks out all files in the index"), OPT_BOOLEAN('f', "force", &force, "forces overwrite of existing files"), - OPT__QUIET(&quiet), + OPT__QUIET(&quiet, "be quiet"), OPT_BOOLEAN('n', "no-create", ¬_new, "don't checkout new files"), { OPTION_CALLBACK, 'u', "index", &newfd, NULL, -- cgit 1.2.3-korg From 76946b76fe3d26507d61cae97aa0676fad24ed92 Mon Sep 17 00:00:00 2001 From: RenĂ© Scharfe Date: Mon, 8 Nov 2010 19:01:54 +0100 Subject: 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 --- Documentation/technical/api-parse-options.txt | 3 +++ builtin/add.c | 2 +- builtin/branch.c | 2 +- builtin/checkout-index.c | 3 +-- builtin/checkout.c | 2 +- builtin/clean.c | 2 +- builtin/fetch.c | 3 +-- builtin/mv.c | 2 +- builtin/notes.c | 4 ++-- builtin/rm.c | 2 +- builtin/tag.c | 2 +- builtin/update-server-info.c | 3 +-- parse-options.h | 1 + 13 files changed, 16 insertions(+), 15 deletions(-) (limited to 'builtin/checkout-index.c') diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt index 248a66dffb..f6a4a361bd 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 9625ceeb5b..71f9b04fef 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 10788fc1dd..e388edc413 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 7ba09130cc..91fb9bfc62 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 a952477d19..f275570cbd 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 449d2a3237..9146bf3c1c 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 d35f000c03..6aaf8e96b4 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 8677bd2e40..93e8995d9e 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 2ab070fa09..c85cbf5a47 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 49461b60c7..9a5990513a 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 d311491e49..d1d7d8701d 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 2b3fddcc69..b90dce6358 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 3dd3a94f22..ae8647d893 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", \ -- cgit 1.2.3-korg From 8c83968385e1e742e188435fd2fe5ebf57565e49 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 8 Nov 2010 13:54:48 -0600 Subject: Describe various forms of "be quiet" using OPT__QUIET Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/checkout-index.c | 3 ++- builtin/checkout.c | 2 +- builtin/clean.c | 2 +- builtin/commit.c | 4 ++-- builtin/gc.c | 2 +- builtin/merge-file.c | 2 +- builtin/reset.c | 2 +- builtin/rm.c | 2 +- builtin/show-ref.c | 3 ++- builtin/symbolic-ref.c | 3 ++- 10 files changed, 14 insertions(+), 11 deletions(-) (limited to 'builtin/checkout-index.c') diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 91fb9bfc62..1ee3044307 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -218,7 +218,8 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) OPT_BOOLEAN('a', "all", &all, "checks out all files in the index"), OPT__FORCE(&force, "forces overwrite of existing files"), - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, + "no warning for existing files and files not in index"), OPT_BOOLEAN('n', "no-create", ¬_new, "don't checkout new files"), { OPTION_CALLBACK, 'u', "index", &newfd, NULL, diff --git a/builtin/checkout.c b/builtin/checkout.c index f275570cbd..f9114de9a4 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -686,7 +686,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) int patch_mode = 0; int dwim_new_local_branch = 1; struct option options[] = { - OPT__QUIET(&opts.quiet, "be quiet"), + OPT__QUIET(&opts.quiet, "suppress progress reporting"), OPT_STRING('b', NULL, &opts.new_branch, "branch", "create and checkout a new branch"), OPT_STRING('B', NULL, &opts.new_branch_force, "branch", diff --git a/builtin/clean.c b/builtin/clean.c index 9146bf3c1c..5e47c53cdb 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -48,7 +48,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) const char *qname; char *seen = NULL; struct option options[] = { - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, "do not print names of files removed"), OPT__DRY_RUN(&show_only, "dry run"), OPT__FORCE(&force, "force"), OPT_BOOLEAN('d', NULL, &remove_directories, diff --git a/builtin/commit.c b/builtin/commit.c index 97ae1bca4b..4fd1a1692f 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -114,8 +114,8 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset) } static struct option builtin_commit_options[] = { - OPT__QUIET(&quiet, "be quiet"), - OPT__VERBOSE(&verbose, "be verbose"), + OPT__QUIET(&quiet, "suppress summary after successful commit"), + OPT__VERBOSE(&verbose, "show diff in commit message template"), OPT_GROUP("Commit message options"), OPT_FILENAME('F', "file", &logfile, "read log from file"), diff --git a/builtin/gc.c b/builtin/gc.c index 8f67325370..397a1e6eb3 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -180,7 +180,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix) char buf[80]; struct option builtin_gc_options[] = { - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, "suppress progress reporting"), { OPTION_STRING, 0, "prune", &prune_expire, "date", "prune unreferenced objects", PARSE_OPT_OPTARG, NULL, (intptr_t)prune_expire }, diff --git a/builtin/merge-file.c b/builtin/merge-file.c index 58e473141c..9d75ed42c2 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -39,7 +39,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix) XDL_MERGE_FAVOR_UNION), OPT_INTEGER(0, "marker-size", &xmp.marker_size, "for conflicts, use this marker size"), - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, "do not warn about conflicts"), OPT_CALLBACK('L', NULL, names, "name", "set labels for file1/orig_file/file2", &label_cb), OPT_END(), diff --git a/builtin/reset.c b/builtin/reset.c index d6242071ba..5de2bceeec 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -243,7 +243,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) struct commit *commit; char *reflog_action, msg[1024]; const struct option options[] = { - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, "be quiet, only report errors"), OPT_SET_INT(0, "mixed", &reset_type, "reset HEAD and index", MIXED), OPT_SET_INT(0, "soft", &reset_type, "reset only HEAD", SOFT), diff --git a/builtin/rm.c b/builtin/rm.c index 9a5990513a..c7b7bb37a2 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -140,7 +140,7 @@ static int ignore_unmatch = 0; static struct option builtin_rm_options[] = { OPT__DRY_RUN(&show_only, "dry run"), - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, "do not list removed files"), OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"), OPT__FORCE(&force, "override the up-to-date check"), OPT_BOOLEAN('r', NULL, &recursive, "allow recursive removal"), diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 6507f03d32..45f0340c3e 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -193,7 +193,8 @@ static const struct option show_ref_options[] = { "only show SHA1 hash using digits", PARSE_OPT_OPTARG, &hash_callback }, OPT__ABBREV(&abbrev), - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, + "do not print results to stdout (useful with --verify)"), { OPTION_CALLBACK, 0, "exclude-existing", &exclude_existing_arg, "pattern", "show refs from stdin that aren't in local repository", PARSE_OPT_OPTARG | PARSE_OPT_NONEG, exclude_existing_callback }, diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c index 1b284253f2..dea849c3c5 100644 --- a/builtin/symbolic-ref.c +++ b/builtin/symbolic-ref.c @@ -30,7 +30,8 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) int quiet = 0; const char *msg = NULL; struct option options[] = { - OPT__QUIET(&quiet, "be quiet"), + OPT__QUIET(&quiet, + "suppress error message for non-symbolic (detached) refs"), OPT_STRING('m', NULL, &msg, "reason", "reason of the update"), OPT_END(), }; -- cgit 1.2.3-korg