Re: Removing useless merge commit with "filter-branch"

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

 



Hi

On Thu, Mar 8, 2012 at 3:30 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Anatol Pomozov <anatol.pomozov@xxxxxxxxx> writes:
>
>> |
>> o      - merge commit that previously merged feature X
>> |\
>> | \
>> |  \
>> o  |   - real commit
>> |   |
>> |  /
>> |/
>> |
>
> It is unclear how many commits are drawn in the above picture and
> what "feature X" is about in the above picture.  Care to redraw the
> commit DAG to explain what you are trying to do a bit better?
>
> The way I read it is that you start from a history like this (note
> that when we draw an ascii art history we often write it sideways,
> time flows from left to right):
>
>    ---A-----B-----M---
>        \         /
>         C-------D
>
> where a side branch to implement "feature X" that has C and D forked
> at A, and it was merged at M after somebody else committed B on the
> mainline.  When you filtered out some parts of the tree, it turns
> out that C and D are totally unintereseting because their changes
> touch parts outside of your interest, i.e. the history is:
>
>    ---A-----B-----M---
>        \         /
>         o-------o
>
> where 'o' are now no-op.
>
> Is that what you are talking about?

Yes, in fact --prune-empty flag removes empty commits so the history looks like

-----A-------B-------M--------
       \               /
        --------------


So M is a merge that has 2 parents A and B. I would like to remove
this merge M and leave the history as

-----A-----B-----

as only these commits have changes in my library that I am trying to extract.

I think some trickery with "git filter-branch --parent-filter" should help here.

First one runs filter-branch with --parent-filter and removes useless
parents from merges (in this example with will be parent A---M), this
converts such merges to regular empty commits

then run filter-branch one more time with --prune-empty - it removes
empty commits.
>
> I think "log --simplify-merges A..M -- path" may already has logic
> that deals with this, so it may help if you study what it does and
> how it does what it does.
--
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]