Add a --signoff option to cherry-pick/revert.
PATCH 1/1 Add a --signoff option to cherry-pick/revert.
Also modify documentation and tests to reflect this change.
Signed-off-by Florian Ragwitz <[email protected]>
--- 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(-)
Documentation/git-cherry-pick.txt +3 -0
@@ -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
Documentation/git-revert.txt +3 -0
@@ -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
builtin-revert.c +20 -5
@@ -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);
t/t3501-revert-cherry-pick.sh +19 -0
@@ -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 &&
Signature · 1 line
1.5.5.1