* [PATCH] Add a --signoff option to cherry-pick/revert.
@ 2008-05-05 0:25 Florian Ragwitz
0 siblings, 0 replies; only message in thread
From: Florian Ragwitz @ 2008-05-05 0:25 UTC (permalink / raw)
To: git; +Cc: Florian Ragwitz
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-05-05 0:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 0:25 [PATCH] Add a --signoff option to cherry-pick/revert Florian Ragwitz
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).