From: Florian Ragwitz <rafl@debian.org>
To: git@vger.kernel.org
Cc: Florian Ragwitz <rafl@debian.org>
Subject: [PATCH] Add a --signoff option to cherry-pick/revert.
Date: Mon, 5 May 2008 02:25:09 +0200 [thread overview]
Message-ID: <1209947109-13910-1-git-send-email-rafl@debian.org> (raw)
Also modify documentation and tests to reflect this change.
Signed-off-by: Florian Ragwitz <rafl@debian.org>
---
Documentation/git-cherry-pick.txt | 3 +++
Documentation/git-revert.txt | 3 +++
builtin-revert.c | 25 ++++++++++++++++++++-----
t/t3501-revert-cherry-pick.sh | 19 +++++++++++++++++++
4 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index f0beb41..ec8bd50 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -39,6 +39,9 @@ OPTIONS
development branch), adding this information can be
useful.
+-s|--signoff::
+ Add Signed-off-by line at the end of the commit message.
+
-r::
It used to be that the command defaulted to do `-x`
described above, and `-r` was to disable it. Now the
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 93e20f7..a35a376 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -27,6 +27,9 @@ OPTIONS
message prior to committing the revert. This is the default if
you run the command from a terminal.
+-s|--signoff::
+ Add Signed-off-by line at the end of the commit message.
+
-m parent-number|--mainline parent-number::
Usually you cannot revert a merge because you do not know which
side of the merge should be considered the mainline. This
diff --git a/builtin-revert.c b/builtin-revert.c
index 607a2f0..ccf591c 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:"),
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
OPT_END(),
};
@@ -404,10 +405,24 @@ static int revert_or_cherry_pick(int argc, const char **argv)
*/
if (!no_commit) {
- if (edit)
- return execl_git_cmd("commit", "-n", NULL);
- else
- return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
+ const char *args[6];
+ int i = 0;
+
+ args[i++] = "commit";
+ args[i++] = "-n";
+
+ if (!edit) {
+ args[i++] = "-F";
+ args[i++] = defmsg;
+ }
+
+ if (signoff) {
+ args[i++] = "-s";
+ }
+
+ args[i] = NULL;
+
+ return execv_git_cmd(args);
}
free(reencoded_message);
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 6da2128..2f74f74 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -50,6 +50,25 @@ test_expect_success 'cherry-pick after renaming branch' '
'
+test_expect_success 'cherry-pick signoff' '
+
+ git checkout rename2 &&
+ git cherry-pick -s added &&
+ test -f opos &&
+ git cat-file commit HEAD | sed "1,/^$/d" > output &&
+ grep Signed-off-by output
+'
+
+test_expect_success 'revert signoff' '
+
+ git checkout rename1 &&
+ git revert -s added &&
+ test -f spoo &&
+ git cat-file commit HEAD | sed "1,/^$/d" > output &&
+ grep Signed-off-by output
+
+'
+
test_expect_success 'revert after renaming branch' '
git checkout rename1 &&
--
1.5.5.1
reply other threads:[~2008-05-05 0:55 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=1209947109-13910-1-git-send-email-rafl@debian.org \
--to=rafl@debian.org \
--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;
as well as URLs for NNTP newsgroup(s).