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

Re: What I want rebase to do

From
Thomas Rast <trast@student.ethz.ch>
Date
Mar 7, 2013, 08:48 UTC
Message-ID
<87r4jra942.fsf@pctrast.inf.ethz.ch>
In-Reply-To
<201303061855.r26ItKtM018797@freeze.ariadne.com>

worley@alum.mit.edu (Dale R. Worley) writes: [...snip...]

Isn't that just a very long-winded way of restating what Junio said earlier:

> > It was suggested to make it apply the first-parent diff and record
> > the result, I think.  If that were an acceptable approach (I didn't
> > think about it through myself, though), that would automatically
> > cover the evil-merge case as well.
You can fake that with something like
git rev-list --first-parent --reverse RANGE_TO_REBASE |
while read rev; do
    if git rev-parse $rev^2 >/dev/null 2>&1; then
        git cherry-pick -n -m1 $rev
        git rev-parse $rev^2 >.git/MERGE_HEAD
        git commit -C$rev
    else
        git cherry-pick $rev
    fi
done

Only tested very lightly. Dealing with octopii, conflicts and actually preserving the commit's attributes is left as an exercise to the reader[1].

I still think that the _right_ solution is first redoing the merge on its original parents and then seeing how the actual merge differs from that. --preserve-merges has bigger issues though, like Junio said.

Perhaps a new option to git-rebase could trigger the above behavior for merges, who knows. (It could be called --first-parent.)

[1] If you don't get the sarcasm: that would amount to reinventing large parts of git-rebase.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Dale R. WorleyNext: Johannes Sixt
Message 6 of 13 in “"git rebase" loses the additional changes in "evil" merges”
  1. Dale R. WorleyMar 4, 2013
  2. Junio C HamanoMar 4, 2013
  3. Thomas RastMar 4, 2013
  4. Junio C HamanoMar 4, 2013
  5. What I want rebase to doDale R. Worley, Mar 6, 2013
  6. Thomas RastMar 7, 2013
  7. Johannes SixtMar 7, 2013
  8. Junio C HamanoMar 7, 2013
  9. Dale R. WorleyMar 7, 2013
  10. Dale WorleyMar 5, 2013
  11. Junio C HamanoMar 5, 2013
  12. Philip OakleyMar 5, 2013
  13. Junio C HamanoMar 5, 2013

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.