From: "Óscar Fuentes" <ofv@wanadoo.es>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Git conflict VC state detection
Date: Sun, 10 Nov 2013 23:19:02 +0100 [thread overview]
Message-ID: <87ppq7zyqx.fsf@wanadoo.es> (raw)
In-Reply-To: <527FFA0B.1080805@yandex.ru> (Dmitry Gutov's message of "Sun, 10 Nov 2013 23:26:35 +0200")
Dmitry Gutov <dgutov@yandex.ru> writes:
> On 10.11.2013 22:30, Óscar Fuentes wrote:
>> I've revised the initial commit implementing conflict state detection on
>> my private branch and the problem with it was that it didn't detect
>> edited state on a staged file, i.e. a file containing staged (but
>> uncommitted) changes would show as up to date.
>>
>> So I pursued a more precise method. The problem is that the git commands
>> that tells you that a file is unmerged doesn't tell that a file contains
>> changes if those are staged.
>
> Are you sure? AFAICS, 'git diff' behaves this way ('git diff' shows
> only unstages changes, 'git diff --cached' only stages ones, but 'git
> diff HEAD' will include both), but the 'git diff-index' command we're
> using already includes HEAD as the reference, and even if I do a 'git
> add' on some edited file, while 'git diff' shows me nothing, 'git
> diff-index --raw HEAD' includes the file with status M.
>
> I haven't tested it in the situation with a file being merged, though.
> Maybe that's different somehow.
With the current method in vc-git-state, this is an example where
the file keyword.cpp is unmerged:
$ git diff-index HEAD -- keyword.cpp
(-p --raw options eluded, as they just add the patch to the output,
which is useless.)
:100644 100644 12b8b5a24d99dfec20c4b5283d91b15ed1a83b4e 0000000000000000000000000000000000000000 Mkeyword.cpp
At first, you can think that those series of zeroes mean something (the
documentation for git-diff-index says
``sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree"
which is quite vague) so let's try with a plainly edited file:
$ git diff-index HEAD -- CMakeLists.txt
:100644 100644 8465aca146db66862498b9e2f2a8993e5d8dda69 0000000000000000000000000000000000000000 MCMakeLists.txt
Hence `git diff-index' can't tell the difference among an unmerged and
an edited file.
Now let's try again but with the `--cached' option:
$ git diff-index --cached -- keyword.cpp
:100644 000000 12b8b5a24d99dfec20c4b5283d91b15ed1a83b4e 0000000000000000000000000000000000000000 Ukeyword.cpp
There it is the `U'. But with the edited, unstaged file:
$ git diff-index --cached HEAD -- CMakeLists.txt
<no output>
And then you need a plain "git diff-index HEAD -- CMakeLists.txt" for
knowing that the file is edited.
AFAIK there is no command that tells that a file is unmerged and also
tells that it is edited, no matter if its changes are staged or not.
>> I CC'ed Dmitry as he implemented the part that my patch touches. I'll
>> like to get the ok from him before installing the patch,
>
> I did a relatively small change there, actually, it just unwrapped all
> the code in `vc-git-registered'.
So you were wrongly "blamed" :-) Sorry about that.
> But FWIW, I don't like the idea of
> doing double the work (external process calls) to know about one more
> status, in principle.
I'm not myself happy with the solution. It all depends on how important
it is to know the `conflict' status. Maybe other features on Emacs VC
depends on it.
next prev parent reply other threads:[~2013-11-10 22:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-07 17:08 Two feature ideas for diffs Tom
2013-11-07 17:25 ` nhs
2013-11-07 17:39 ` Tom
2013-11-07 17:58 ` Dmitry Gutov
2013-11-07 18:24 ` Tom
2013-11-07 19:09 ` Stefan Monnier
2013-11-07 19:30 ` Dmitry Gutov
2013-11-07 20:00 ` Stefan Monnier
2013-11-08 22:58 ` Michael Heerdegen
2013-11-09 2:30 ` Óscar Fuentes
2013-11-09 2:59 ` Michael Heerdegen
2013-11-09 13:34 ` Stefan Monnier
2013-11-09 22:58 ` Michael Heerdegen
2013-11-09 13:37 ` Stefan Monnier
2013-11-09 15:02 ` Óscar Fuentes
2013-11-10 13:24 ` Stefan Monnier
2013-11-10 20:30 ` Git conflict VC state detection Óscar Fuentes
2013-11-10 21:26 ` Dmitry Gutov
2013-11-10 22:19 ` Óscar Fuentes [this message]
2013-11-11 0:16 ` Stefan Monnier
2013-11-11 0:53 ` Óscar Fuentes
2013-11-11 2:13 ` Stefan Monnier
2013-11-11 23:16 ` Dmitry Gutov
2013-11-07 18:11 ` Two feature ideas for diffs Dmitry Gutov
2013-11-07 18:33 ` Tom
2013-11-08 1:29 ` Ivan Andrus
2013-11-07 19:11 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ppq7zyqx.fsf@wanadoo.es \
--to=ofv@wanadoo.es \
--cc=dgutov@yandex.ru \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).