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

Re: [PATCH v3 0/4] git add --resolved

From
Jeff King <peff@peff.net>
Date
Aug 1, 2026, 14:14 UTC
Message-ID
<20260801141414.GD2041176@coredump.intra.peff.net>
In-Reply-To
<20260731125605.3638938-1-gitster@pobox.com>
On Fri, Jul 31, 2026 at 05:56:01AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> When you are the maintainer of a project and make many merges day
> in, day out, a lot of your time is spent resolving conflicts and
> adding the results to the index.  It is not unusual to have local
> changes in your working tree that are unrelated to any particular
> merge [*].  In such cases, 'git add -u', which adds all changes in
> the working tree to the index, does not help much.
> 
> Here is a new option for 'git add' that lets you add paths with
> resolved conflicts to the index, while keeping unrelated local
> changes out.

I think this is a reasonable thing to want, but just playing devil's advocate for a moment: how big of a footgun might this be?

We have some changes in the working tree, we try a merge and get conflicts, do some resolving work and now we want to stage the resolution but nothing else. How close is --resolved to that? I can think of two corner cases:

  1. There are non-merge changes in foo.c, which also had some
     conflicts. Because we stage the whole file, we accidentally stage
     those along with the merge resolution.
     But maybe this is impossible, because merge would have refused to
     operate when one of the changed files is dirty? I think this is
     dependent on the strategy, but it should be true for most
     strategies. The exception is "ours", but that does not create
     conflicts in the first place. ;)
  2. Your resolution required touching other files (e.g., updating the
     caller of a function), but we'll ignore them. Git has no idea that
     those changes are related to the merge and not just stray changes.
     You have to remember to stage them manually.
     This is a problem even without --resolved, but I think it's easy
     for --resolved to lure you into a false sense of security that it
     is staging all of the important bits.

That doesn't seem too bad to me. I was mostly worried about (1), but after digging into it, I think I've convinced myself that it's a non-issue.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 28 of 30 in “git add --resolved”
  1. 0/4 git add --resolvedJunio C Hamano, Jul 28, 2026
  2. 1/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 28, 2026
  3. 2/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 28, 2026
  4. 3/4 add: introduce '--resolved' optionJunio C Hamano, Jul 28, 2026
  5. Michael MontalboJul 29, 2026
  6. Junio C HamanoJul 29, 2026
  7. Junio C HamanoJul 29, 2026
  8. Junio C HamanoAug 2, 2026
  9. Junio C HamanoJul 29, 2026
  10. Michael MontalboAug 2, 2026
  11. Junio C HamanoAug 2, 2026
  12. Michael MontalboAug 3, 2026
  13. 4/4 read-cache: reindentJunio C Hamano, Jul 28, 2026
  14. 0/4 git add --resolvedJunio C Hamano, Jul 29, 2026
  15. 1/4 read-cache: reindentJunio C Hamano, Jul 29, 2026
  16. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 29, 2026
  17. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 29, 2026
  18. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 29, 2026
  19. Junio C HamanoJul 29, 2026
  20. Michael MontalboJul 29, 2026
  21. Junio C HamanoJul 30, 2026
  22. Michael MontalboAug 2, 2026
  23. 0/4 git add --resolvedJunio C Hamano, Jul 31, 2026
  24. 1/4 read-cache: reindentJunio C Hamano, Jul 31, 2026
  25. 2/4 merge-ll: consolidate conflict marker scanning logicJunio C Hamano, Jul 31, 2026
  26. 3/4 read-cache: add remove_file_from_index_with_flags()Junio C Hamano, Jul 31, 2026
  27. 4/4 add: introduce '--resolved' optionJunio C Hamano, Jul 31, 2026
  28. Jeff KingAug 1, 2026
  29. Junio C HamanoAug 1, 2026
  30. Junio C HamanoAug 1, 2026

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.