Re: [PATCH] combine-diff: handle --find-object in multitree code path
- From
Jeff King <peff@peff.net>
- Date
- Sep 30, 2020, 22:54 UTC
- Message-ID
- <20200930225441.GD1908000@coredump.intra.peff.net>
- In-Reply-To
- <xmqqmu16gbqk.fsf@gitster.c.googlers.com>
On Wed, Sep 30, 2020 at 03:07:15PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> > +test_expect_success 'do not detect merge that does not touch blob' ' > > + git checkout -B merge interesting && > > + git merge -m "untouched blob" base && > > + git diff-tree --format=%s --find-object=$blob -c --name-status HEAD >actual && > > You learn new things every day ;-) > > I've always thought that for --find-object to do a good job, you'd > need "--full-history" and perhaps "-m". Especially, I didn't expect > "-c" or "--cc" to make a difference.
You don't need --full-history, since there's no history simplification going on here. And "-m" isn't very helpful with --find-object. It's going to find every merge that crosses a boundary where the object was introduced, since it will be introduced in the diff against the _other_ parent. E.g., in:
A -- B
\ \
C -- MIf B introduces object X, then:
git log --find-object=X -m M
is going to see the diff of C to M as introducing X. But M didn't do anything interesting there; it just picked it up from the branch with B.
My concrete use case here, btw, is reporting to users which commit introduced a blob (and at which path). It mostly works if you ignore merges, but misses out on any evil merges which introduce the object. Adding "-c" fixes that (but before this patch is slow and misses the case where the merge removes the object).
-Peff