Allow cherry-pick (and revert) to add signoff line
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Dan McGee committed
Apr 26, 2008 at 15:14 UTC
cfd9c27708509457f572373bd8f4eb25dd4a6715
3 files changed
+23
-7
Documentation/git-cherry-pick.txt
+4
-1
@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit
7
8
SYNOPSIS
9
--------
10
-'git-cherry-pick' [--edit] [-n] [-m parent-number] [-x] <commit>
10
+'git-cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] <commit>
11
12
DESCRIPTION
13
-----------
@@ -64,6 +64,9 @@ OPTIONS
64
This is useful when cherry-picking more than one commits'
65
effect to your working tree in a row.
66
67
+-s|--signoff::
68
+ Add Signed-off-by line at the end of the commit message.
69
+
70
71
Author
72
------
Documentation/git-revert.txt
+4
-1
@@ -7,7 +7,7 @@ git-revert - Revert an existing commit
7
8
SYNOPSIS
9
--------
10
-'git-revert' [--edit | --no-edit] [-n] [-m parent-number] <commit>
10
+'git-revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>
11
12
DESCRIPTION
13
-----------
@@ -51,6 +51,9 @@ OPTIONS
51
This is useful when reverting more than one commits'
52
effect to your working tree in a row.
53
54
+-s|--signoff::
55
+ Add Signed-off-by line at the end of the commit message.
56
+
57
58
Author
59
------
builtin-revert.c
+15
-5
@@ -33,7 +33,7 @@ static const char * const cherry_pick_usage[] = {
33
NULL
34
};
35
36
-static int edit, no_replay, no_commit, mainline;
36
+static int edit, no_replay, no_commit, mainline, signoff;
37
static enum { REVERT, CHERRY_PICK } action;
38
static struct commit *commit;
39
@@ -53,6 +53,7 @@ static void parse_args(int argc, const char **argv)
53
OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
54
OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"),
55
OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
56
+ OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
57
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
58
OPT_END(),
59
};
@@ -404,10 +405,19 @@ static int revert_or_cherry_pick(int argc, const char **argv)
405
*/
406
407
if (!no_commit) {
407
- if (edit)
408
- return execl_git_cmd("commit", "-n", NULL);
409
- else
410
- return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
408
+ /* 6 is max possible length of our args array including NULL */
409
+ const char *args[6];
410
+ int i = 0;
411
+ args[i++] = "commit";
412
+ args[i++] = "-n";
413
+ if (signoff)
414
+ args[i++] = "-s";
415
+ if (!edit) {
416
+ args[i++] = "-F";
417
+ args[i++] = defmsg;
418
+ }
419
+ args[i] = NULL;
420
+ return execv_git_cmd(args);
421
}
422
free(reencoded_message);
423