From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Dan McGee <dpmcgee@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Allow cherry-pick (and revert) to add signoff line
Date: Sun, 20 Apr 2008 20:28:57 +0200 [thread overview]
Message-ID: <20080420182857.GA15277@atjola.homenet> (raw)
In-Reply-To: <1208714585-4053-1-git-send-email-dpmcgee@gmail.com>
On 2008.04.20 13:03:05 -0500, Dan McGee wrote:
> I often find myself pulling patches off of other peoples trees using
> cherry-pick, and following it with an immediate 'git commit --amend -s'
> command. Eliminate the need for a double commit by allowing signoff on a
> cherry-pick or revert.
>
> Signed-off-by: Dan McGee <dpmcgee@gmail.com>
> ---
>
> This is something I have done in my workflow for a long time, and it seems
> like a weird omission to me. Signoffs can be done on git-am without having
> a second commit, and I often have a workflow where I am picking patches from
> other users' topic branches and have reviewed the patch and would like to
> signoff when I pull it into my tree.
>
> I'm not particularly happy about the 4 case if statement at the end, so I'd
> be happy to clean that up if anyone has suggestions.
>
> builtin-revert.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/builtin-revert.c b/builtin-revert.c
> index 607a2f0..433d0dd 100644
> --- a/builtin-revert.c
> +++ b/builtin-revert.c
> @@ -33,7 +33,7 @@ static const char * const cherry_pick_usage[] = {
> NULL
> };
>
> -static int edit, no_replay, no_commit, mainline;
> +static int edit, no_replay, no_commit, mainline, signoff;
> static enum { REVERT, CHERRY_PICK } action;
> static struct commit *commit;
>
> @@ -53,6 +53,7 @@ static void parse_args(int argc, const char **argv)
> OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
> OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"),
> OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
> + OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by: header"),
> OPT_INTEGER('m', "mainline", &mainline, "parent number"),
> OPT_END(),
> };
> @@ -404,10 +405,14 @@ static int revert_or_cherry_pick(int argc, const char **argv)
> */
>
> if (!no_commit) {
> - if (edit)
> + if (edit && !signoff)
> return execl_git_cmd("commit", "-n", NULL);
> - else
> + else if (edit)
> + return execl_git_cmd("commit", "-n", "-s", NULL);
> + else if (!signoff)
> return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
> + else
> + return execl_git_cmd("commit", "-n", "-s", "-F", defmsg, NULL);
maybe like this?
if (!no_commit) {
char **argv[6] = { "commit", "-n" };
int argc = 2;
if (signoff)
argv[argc++] = "-s";
if (!edit) {
argv[argc++] = "-F";
argv[argc++] = defmsg;
}
argv[argc] = NULL;
execv_git_command(argv);
}
It duplicates what execl_git_cmd does, but other places already work
similar (eg. cmd_describe, when --contains is given), and IMHO it's
nicer than the if-else chain.
Björn
next prev parent reply other threads:[~2008-04-20 18:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-20 18:03 [PATCH] Allow cherry-pick (and revert) to add signoff line Dan McGee
2008-04-20 18:28 ` Björn Steinbrink [this message]
2008-04-23 5:08 ` Junio C Hamano
2008-04-26 14:46 ` Dan McGee
2008-04-26 20:14 ` [PATCH resubmit] " Dan McGee
2008-04-26 21:07 ` Junio C Hamano
2008-04-27 0:43 ` [PATCH] Remove 'header' from --signoff option description Dan McGee
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=20080420182857.GA15277@atjola.homenet \
--to=b.steinbrink@gmx.de \
--cc=dpmcgee@gmail.com \
--cc=git@vger.kernel.org \
/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