Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Do not ignore merge options in interactive rebase

From: Arnaud Fontaine <hidden>
Date: 2016-06-15 22:57:58

Hello,

Sorry for the late reply.

Junio C Hamano [off-list ref] writes:
quoted hunk
Junio C Hamano [off-list ref] writes:
quoted
You should use ${var:+if_set_to_nonempty_use_this} here.
...
So munging it manually with sloppy "sed" script is simply wrong.
Perhaps something like this on top of your patch squashed in?

The  eval magic  lets  the  shell to  split  $strategy_opts back  into
individual words (e.g. "--subtree=My Project" is a single word), strip
the leading "--",  and then uses "rev-parse --sq-quote"  again to turn
them into "-X 'subtree=My Project'" (two words), which can be inserted
into a string later to be eval'ed.

 git-rebase--interactive.sh | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index e558397..ae2da7a 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -83,8 +83,13 @@ rewritten_pending="$state_dir"/rewritten-pending
 strategy_args=
 if test -n "$do_merge"
 then
-	strategy_args="${strategy+--strategy=$strategy}
- $(echo $strategy_opts | sed "s/'--\([^']*\)'/-X\1/g")"
+	strategy_args=${strategy:+--strategy=$strategy}
+	eval '
+		for strategy_opt in '"$strategy_opts"'
+		do
+			strategy_args="$strategy_args -X$(git rev-parse --sq-quote "${strategy_opt#--}")"
+		done
+	'
 fi
 
 GIT_CHERRY_PICK_HELP="$resolvemsg"
@@ -246,7 +251,7 @@ pick_one () {
 
 	test -d "$rewritten" &&
 		pick_one_preserving_merges "$@" && return
-	output git cherry-pick $strategy_args $empty_args $ff "$@"
+	output eval git cherry-pick "$strategy_args" $empty_args $ff "$@"
 }
 
 pick_one_preserving_merges () {
@@ -347,9 +352,8 @@ pick_one_preserving_merges () {
 			msg_content="$(commit_message $sha1)"
 			# No point in merging the first parent, that's HEAD
 			new_parents=${new_parents# $first_parent}
-			if ! do_with_author output \
-				git merge --no-ff $strategy_args -m \
-					"$msg_content" $new_parents
+			if ! do_with_author output eval \
+			'git merge --no-ff $strategy_args -m "$msg_content" $new_parents'
 			then
 				printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
 				die_with_patch $sha1 "Error redoing merge $sha1"
@@ -357,7 +361,7 @@ pick_one_preserving_merges () {
 			echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
 			;;
 		*)
-			output git cherry-pick $strategy_args "$@" ||
+			output eval git cherry-pick "$strategy_args" "$@" ||
 				die_with_patch $sha1 "Could not pick $sha1"
 			;;
 		esac
Indeed, this is much  better this way. Thank you very  much! I have just
squashed your patch into mine and ran successfully t3404 and t3421 tests
after rebasing my branch on top of current master.

I will send  the final patch in  another email. Of course,  feel free to
take authorship of the patch or add yourself as Signed-off-by.

Cheers,
-- 
Arnaud Fontaine
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help