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

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 -- M
If 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
Previous: Junio C Hamano
Message 5 of 5 in “combine-diff: handle --find-object in multitree code path”
  1. combine-diff: handle --find-object in multitree code pathJeff King, Sep 30, 2020
  2. Chris TorekSep 30, 2020
  3. Jeff KingSep 30, 2020
  4. Junio C HamanoSep 30, 2020
  5. Jeff KingSep 30, 2020

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.