git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Allow cherry-pick (and revert) to add signoff line

From
Dan McGee <dpmcgee@gmail.com>
Date
Apr 26, 2008, 14:46 UTC
Message-ID
<1209221215-13476-1-git-send-email-dpmcgee@gmail.com>
In-Reply-To
<7vabjlupjc.fsf@gitster.siamese.dyndns.org>

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>
---

Resubmit using execv_git_cmd() directly. This reduces some code duplication and allows for any other commit options to be propagated forth in the future.

 builtin-revert.c |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin-revert.c b/builtin-revert.c
index 607a2f0..3f08cfe 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,19 @@ 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);
+		/* 6 is max possible length of our args array including NULL */
+		const char *args[6];
+		int i = 0;
+		args[i++] = "commit";
+		args[i++] = "-n";
+		if (signoff)
+			args[i++] = "-s";
+		if (!edit) {
+			args[i++] = "-F";
+			args[i++] = defmsg;
+		}
+		args[i] = NULL;
+		return execv_git_cmd(args);
 	}
 	free(reencoded_message);
 
-- 
1.5.5.1
Previous: Junio C HamanoNext: Dan McGee
Message 4 of 7 in “Allow cherry-pick (and revert) to add signoff line”
  1. Allow cherry-pick (and revert) to add signoff lineDan McGee, Apr 20, 2008
  2. Björn SteinbrinkApr 20, 2008
  3. Junio C HamanoApr 23, 2008
  4. Allow cherry-pick (and revert) to add signoff lineDan McGee, Apr 26, 2008
  5. Allow cherry-pick (and revert) to add signoff lineDan McGee, Apr 26, 2008
  6. Junio C HamanoApr 26, 2008
  7. Remove 'header' from --signoff option descriptionDan McGee, Apr 27, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.