зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
d52ee6e613
Коммит
76946b76fe
|
@ -121,6 +121,9 @@ There are some macros to easily define options:
|
||||||
`OPT__DRY_RUN(&int_var, description)`::
|
`OPT__DRY_RUN(&int_var, description)`::
|
||||||
Add `-n, \--dry-run`.
|
Add `-n, \--dry-run`.
|
||||||
|
|
||||||
|
`OPT__FORCE(&int_var, description)`::
|
||||||
|
Add `-f, \--force`.
|
||||||
|
|
||||||
`OPT__QUIET(&int_var, description)`::
|
`OPT__QUIET(&int_var, description)`::
|
||||||
Add `-q, \--quiet`.
|
Add `-q, \--quiet`.
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,7 @@ static struct option builtin_add_options[] = {
|
||||||
OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
|
OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
|
||||||
OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
|
OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
|
||||||
OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"),
|
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('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('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"),
|
OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
|
||||||
|
|
|
@ -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 and its reflog", 1),
|
||||||
OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
|
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('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,
|
OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
|
||||||
"commit", "print only not merged branches",
|
"commit", "print only not merged branches",
|
||||||
|
|
|
@ -217,8 +217,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
|
||||||
struct option builtin_checkout_index_options[] = {
|
struct option builtin_checkout_index_options[] = {
|
||||||
OPT_BOOLEAN('a', "all", &all,
|
OPT_BOOLEAN('a', "all", &all,
|
||||||
"checks out all files in the index"),
|
"checks out all files in the index"),
|
||||||
OPT_BOOLEAN('f', "force", &force,
|
OPT__FORCE(&force, "forces overwrite of existing files"),
|
||||||
"forces overwrite of existing files"),
|
|
||||||
OPT__QUIET(&quiet, "be quiet"),
|
OPT__QUIET(&quiet, "be quiet"),
|
||||||
OPT_BOOLEAN('n', "no-create", ¬_new,
|
OPT_BOOLEAN('n', "no-create", ¬_new,
|
||||||
"don't checkout new files"),
|
"don't checkout new files"),
|
||||||
|
|
|
@ -699,7 +699,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
|
||||||
2),
|
2),
|
||||||
OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files",
|
OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files",
|
||||||
3),
|
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_BOOLEAN('m', "merge", &opts.merge, "perform a 3-way merge with the new branch"),
|
||||||
OPT_STRING(0, "conflict", &conflict_style, "style",
|
OPT_STRING(0, "conflict", &conflict_style, "style",
|
||||||
"conflict style (merge or diff3)"),
|
"conflict style (merge or diff3)"),
|
||||||
|
|
|
@ -50,7 +50,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT__QUIET(&quiet, "be quiet"),
|
OPT__QUIET(&quiet, "be quiet"),
|
||||||
OPT__DRY_RUN(&show_only, "dry run"),
|
OPT__DRY_RUN(&show_only, "dry run"),
|
||||||
OPT_BOOLEAN('f', "force", &force, "force"),
|
OPT__FORCE(&force, "force"),
|
||||||
OPT_BOOLEAN('d', NULL, &remove_directories,
|
OPT_BOOLEAN('d', NULL, &remove_directories,
|
||||||
"remove whole directories"),
|
"remove whole directories"),
|
||||||
{ OPTION_CALLBACK, 'e', "exclude", &exclude_list, "pattern",
|
{ OPTION_CALLBACK, 'e', "exclude", &exclude_list, "pattern",
|
||||||
|
|
|
@ -43,8 +43,7 @@ static struct option builtin_fetch_options[] = {
|
||||||
"append to .git/FETCH_HEAD instead of overwriting"),
|
"append to .git/FETCH_HEAD instead of overwriting"),
|
||||||
OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
|
OPT_STRING(0, "upload-pack", &upload_pack, "PATH",
|
||||||
"path to upload pack on remote end"),
|
"path to upload pack on remote end"),
|
||||||
OPT_BOOLEAN('f', "force", &force,
|
OPT__FORCE(&force, "force overwrite of local branch"),
|
||||||
"force overwrite of local branch"),
|
|
||||||
OPT_BOOLEAN('m', "multiple", &multiple,
|
OPT_BOOLEAN('m', "multiple", &multiple,
|
||||||
"fetch from multiple remotes"),
|
"fetch from multiple remotes"),
|
||||||
OPT_SET_INT('t', "tags", &tags,
|
OPT_SET_INT('t', "tags", &tags,
|
||||||
|
|
|
@ -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;
|
int verbose = 0, show_only = 0, force = 0, ignore_errors = 0;
|
||||||
struct option builtin_mv_options[] = {
|
struct option builtin_mv_options[] = {
|
||||||
OPT__DRY_RUN(&show_only, "dry run"),
|
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_BOOLEAN('k', NULL, &ignore_errors, "skip move/rename errors"),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -538,7 +538,7 @@ static int add(int argc, const char **argv, const char *prefix)
|
||||||
{ OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
|
{ OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT",
|
||||||
"reuse specified note object", PARSE_OPT_NONEG,
|
"reuse specified note object", PARSE_OPT_NONEG,
|
||||||
parse_reuse_arg},
|
parse_reuse_arg},
|
||||||
OPT_BOOLEAN('f', "force", &force, "replace existing notes"),
|
OPT__FORCE(&force, "replace existing notes"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -594,7 +594,7 @@ static int copy(int argc, const char **argv, const char *prefix)
|
||||||
struct notes_tree *t;
|
struct notes_tree *t;
|
||||||
const char *rewrite_cmd = NULL;
|
const char *rewrite_cmd = NULL;
|
||||||
struct option options[] = {
|
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_BOOLEAN(0, "stdin", &from_stdin, "read objects from stdin"),
|
||||||
OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
|
OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command",
|
||||||
"load rewriting config for <command> (implies "
|
"load rewriting config for <command> (implies "
|
||||||
|
|
|
@ -142,7 +142,7 @@ static struct option builtin_rm_options[] = {
|
||||||
OPT__DRY_RUN(&show_only, "dry run"),
|
OPT__DRY_RUN(&show_only, "dry run"),
|
||||||
OPT__QUIET(&quiet, "be quiet"),
|
OPT__QUIET(&quiet, "be quiet"),
|
||||||
OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"),
|
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('r', NULL, &recursive, "allow recursive removal"),
|
||||||
OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
|
OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
|
||||||
"exit with a zero status even if nothing matched"),
|
"exit with a zero status even if nothing matched"),
|
||||||
|
|
|
@ -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_BOOLEAN('s', NULL, &sign, "annotated and GPG-signed tag"),
|
||||||
OPT_STRING('u', NULL, &keyid, "key-id",
|
OPT_STRING('u', NULL, &keyid, "key-id",
|
||||||
"use another key to sign the tag"),
|
"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"),
|
OPT_GROUP("Tag listing options"),
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,8 +11,7 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int force = 0;
|
int force = 0;
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
OPT_BOOLEAN('f', "force", &force,
|
OPT__FORCE(&force, "update the info files from scratch"),
|
||||||
"update the info files from scratch"),
|
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,7 @@ extern int parse_opt_tertiary(const struct option *, const char *, int);
|
||||||
{ OPTION_CALLBACK, 'q', "quiet", (var), NULL, "be more quiet", \
|
{ OPTION_CALLBACK, 'q', "quiet", (var), NULL, "be more quiet", \
|
||||||
PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }
|
PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }
|
||||||
#define OPT__DRY_RUN(var, h) OPT_BOOLEAN('n', "dry-run", (var), (h))
|
#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) \
|
#define OPT__ABBREV(var) \
|
||||||
{ OPTION_CALLBACK, 0, "abbrev", (var), "n", \
|
{ OPTION_CALLBACK, 0, "abbrev", (var), "n", \
|
||||||
"use <n> digits to display SHA-1s", \
|
"use <n> digits to display SHA-1s", \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче