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

[PATCH v2 1/3] revert.c: Allow to specify -x via git-config

From
Guido Günther <agx@sigxcpu.org>
Date
Feb 18, 2014, 21:27 UTC
Message-ID
<85b9fa68b1a5542817489ddbe186cbb7600599b0.1392758057.git.agx@sigxcpu.org>
In-Reply-To
<cover.1392758057.git.agx@sigxcpu.org>
Without this when maintaining stable branches it's easy to forget to use
-x to track where a patch was cherry-picked from.
---
 Documentation/config.txt          |  4 ++++
 Documentation/git-cherry-pick.txt |  8 ++++++++
 builtin/revert.c                  | 14 +++++++++++++-
 3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5f4d793..a47d045 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -794,6 +794,10 @@ browser.<tool>.path::
 	browse HTML help (see '-w' option in linkgit:git-help[1]) or a
 	working repository in gitweb (see linkgit:git-instaweb[1]).
 
+cherrypick.recordOrigin::
+	When cherry picking patches record the sha1 of the original
+	commit in the commit message. Defaults to `false`.
+
 clean.requireForce::
 	A boolean to make git-clean do nothing unless given -f,
 	-i or -n.   Defaults to true.
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index c205d23..c0274bd 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -215,6 +215,14 @@ the working tree.
 spending extra time to avoid mistakes based on incorrectly matching
 context lines.
 
+CONFIGURATION
+-------------
+
+See linkgit:git-config[1] for core variables.
+
+cherrypick.recordOrigin::
+	Default for the `-x` option. Defaults to `false`.
+
 SEE ALSO
 --------
 linkgit:git-revert[1]
diff --git a/builtin/revert.c b/builtin/revert.c
index 87659c9..0c14af4 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -196,6 +196,18 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
 	return res;
 }
 
+static int git_cherry_pick_config(const char *var, const char *value, void *cb)
+{
+	struct replay_opts *opts = cb;
+
+	if (!strcmp(var, "cherrypick.recordorigin")) {
+		opts->record_origin = git_config_bool (var, value);
+		return 0;
+	} else {
+		return git_config(git_default_config, NULL);
+	}
+}
+
 int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
 {
 	struct replay_opts opts;
@@ -203,7 +215,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
 
 	memset(&opts, 0, sizeof(opts));
 	opts.action = REPLAY_PICK;
-	git_config(git_default_config, NULL);
+	git_config(git_cherry_pick_config, &opts);
 	parse_args(argc, argv, &opts);
 	res = sequencer_pick_revisions(&opts);
 	if (res < 0)
-- 
1.9.0.rc3
Previous: Guido GüntherNext: Junio C Hamano
Message 7 of 10 in “revert.c: Allow to specify -x via git-config”
  1. revert.c: Allow to specify -x via git-configGuido Günther, Feb 18, 2014
  2. John KeepingFeb 18, 2014
  3. Jonathan NiederFeb 18, 2014
  4. brian m. carlsonFeb 18, 2014
  5. Jonathan NiederFeb 18, 2014
  6. 0/3 Allow to configure cherry-pick's record originGuido Günther, Feb 18, 2014
  7. 1/3 revert.c: Allow to specify -x via git-configGuido Günther, Feb 18, 2014
  8. Junio C HamanoFeb 19, 2014
  9. 2/3 revert.c: Add --record-originGuido Günther, Feb 18, 2014
  10. 3/3 revert.c Allow to override cherrypick.recordOriginGuido Günther, Feb 18, 2014

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.