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

Re: [PATCH/RFC] rebase -p: do not redo the merge, but cherry-pick first-parent changes

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 22, 2012, 23:38 UTC
Message-ID
<20120522233821.GA31667@burratino>
In-Reply-To
<4FBAA33D.1080703@kdbg.org>
Johannes Sixt wrote:
> - The 'git merge' invocation passed the commit message of the old merge
>   commit, but it still obeyed the merge.log option. If it was set, the log
>   ended up twice in the commit message.

Likewise for the "Conflicts:" paragraph, which should also be pretty simple to fix directly. I don't think that points directly to a fundamental flaw in the current implementation, but it does make it seem like no one has been using "rebase -p" for anything nontrivial. :)

[...]
Show 20 quoted lines
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -312,12 +312,14 @@ 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:+-s $strategy} -m \
> -					"$msg_content" $new_parents
> +			printf "%s\n" $new_parents >"$GIT_DIR"/MERGE_HEAD
> +			printf "%s\n" "$msg_content" >"$GIT_DIR"/MERGE_MSG
> +			if output git cherry-pick -m 1 -n "$sha1"
>  			then
> +				do_with_author output git commit --no-verify -F "$GIT_DIR"/MERGE_MSG ||
> +					die_with_patch $sha1 "Could not replay merge $sha1"
> +			else
> -				printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
> -				die_with_patch $sha1 "Error redoing merge $sha1"
> +				die_with_patch $sha1 "Could not pick merge $sha1"
>  			fi
Cute.  The approach looks very sensible to me.

Thanks, Jonathan

Previous: Johannes SixtNext: Martin von Zweigbergk
Message 4 of 16 in “rebase -p: do not redo the merge, but cherry-pick first-parent changes”
  1. rebase -p: do not redo the merge, but cherry-pick first-parent changesJohannes Sixt, May 21, 2012
  2. Junio C HamanoMay 22, 2012
  3. Johannes SixtMay 22, 2012
  4. Jonathan NiederMay 22, 2012
  5. Martin von ZweigbergkMay 23, 2012
  6. Junio C HamanoMay 23, 2012
  7. Martin von ZweigbergkMay 23, 2012
  8. Junio C HamanoMay 24, 2012
  9. Martin von ZweigbergkMay 24, 2012
  10. Junio C HamanoMay 24, 2012
  11. Johannes SixtMay 24, 2012
  12. Junio C HamanoMay 24, 2012
  13. Johannes SixtMay 25, 2012
  14. Junio C HamanoMay 25, 2012
  15. Johannes SixtMay 25, 2012
  16. Johannes SixtMay 23, 2012

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.