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

Re: [PATCH 2/6] diff: ignore sparse paths in diffstat

From
Elijah Newren <newren@gmail.com>
Date
Aug 27, 2021, 22:27 UTC
Message-ID
<CABPp-BHR5Zf23yVXJ9NTbo05Ck+kpZ7tH3qBEvnPjV42PzyOcg@mail.gmail.com>
In-Reply-To
<d77ae8ce-977a-82d9-f28c-f57271fbf923@gmail.com>
On Tue, Aug 24, 2021 at 11:30 AM Derrick Stolee <stolee@gmail.com> wrote:
Show 68 quoted lines
>
> On 8/20/2021 5:32 PM, Elijah Newren wrote:
> > On Tue, Aug 17, 2021 at 10:08 AM Derrick Stolee via GitGitGadget
> > <gitgitgadget@gmail.com> wrote:
> >>
> >> From: Derrick Stolee <dstolee@microsoft.com>
> >>
> >> The diff_populate_filespec() method is used to describe the diff after a
> >> merge operation is complete, especially when a conflict appears. In
> >> order to avoid expanding a sparse index, the reuse_worktree_file() needs
> >> to be adapted to ignore files that are outside of the sparse-checkout
> >> cone. The file names and OIDs used for this check come from the merged
> >> tree in the case of the ORT strategy, not the index, hence the ability
> >> to look into these paths without having already expanded the index.
> >
> > I'm confused; I thought the diffstat was only shown if the merge was
> > successful, in which case there would be no conflicts appearing.
>
> That's my mistake. I'll edit the message accordingly.
>
> > Also, I'm not that familiar with the general diff machinery (just the
> > rename detection parts), but...if the diffstat only shows when the
> > merge is successful, wouldn't we be comparing two REVS (ORIG_HEAD to
> > HEAD)?  Why would we make use of the working tree at all in such a
> > case?  And, wouldn't using the working tree be dangerous...what if
> > there was a merge performed with a dirty working tree?
> >
> > On a bit of a tangent, I know diffcore-rename.c calls into
> > diff_populate_filespec() as well, and I have some code doing merges in
> > a bare repository (where there obviously is no index).  It seemed to
> > be working, but given this commit message, now I'm wondering if I've
> > missed something fundamental either in that implementation or there's
> > something amiss in this patch.  Or both.  Maybe I need to dig into
> > diff_populate_filespec() more, but it seems you already have.  Any
> > pointers to orient me on why your changes are right here (and, if you
> > know, why diffcore-rename.c should or shouldn't be using
> > diff_populate_filespec() in a bare repo)?
>
> I think the cases you are thinking about are covered by this
> condition before the one I'm inserting:
>
>         /* We want to avoid the working directory if our caller
>          * doesn't need the data in a normal file, this system
>          * is rather slow with its stat/open/mmap/close syscalls,
>          * and the object is contained in a pack file.  The pack
>          * is probably already open and will be faster to obtain
>          * the data through than the working directory.  Loose
>          * objects however would tend to be slower as they need
>          * to be individually opened and inflated.
>          */
>         if (!FAST_WORKING_DIRECTORY && !want_file && has_object_pack(oid))
>                 return 0;
>
> or after:
>
>         /*
>          * Similarly, if we'd have to convert the file contents anyway, that
>          * makes the optimization not worthwhile.
>          */
>         if (!want_file && would_convert_to_git(istate, name))
>                 return 0;
>
> (This makes me think that I should move my new condition further down
> so these two can be linked by context.)
>
> Sounds like this is just an optimization, so it is fine to opt out of it
> if we think the optimization isn't necessary. Outside of the sparse-checkout
> cone qualifies.
Ah, this is very helpful.  Thanks for digging up these details.
Previous: Derrick StoleeNext: Derrick Stolee via GitGitGadget
Message 15 of 45 in “Sparse Index: Integrate with merge, cherry-pick, rebase, and revert”
  1. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Aug 17, 2021
  2. 1/6 t1092: use ORT merge strategyDerrick Stolee via GitGitGadget, Aug 17, 2021
  3. Taylor BlauAug 18, 2021
  4. Junio C HamanoAug 18, 2021
  5. Derrick StoleeAug 18, 2021
  6. Junio C HamanoAug 18, 2021
  7. Elijah NewrenAug 20, 2021
  8. Junio C HamanoAug 20, 2021
  9. Elijah NewrenAug 21, 2021
  10. Junio C HamanoAug 21, 2021
  11. Elijah NewrenAug 21, 2021
  12. 2/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Aug 17, 2021
  13. Elijah NewrenAug 20, 2021
  14. Derrick StoleeAug 24, 2021
  15. Elijah NewrenAug 27, 2021
  16. 3/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Aug 17, 2021
  17. Elijah NewrenAug 20, 2021
  18. 4/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Aug 17, 2021
  19. Elijah NewrenAug 20, 2021
  20. 5/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Aug 17, 2021
  21. Elijah NewrenAug 20, 2021
  22. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Aug 17, 2021
  23. Elijah NewrenAug 21, 2021
  24. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Aug 24, 2021
  25. 2/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Aug 24, 2021
  26. Elijah NewrenAug 27, 2021
  27. Derrick StoleeAug 30, 2021
  28. Derrick StoleeSep 8, 2021
  29. 1/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Aug 24, 2021
  30. 3/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Aug 24, 2021
  31. Elijah NewrenAug 27, 2021
  32. Derrick StoleeAug 30, 2021
  33. 4/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Aug 24, 2021
  34. 5/6 sequencer: ensure full index if not ORT strategyDerrick Stolee via GitGitGadget, Aug 24, 2021
  35. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Aug 24, 2021
  36. Elijah NewrenAug 27, 2021
  37. Derrick StoleeAug 30, 2021
  38. 0/6 Sparse Index: Integrate with merge, cherry-pick, rebase, and revertDerrick Stolee via GitGitGadget, Sep 8, 2021
  39. 1/6 diff: ignore sparse paths in diffstatDerrick Stolee via GitGitGadget, Sep 8, 2021
  40. 2/6 merge: make sparse-aware with ORTDerrick Stolee via GitGitGadget, Sep 8, 2021
  41. 4/6 t1092: add cherry-pick, rebase testsDerrick Stolee via GitGitGadget, Sep 8, 2021
  42. 3/6 merge-ort: expand only for out-of-cone conflictsDerrick Stolee via GitGitGadget, Sep 8, 2021
  43. 5/6 sequencer: ensure full index if not ORT strategyDerrick Stolee via GitGitGadget, Sep 8, 2021
  44. 6/6 sparse-index: integrate with cherry-pick and rebaseDerrick Stolee via GitGitGadget, Sep 8, 2021
  45. Elijah NewrenSep 9, 2021

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.