@matheusbsbs / matheus-bagliano / commits / 76946b76fe
Fork 0

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 <rene.scharfe@lstfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 8, 2010 at 19:01 UTC 76946b76fe3d26507d61cae97aa0676fad24ed92
13 files changed +16 -15
Documentation/technical/api-parse-options.txt
+3
@@ -121,6 +121,9 @@ There are some macros to easily define options:
121 `OPT__DRY_RUN(&int_var, description)`::
122 Add `-n, \--dry-run`.
123
124 +`OPT__FORCE(&int_var, description)`::
125 + Add `-f, \--force`.
126 +
127 `OPT__QUIET(&int_var, description)`::
128 Add `-q, \--quiet`.
129
builtin/add.c
+1 -1
@@ -319,7 +319,7 @@ static struct option builtin_add_options[] = {
319 OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
320 OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
321 OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"),
322 - OPT_BOOLEAN('f', "force", &ignored_too, "allow adding otherwise ignored files"),
322 + OPT__FORCE(&ignored_too, "allow adding otherwise ignored files"),
323 OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
324 OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, "record only the fact that the path will be added later"),
325 OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
builtin/branch.c
+1 -1
@@ -651,7 +651,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
651 OPT_BIT('m', NULL, &rename, "move/rename a branch and its reflog", 1),
652 OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
653 OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
654 - OPT_BOOLEAN('f', "force", &force_create, "force creation (when already exists)"),
654 + OPT__FORCE(&force_create, "force creation (when already exists)"),
655 {
656 OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
657 "commit", "print only not merged branches",
builtin/checkout-index.c
+1 -2
@@ -217,8 +217,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
217 struct option builtin_checkout_index_options[] = {
218 OPT_BOOLEAN('a', "all", &all,
219 "checks out all files in the index"),
220 - OPT_BOOLEAN('f', "force", &force,
221 - "forces overwrite of existing files"),
220 + OPT__FORCE(&force, "forces overwrite of existing files"),
221 OPT__QUIET(&quiet, "be quiet"),
222 OPT_BOOLEAN('n', "no-create", &not_new,
223 "don't checkout new files"),
builtin/checkout.c
+1 -1
@@ -699,7 +699,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
699 2),
700 OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files",
701 3),
702 - OPT_BOOLEAN('f', "force", &opts.force, "force checkout (throw away local modifications)"),
702 + OPT__FORCE(&opts.force, "force checkout (throw away local modifications)"),
703 OPT_BOOLEAN('m', "merge", &opts.merge, "perform a 3-way merge with the new branch"),
704 OPT_STRING(0, "conflict", &conflict_style, "style",
705 "conflict style (merge or diff3)"),
builtin/clean.c
+1 -1
@@ -50,7 +50,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
50 struct option options[] = {
51 OPT__QUIET(&quiet, "be quiet"),
52 OPT__DRY_RUN(&show_only, "dry run"),
53 - OPT_BOOLEAN('f', "force", &force, "force"),
53 + OPT__FORCE(&force, "force"),
54 OPT_BOOLEAN('d', NULL, &remove_directories,
55 "remove whole directories"),
56 { OPTION_CALLBACK, 'e', "exclude", &exclude_list, "pattern",
builtin/fetch.c
+1 -2
@@ -43,8 +43,7 @@ static struct option builtin_fetch_options[] = {
43 "append to .git/FETCH_HEAD instead of overwriting"),
44 OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
45 "path to upload pack on remote end"),
46 - OPT_BOOLEAN('f', "force", &force,
47 - "force overwrite of local branch"),
46 + OPT__FORCE(&force, "force overwrite of local branch"),
47 OPT_BOOLEAN('m', "multiple", &multiple,
48 "fetch from multiple remotes"),
49 OPT_SET_INT('t', "tags", &tags,
builtin/mv.c
+1 -1
@@ -56,7 +56,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
56 int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
57 struct option builtin_mv_options[] = {
58 OPT__DRY_RUN(&show_only, "dry run"),
59 - OPT_BOOLEAN('f', "force", &force, "force move/rename even if target exists"),
59 + OPT__FORCE(&force, "force move/rename even if target exists"),
60 OPT_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
61 OPT_END(),
62 };
builtin/notes.c
+2 -2
@@ -538,7 +538,7 @@ static int add(int argc, const char **argv, const char *prefix)
538 { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
539 "reuse specified note object", PARSE_OPT_NONEG,
540 parse_reuse_arg},
541 - OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
541 + OPT__FORCE(&force, "replace existing notes"),
542 OPT_END()
543 };
544
@@ -594,7 +594,7 @@ static int copy(int argc, const char **argv, const char *prefix)
594 struct notes_tree *t;
595 const char *rewrite_cmd = NULL;
596 struct option options[] = {
597 - OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
597 + OPT__FORCE(&force, "replace existing notes"),
598 OPT_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"),
599 OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
600 "load rewriting config for <command> (implies "
builtin/rm.c
+1 -1
@@ -142,7 +142,7 @@ static struct option builtin_rm_options[] = {
142 OPT__DRY_RUN(&show_only, "dry run"),
143 OPT__QUIET(&quiet, "be 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"),
145 + OPT__FORCE(&force, "override the up-to-date check"),
146 OPT_BOOLEAN('r', NULL, &recursive, "allow recursive removal"),
147 OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
148 "exit with a zero status even if nothing matched"),
builtin/tag.c
+1 -1
@@ -390,7 +390,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
390 OPT_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
391 OPT_STRING('u', NULL, &keyid, "key-id",
392 "use another key to sign the tag"),
393 - OPT_BOOLEAN('f', "force", &force, "replace the tag if exists"),
393 + OPT__FORCE(&force, "replace the tag if exists"),
394
395 OPT_GROUP("Tag listing options"),
396 {
builtin/update-server-info.c
+1 -2
@@ -11,8 +11,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)
11 {
12 int force = 0;
13 struct option options[] = {
14 - OPT_BOOLEAN('f', "force", &force,
15 - "update the info files from scratch"),
14 + OPT__FORCE(&force, "update the info files from scratch"),
15 OPT_END()
16 };
17
parse-options.h
+1
@@ -206,6 +206,7 @@ extern int parse_opt_tertiary(const struct option *, const char *, int);
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, h) OPT_BOOLEAN('n', "dry-run", (var), (h))
209 +#define OPT__FORCE(var, h) OPT_BOOLEAN('f', "force", (var), (h))
210 #define OPT__ABBREV(var) \
211 { OPTION_CALLBACK, 0, "abbrev", (var), "n", \
212 "use <n> digits to display SHA-1s", \