summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d52ee6e)
raw | patch | inline | side by side (parent: d52ee6e)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Mon, 8 Nov 2010 18:01:54 +0000 (19:01 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Nov 2010 18:04:43 +0000 (10:04 -0800) |
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>
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>
13 files changed:
diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt
index 248a66dffb04a24b0c870ca60030b384ab72a862..f6a4a361bd56e1cc0f4645e09898e6852bfb8a8b 100644 (file)
`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 9625ceeb5bb6c6e7c8c37ea505ab7d8a9511ef9d..71f9b04fef829ad3725ca50902bd6935dc3cda36 100644 (file)
--- a/builtin/add.c
+++ b/builtin/add.c
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 10788fc1dd134aa9c9f6ef81fbc3b681b23718b0..e388edc413c1920557d51aa04c1dd1e9dbdfa2a5 100644 (file)
--- a/builtin/branch.c
+++ b/builtin/branch.c
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",
index 7ba09130cc2d1e9e3043ab867823b50e6227e2de..91fb9bfc624e3dc6556707e4a275c1d5543b5ce6 100644 (file)
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
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 a952477d19608a4324b5a141c7740d9ab5ed16c2..f275570cbda0fe6fee85037ed0ec0c2500eafa7c 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
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 449d2a3237637f07258ca9a5ee5423790d587a82..9146bf3c1c70d306aab59812ea12f3a4d5fa7293 100644 (file)
--- a/builtin/clean.c
+++ b/builtin/clean.c
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 d35f000c034964ed600b1d8d45e2ef9260abcfb6..6aaf8e96b4b4415a909d244e200984fb586d574b 100644 (file)
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
"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 8677bd2e40d98de1ce6cf727119176dc26357fed..93e8995d9e704faa041f97f92ba72dabe7839d81 100644 (file)
--- a/builtin/mv.c
+++ b/builtin/mv.c
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 2ab070fa09dd1dfb253ae48d867d4c06699e40c3..c85cbf5a4758c8c08ef43dd65d9f85669c0063f2 100644 (file)
--- a/builtin/notes.c
+++ b/builtin/notes.c
{ 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()
};
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 <command> (implies "
diff --git a/builtin/rm.c b/builtin/rm.c
index 49461b60c75d214a72cb1882c0d2f0c265e59ab5..9a5990513ab78a7c32cffdbe8b36b20c2509627e 100644 (file)
--- a/builtin/rm.c
+++ b/builtin/rm.c
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 d311491e492787ae50aa172f51629abea53eec19..d1d7d8701db23dfa0db0fb3457f57826b7012d41 100644 (file)
--- a/builtin/tag.c
+++ b/builtin/tag.c
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"),
{
index 2b3fddcc69087d856b6a9c9f4383c5577a759c77..b90dce6358153b274a1e26afde9cc89aad473d14 100644 (file)
{
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 3dd3a94f22b23ffe9127aba3a90fe66c3ebc45f1..ae8647d8932512a49f5a7f9bc9decee34964976b 100644 (file)
--- a/parse-options.h
+++ b/parse-options.h
{ 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 <n> digits to display SHA-1s", \