From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Stephan Beyer <s-beyer@gmx.net>,
Daniel Barkalow <barkalow@iabervon.org>,
Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH v2 3/4] sequencer: add "--reset-hard" option to "git sequencer--helper"
Date: Wed, 05 Aug 2009 22:52:59 +0200 [thread overview]
Message-ID: <20090805205301.3673.9806.chriscool@tuxfamily.org> (raw)
This new option uses the "reset_almost_hard()" function to perform
a reset.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-sequencer--helper.c | 65 ++++++++++++++++++++++++++++++++++++------
1 files changed, 55 insertions(+), 10 deletions(-)
diff --git a/builtin-sequencer--helper.c b/builtin-sequencer--helper.c
index a15139c..be030bc 100644
--- a/builtin-sequencer--helper.c
+++ b/builtin-sequencer--helper.c
@@ -18,6 +18,7 @@ static unsigned char head_sha1[20];
static const char * const git_sequencer_helper_usage[] = {
"git sequencer--helper --make-patch <commit>",
+ "git sequencer--helper --reset-hard <commit> <reflog-msg> <verbosity>",
NULL
};
@@ -185,27 +186,71 @@ static int set_verbosity(int verbose)
return 0;
}
+/* v should be "" or "t" or "\d" */
+static int parse_verbosity(const char *v)
+{
+ /* "" means verbosity = 1 */
+ if (!v[0])
+ return set_verbosity(1);
+
+ if (v[1])
+ return 1;
+
+ if (v[0] == 't')
+ return set_verbosity(2);
+
+ if (!isdigit(v[0]))
+ return 1;
+
+ return set_verbosity(v[0] - '0');
+}
+
int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
{
- char *commit = NULL;
- struct commit *c;
+ char *patch_commit = NULL;
+ char *reset_commit = NULL;
struct option options[] = {
- OPT_STRING(0, "make-patch", &commit, "commit",
+ OPT_STRING(0, "make-patch", &patch_commit, "commit",
"create a patch from commit"),
+ OPT_STRING(0, "reset-hard", &reset_commit, "commit",
+ "reset to commit"),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options,
git_sequencer_helper_usage, 0);
- if (!commit)
- usage_with_options(git_sequencer_helper_usage, options);
+ if (patch_commit) {
+ struct commit *c = get_commit(patch_commit);
+ if (!c)
+ return 1;
- c = get_commit(commit);
- if (!c)
- return 1;
+ make_patch(c);
- make_patch(c);
+ return 0;
+ }
- return 0;
+ if (reset_commit) {
+ unsigned char sha1[20];
+
+ if (argc != 2)
+ usage_with_options(git_sequencer_helper_usage,
+ options);
+
+ if (get_sha1(reset_commit, sha1)) {
+ error("Could not find '%s'", reset_commit);
+ return 1;
+ }
+
+ reflog = (char *)argv[0];
+
+ if (parse_verbosity(argv[1])) {
+ error("bad verbosity '%s'", argv[1]);
+ return 1;
+ }
+
+ return reset_almost_hard(sha1);
+ }
+
+ usage_with_options(git_sequencer_helper_usage, options);
}
--
1.6.4.133.g8a5c8
reply other threads:[~2009-08-05 21:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090805205301.3673.9806.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=barkalow@iabervon.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=s-beyer@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).