[PATCH v4 21/45] cherry-pick: add --action-name option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So it can be used by other tools (e.g. git rebase), and the right action
is passed to the hooks and notes rewrite stuff.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 builtin/revert.c           |  2 ++
 builtin/sequencer.c        | 17 ++++++++++++++---
 builtin/sequencer.h        |  2 ++
 git-rebase--interactive.sh |  4 ++--
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index d3d5600..6066ad2 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -122,6 +122,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
 		OPT_END(),
 		OPT_END(),
 		OPT_END(),
+		OPT_END(),
 	};
 
 	if (opts->action == REPLAY_PICK) {
@@ -132,6 +133,7 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
 			OPT_BOOLEAN(0, "allow-empty-message", &opts->allow_empty_message, N_("allow commits with empty messages")),
 			OPT_BOOLEAN(0, "keep-redundant-commits", &opts->keep_redundant_commits, N_("keep redundant, empty commits")),
 			OPT_BOOLEAN(0, "skip-empty", &opts->skip_empty, N_("skip empty commits")),
+			OPT_STRING(0, "action-name", &opts->action_name, N_("name"), N_("action name")),
 			OPT_END(),
 		};
 		if (parse_options_concat(options, ARRAY_SIZE(options), cp_extra))
diff --git a/builtin/sequencer.c b/builtin/sequencer.c
index fe96f1f..a419387 100644
--- a/builtin/sequencer.c
+++ b/builtin/sequencer.c
@@ -23,11 +23,18 @@ static struct rewritten rewritten;
 
 static void finish(struct replay_opts *opts)
 {
+	const char *name;
+
 	if (opts->action != REPLAY_PICK)
 		return;
 
-	run_rewrite_hook(&rewritten, "cherry-pick");
-	copy_rewrite_notes(&rewritten, "cherry-pick");
+	name = opts->action_name ? opts->action_name : "cherry-pick";
+
+	if (!*name)
+		return;
+
+	run_rewrite_hook(&rewritten, name);
+	copy_rewrite_notes(&rewritten, name);
 }
 
 static void remove_sequencer_state(void)
@@ -744,7 +751,9 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
 	else if (!strcmp(key, "options.strategy-option")) {
 		ALLOC_GROW(opts->xopts, opts->xopts_nr + 1, opts->xopts_alloc);
 		opts->xopts[opts->xopts_nr++] = xstrdup(value);
-	} else
+	} else if (!strcmp(key, "options.action-name"))
+		git_config_string(&opts->action_name, key, value);
+	else
 		return error(_("Invalid key: %s"), key);
 
 	if (!error_flag)
@@ -921,6 +930,8 @@ static void save_opts(struct replay_opts *opts)
 							"options.strategy-option",
 							opts->xopts[i], "^$", 0);
 	}
+	if (opts->action_name)
+		git_config_set_in_file(opts_file, "options.action-name", opts->action_name);
 }
 
 static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
diff --git a/builtin/sequencer.h b/builtin/sequencer.h
index 63ba274..c69eeff 100644
--- a/builtin/sequencer.h
+++ b/builtin/sequencer.h
@@ -46,6 +46,8 @@ struct replay_opts {
 
 	/* Only used by REPLAY_NONE */
 	struct rev_info *revs;
+
+	const char *action_name;
 };
 
 int sequencer_pick_revisions(struct replay_opts *opts);
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index f953d8d..9f42a71 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -239,7 +239,7 @@ pick_one () {
 
 	test -d "$rewritten" &&
 		pick_one_preserving_merges "$@" && return
-	output git cherry-pick $empty_args $ff "$@"
+	output git cherry-pick --action-name '' $empty_args $ff "$@"
 }
 
 pick_one_preserving_merges () {
@@ -350,7 +350,7 @@ pick_one_preserving_merges () {
 			echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
 			;;
 		*)
-			output git cherry-pick "$@" ||
+			output git cherry-pick --action-name '' "$@" ||
 				die_with_patch $sha1 "Could not pick $sha1"
 			;;
 		esac
-- 
1.8.3.698.g079b096

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]