Skip to content

Commit

Permalink
add description parameter to OPT__DRY_RUN
Browse files Browse the repository at this point in the history
Allows better help text to be defined than "dry run".  Also make use
of the macro in places that already had a different description.  No
object code changes intended.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Nov 15, 2010
1 parent fd03881 commit e21adb8
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Documentation/technical/api-parse-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ There are some macros to easily define options:
`OPT__COLOR(&int_var, description)`::
Add `\--color[=<when>]` and `--no-color`.

`OPT__DRY_RUN(&int_var)`::
`OPT__DRY_RUN(&int_var, description)`::
Add `-n, \--dry-run`.

`OPT__QUIET(&int_var)`::
Expand Down
2 changes: 1 addition & 1 deletion builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;

static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only),
OPT__DRY_RUN(&show_only, "dry run"),
OPT__VERBOSE(&verbose, "be verbose"),
OPT_GROUP(""),
OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
Expand Down
2 changes: 1 addition & 1 deletion builtin/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
char *seen = NULL;
struct option options[] = {
OPT__QUIET(&quiet),
OPT__DRY_RUN(&show_only),
OPT__DRY_RUN(&show_only, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force"),
OPT_BOOLEAN('d', NULL, &remove_directories,
"remove whole directories"),
Expand Down
2 changes: 1 addition & 1 deletion builtin/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
int i, newfd;
int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
struct option builtin_mv_options[] = {
OPT__DRY_RUN(&show_only),
OPT__DRY_RUN(&show_only, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force move/rename even if target exists"),
OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
OPT_END(),
Expand Down
3 changes: 1 addition & 2 deletions builtin/notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,7 @@ static int prune(int argc, const char **argv, const char *prefix)
struct notes_tree *t;
int show_only = 0, verbose = 0;
struct option options[] = {
OPT_BOOLEAN('n', "dry-run", &show_only,
"do not remove, show only"),
OPT__DRY_RUN(&show_only, "do not remove, show only"),
OPT__VERBOSE(&verbose, "report pruned notes"),
OPT_END()
};
Expand Down
3 changes: 1 addition & 2 deletions builtin/prune.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
const struct option options[] = {
OPT_BOOLEAN('n', "dry-run", &show_only,
"do not remove, show only"),
OPT__DRY_RUN(&show_only, "do not remove, show only"),
OPT__VERBOSE(&verbose, "report pruned objects"),
OPT_DATE(0, "expire", &expire,
"expire objects older than <time>"),
Expand Down
2 changes: 1 addition & 1 deletion builtin/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ static int prune(int argc, const char **argv)
{
int dry_run = 0, result = 0;
struct option options[] = {
OPT__DRY_RUN(&dry_run),
OPT__DRY_RUN(&dry_run, "dry run"),
OPT_END()
};

Expand Down
2 changes: 1 addition & 1 deletion builtin/rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int show_only = 0, force = 0, index_only = 0, recursive = 0, quiet = 0;
static int ignore_unmatch = 0;

static struct option builtin_rm_options[] = {
OPT__DRY_RUN(&show_only),
OPT__DRY_RUN(&show_only, "dry run"),
OPT__QUIET(&quiet),
OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"),
OPT_BOOLEAN('f', "force", &force, "override the up-to-date check"),
Expand Down
2 changes: 1 addition & 1 deletion parse-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ extern int parse_opt_tertiary(const struct option *, const char *, int);
PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }, \
{ OPTION_CALLBACK, 'q', "quiet", (var), NULL, "be more quiet", \
PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }
#define OPT__DRY_RUN(var) OPT_BOOLEAN('n', "dry-run", (var), "dry run")
#define OPT__DRY_RUN(var, h) OPT_BOOLEAN('n', "dry-run", (var), (h))
#define OPT__ABBREV(var) \
{ OPTION_CALLBACK, 0, "abbrev", (var), "n", \
"use <n> digits to display SHA-1s", \
Expand Down
2 changes: 1 addition & 1 deletion test-parse-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, const char **argv)
OPT_GROUP("Standard options"),
OPT__ABBREV(&abbrev),
OPT__VERBOSE(&verbose, "be verbose"),
OPT__DRY_RUN(&dry_run),
OPT__DRY_RUN(&dry_run, "dry run"),
OPT__QUIET(&quiet),
OPT_END(),
};
Expand Down

0 comments on commit e21adb8

Please sign in to comment.