@matheusbsbs / matheus-bagliano / commits / e21adb8c10
Fork 0

add description parameter to OPT__DRY_RUN

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>

René Scharfe committed Nov 8, 2010 at 18:58 UTC e21adb8c100cd2859cff1d74f7d0e622ac640085
10 files changed +10 -12
Documentation/technical/api-parse-options.txt
+1 -1
@@ -118,7 +118,7 @@ There are some macros to easily define options:
118 `OPT__COLOR(&int_var, description)`::
119 Add `\--color[=<when>]` and `--no-color`.
120
121 -`OPT__DRY_RUN(&int_var)`::
121 +`OPT__DRY_RUN(&int_var, description)`::
122 Add `-n, \--dry-run`.
123
124 `OPT__QUIET(&int_var)`::
builtin/add.c
+1 -1
@@ -313,7 +313,7 @@ static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
313 static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
314
315 static struct option builtin_add_options[] = {
316 - OPT__DRY_RUN(&show_only),
316 + OPT__DRY_RUN(&show_only, "dry run"),
317 OPT__VERBOSE(&verbose, "be verbose"),
318 OPT_GROUP(""),
319 OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
builtin/clean.c
+1 -1
@@ -49,7 +49,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
49 char *seen = NULL;
50 struct option options[] = {
51 OPT__QUIET(&quiet),
52 - OPT__DRY_RUN(&show_only),
52 + OPT__DRY_RUN(&show_only, "dry run"),
53 OPT_BOOLEAN('f', "force", &force, "force"),
54 OPT_BOOLEAN('d', NULL, &remove_directories,
55 "remove whole directories"),
builtin/mv.c
+1 -1
@@ -55,7 +55,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
55 int i, newfd;
56 int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
57 struct option builtin_mv_options[] = {
58 - OPT__DRY_RUN(&show_only),
58 + OPT__DRY_RUN(&show_only, "dry run"),
59 OPT_BOOLEAN('f', "force", &force, "force move/rename even if target exists"),
60 OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
61 OPT_END(),
builtin/notes.c
+1 -2
@@ -804,8 +804,7 @@ static int prune(int argc, const char **argv, const char *prefix)
804 struct notes_tree *t;
805 int show_only = 0, verbose = 0;
806 struct option options[] = {
807 - OPT_BOOLEAN('n', "dry-run", &show_only,
808 - "do not remove, show only"),
807 + OPT__DRY_RUN(&show_only, "do not remove, show only"),
808 OPT__VERBOSE(&verbose, "report pruned notes"),
809 OPT_END()
810 };
builtin/prune.c
+1 -2
@@ -125,8 +125,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
125 {
126 struct rev_info revs;
127 const struct option options[] = {
128 - OPT_BOOLEAN('n', "dry-run", &show_only,
129 - "do not remove, show only"),
128 + OPT__DRY_RUN(&show_only, "do not remove, show only"),
129 OPT__VERBOSE(&verbose, "report pruned objects"),
130 OPT_DATE(0, "expire", &expire,
131 "expire objects older than <time>"),
builtin/remote.c
+1 -1
@@ -1200,7 +1200,7 @@ static int prune(int argc, const char **argv)
1200 {
1201 int dry_run = 0, result = 0;
1202 struct option options[] = {
1203 - OPT__DRY_RUN(&dry_run),
1203 + OPT__DRY_RUN(&dry_run, "dry run"),
1204 OPT_END()
1205 };
1206
builtin/rm.c
+1 -1
@@ -139,7 +139,7 @@ static int show_only = 0, force = 0, index_only = 0, recursive = 0, quiet = 0;
139 static int ignore_unmatch = 0;
140
141 static struct option builtin_rm_options[] = {
142 - OPT__DRY_RUN(&show_only),
142 + OPT__DRY_RUN(&show_only, "dry run"),
143 OPT__QUIET(&quiet),
144 OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"),
145 OPT_BOOLEAN('f', "force", &force, "override the up-to-date check"),
parse-options.h
+1 -1
@@ -205,7 +205,7 @@ extern int parse_opt_tertiary(const struct option *, const char *, int);
205 PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }, \
206 { OPTION_CALLBACK, 'q', "quiet", (var), NULL, "be more quiet", \
207 PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }
208 -#define OPT__DRY_RUN(var) OPT_BOOLEAN('n', "dry-run", (var), "dry run")
208 +#define OPT__DRY_RUN(var, h) OPT_BOOLEAN('n', "dry-run", (var), (h))
209 #define OPT__ABBREV(var) \
210 { OPTION_CALLBACK, 0, "abbrev", (var), "n", \
211 "use <n> digits to display SHA-1s", \
test-parse-options.c
+1 -1
@@ -67,7 +67,7 @@ int main(int argc, const char **argv)
67 OPT_GROUP("Standard options"),
68 OPT__ABBREV(&abbrev),
69 OPT__VERBOSE(&verbose, "be verbose"),
70 - OPT__DRY_RUN(&dry_run),
70 + OPT__DRY_RUN(&dry_run, "dry run"),
71 OPT__QUIET(&quiet),
72 OPT_END(),
73 };