From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Mark Kharitonov <mark.kharitonov@gmail.com>, git@vger.kernel.org
Subject: Re: Can git tell me which uncommitted files clash with the incoming changes?
Date: Mon, 17 Dec 2018 19:49:00 +0100 [thread overview]
Message-ID: <877eg80z1f.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20181217162108.GB914@sigill.intra.peff.net>
On Mon, Dec 17 2018, Jeff King wrote:
> On Mon, Dec 17, 2018 at 08:08:49AM -0500, Mark Kharitonov wrote:
>
>> C:\Dayforce\test [master ↓2 +0 ~2 -0 !]> git pull
>> error: Your local changes to the following files would be
>> overwritten by merge:
>> 2.txt
>> Please commit your changes or stash them before you merge.
>> Aborting
>> Updating 2dc8bd0..ea343f8
>> C:\Dayforce\test [master ↓2 +0 ~2 -0 !]>
>>
>> Does git have a command that can tell me which uncommitted files cause
>> the this error? I can see them displayed by git pull, but I really do
>> not want to parse git pull output.
>
> That message is generated by merge-recursive, I believe after it's
> figured out which files would need to be touched.
>
> I don't offhand know of a way to get that _exact_ answer from another
> plumbing command. But in practice it would probably be reasonable to ask
> for the diff between your current branch and what you plan to merge, and
> cross-reference that with the list of files with local changes.
>
> Something like:
>
> git pull ;# this fails, but FETCH_HEAD is left over
>
> git diff-tree -z --name-only HEAD FETCH_HEAD >one
> git diff-index -z --name-only HEAD >two
> comm -z -12 one two
>
> would work on Linux, but "comm -z" is not portable (and I suspect you
> may not have comm at all on Windows). You can probably find a way to
> show the common elements of the two lists using the scripting language
> of your choice.
>
> The answer that gives will be overly broad (e.g., in a case where our
> local branch had touched file "foo" but other side had not, we'd
> consider "foo" as a difference the two-point diff-tree, whereas a real
> 3-way merge would realize that we'd keep our version of "foo"). But it
> might be good enough for your purposes.
Isn't this done more simply with just running the merge with
git-merge-tree? Maybe I'm missing something. E.g. earlier I had a
conflict between a WIP series of mine in next in
parse-options-cb.c. Just using git-merge-tree and grepping for conflict
markers gives me what conflicted:
$ git merge-tree origin/master unconditional-abbrev-2 origin/next|grep -E -e '^(merged|changed in both| (base|our|their|result))' -e '^\+======='
[...]
merged
result 100644 d70c6d9afb94c77c285fe8ee3237f7a40867157a packfile.h
our 100644 6c4037605d0dfee59a084c440506f1af11708d63 packfile.h
changed in both
base 100644 8c9edce52f63bcb1085b119b3a2264a97b1fb374 parse-options-cb.c
our 100644 1afc11a9901dba25dc0f6151e5d9a7654b6e3192 parse-options-cb.c
their 100644 e2f3eaed072f77d63890ec814d810199f57248d5 parse-options-cb.c
+=======
[...]
Or more simply, you can "grep -q" for '^\+=======' to ask "does this
conflict?".
next prev parent reply other threads:[~2018-12-17 18:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-17 13:08 Can git tell me which uncommitted files clash with the incoming changes? Mark Kharitonov
2018-12-17 16:21 ` Jeff King
2018-12-17 18:49 ` Ævar Arnfjörð Bjarmason [this message]
2018-12-17 19:35 ` Jeff King
2018-12-17 16:24 ` Duy Nguyen
2018-12-17 17:17 ` Elijah Newren
2018-12-17 19:37 ` Duy Nguyen
2018-12-17 22:50 ` Mark Kharitonov
2018-12-18 13:14 ` Jeff King
2018-12-18 15:51 ` Elijah Newren
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=877eg80z1f.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=mark.kharitonov@gmail.com \
--cc=peff@peff.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.