From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v3 0/4] git add --resolved
Date: Fri, 31 Jul 2026 05:56:01 -0700 [thread overview]
Message-ID: <20260731125605.3638938-1-gitster@pobox.com> (raw)
In-Reply-To: <20260728215219.753678-1-gitster@pobox.com>
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.
The first three patches perform preliminary refactorings.
- [1/4] is a totally unrelated code cleanup that almost disappears
when viewed with 'git show -w', but it was an eyesore to have so
many lines with broken indentation while working in the vicinity.
- [2/4] consolidates a helper function to determine whether a line
is a conflict marker (replacing two slightly different
definitions).
- [3/4] introduces a helper that makes registering path removals
from the index as easy as adding them, complete with automatic
'--dry-run' and '--verbose' support.
The fourth patch implements the new feature.
1/4: read-cache: reindent
2/4: merge-ll: consolidate conflict marker scanning logic
3/4: read-cache: add remove_file_from_index_with_flags()
4/4: add: introduce '--resolved' option
The only change since v2 is to fix the test under BREAKING_CHANGES,
where the tests are run with a future default initial branch name of
'main'. Instead of assuming that the initial branch is named
'master' when returning, we instruct 'checkout' to return to the
previous branch, i.e., '@{-1}'.
[Footnote]
* This is not limited to my own workflow. An earlier message on
this topic worth mentioning is:
https://lore.kernel.org/git/CA+55aFxP8j7YbYaRXt-8Y0n8cHafB=FPKMy8gKFYH5QsKX4S=Q@mail.gmail.com/
Documentation/git-add.adoc | 10 +++-
builtin/add.c | 92 ++++++++++++++++++++++++++++---
diff.c | 25 +--------
merge-ll.c | 56 +++++++++++++++++++
merge-ll.h | 2 +
read-cache-ll.h | 3 ++
read-cache.c | 89 +++++++++++++++++-------------
rerere.c | 38 +++----------
t/meson.build | 1 +
t/t2207-add-resolved.sh | 108 +++++++++++++++++++++++++++++++++++++
10 files changed, 323 insertions(+), 101 deletions(-)
create mode 100755 t/t2207-add-resolved.sh
Range-diff against v2:
1: b0643ed516 = 1: 414219a89a read-cache: reindent
2: 4533fa4da1 = 2: f64ad26d1f merge-ll: consolidate conflict marker scanning logic
3: dbf70c2d3a = 3: 1431d0bfdb read-cache: add remove_file_from_index_with_flags()
4: 033a3d2526 ! 4: 42fb33200a add: introduce '--resolved' option
@@ t/t2207-add-resolved.sh (new)
+ echo "theirs 3" >file3.txt &&
+ git commit -a -m theirs &&
+
-+ git checkout master
++ git checkout @{-1}
+'
+
+test_expect_success 'git add --resolved refuses files with conflict markers' '
--
2.55.0-599-g5cacd2ad51
next prev parent reply other threads:[~2026-07-31 12:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 21:52 [PATCH 0/4] git add --resolved Junio C Hamano
2026-07-28 21:52 ` [PATCH 1/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-28 21:52 ` [PATCH 2/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-28 21:52 ` [PATCH 3/4] add: introduce '--resolved' option Junio C Hamano
2026-07-29 3:28 ` Michael Montalbo
2026-07-29 13:43 ` Junio C Hamano
2026-07-29 13:49 ` Junio C Hamano
2026-07-29 15:01 ` Junio C Hamano
2026-07-28 21:52 ` [PATCH 4/4] read-cache: reindent Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 0/4] git add --resolved Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 1/4] read-cache: reindent Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 2/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 3/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-29 17:25 ` [PATCH v2 4/4] add: introduce '--resolved' option Junio C Hamano
2026-07-29 22:19 ` Junio C Hamano
2026-07-29 23:41 ` [PATCH v2 0/4] git add --resolved Michael Montalbo
2026-07-30 8:41 ` Junio C Hamano
2026-07-31 12:56 ` Junio C Hamano [this message]
2026-07-31 12:56 ` [PATCH v3 1/4] read-cache: reindent Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 2/4] merge-ll: consolidate conflict marker scanning logic Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 3/4] read-cache: add remove_file_from_index_with_flags() Junio C Hamano
2026-07-31 12:56 ` [PATCH v3 4/4] add: introduce '--resolved' option Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731125605.3638938-1-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox