[RFC/PATCH 15/18] revert: add NONE action and make parse_args() manage it
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin/revert.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 7513a00..fee2e38 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -40,7 +40,7 @@ static const char * const cherry_pick_usage[] = {
};
struct args_info {
- enum { REVERT, CHERRY_PICK } action;
+ enum { NONE = 0, REVERT, CHERRY_PICK } action;
int edit;
int no_replay;
int no_commit;
@@ -90,6 +90,17 @@ static void parse_args(int argc, const char **argv, struct args_info *info)
OPT_END(),
};
+ if (info->action == NONE) {
+ if (argc < 1)
+ die("no action argument");
+ if (!strcasecmp(argv[0], "p") || !strcasecmp(argv[0], "pick"))
+ info->action = CHERRY_PICK;
+ else if (!strcasecmp(argv[0], "revert"))
+ info->action = REVERT;
+ else
+ die("unknown action argument: %s", argv[0]);
+ }
+
info->me = info->action == REVERT ? "revert" : "cherry-pick";
setenv(GIT_REFLOG_ACTION, info->me, 0);
--
1.7.3.2.504.g59d466