git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: git squash
@ 2018-02-23  3:41 Julius Musseau
  2018-02-23  6:04 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Julius Musseau @ 2018-02-23  3:41 UTC (permalink / raw)
  To: git

Hi, Git Developers,

Thanks for your help regarding my earlier email (trying to break git
pull --rebase).

I just wanted to warn you all that my first attempt at a patch is
imminent.  I'm working on a "git squash" command.  Here's a quick
summary:

------
git squash [<commit>]

Squashes <commit>..HEAD into a single commit. Replaces HEAD with the
result.  If not specified, <commit> defaults to the current branch's
upstream (a.k.a. @{upstream}).

Rationale:

This command provides an intuitive mechanism for in-place squash that
doesn't drop dirty merge results.

We call this an in-place squash because the state of all files and
directories at HEAD does not change. Only the ancestory of HEAD
changes: its (only) parent becomes the merge-base of <commit> and
HEAD, removing all intermediate commits.

Alternatives:

- "git merge --squash master" correctly preserves dirty merge results,
but it's tricky to achieve an in-place squash with this command, since
it requires the following sequence of commands (these assume the
current branch is "feature" and we want to squash it relative to
"master"):

    git checkout $(git merge-base HEAD master)
    git merge --squash feature
    git commit
    git branch -f feature
    git checkout feature

- "git rebase --interactive HEAD~N" with commits set to "squash" (or
"fixup") is very popular in industry.  But it has some tricky edge
cases: drops dirty merge results, can run into conflicts, and can be
confusing if HEAD~N spans any merges (including clean merges).
-----


I expect I'll have the patch finished this weekend, and ready for
everyone to look at by Monday (Feb 26th).

Note:  I'm not 100% sure "git rebase --interactive" would drop dirty
merge results (e.g., the dirty parts from conflict-resolving merges).
That's speculation on my part.  I'll confirm this before I finish and
submit the patch.


yours sincerely,

Julius Musseau

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-23 20:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23  3:41 RFC: git squash Julius Musseau
2018-02-23  6:04 ` Junio C Hamano
2018-02-23 17:03   ` Julius Musseau
2018-02-23 20:31     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).