unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
@ 2009-04-13 11:23 Markus Triska
  2009-04-13 17:58 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Markus Triska @ 2009-04-13 11:23 UTC (permalink / raw)
  To: emacs-pretest-bug

When I do:

   $ mkdir test
   $ cd test
   $ git init
   $ touch a.txt
   $ git add a.txt
   $ git commit -m "initial revision"
   $ emacs -Q a.txt

then pressing "C-x v =" shows:

   No changes between working revision and workfile

in the echo area. However, when I do:

   M-! touch a.txt RET

then "C-x v =" shows:

   Finding changes in /Users/mt/test/a.txt...done

and a *vc-diff* buffer remains visible, showing:

   diff --git a/a.txt b/a.txt

although, as before, a.txt is unchanged. In a new Emacs instance,
"C-x v =" again behaves like the first time. git version: 1.6.2.

In GNU Emacs 23.0.92.2 (i386-apple-darwin9.6.1, GTK+ Version 2.14.7)
 of 2009-04-05 on mt-imac.local
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--with-tiff=no''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
  2009-04-13 11:23 bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git Markus Triska
@ 2009-04-13 17:58 ` Stefan Monnier
       [not found] ` <mailman.5259.1239647042.31690.bug-gnu-emacs@gnu.org>
  2012-06-28 12:51 ` Dmitry Gutov
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-04-13 17:58 UTC (permalink / raw)
  To: Markus Triska; +Cc: emacs-pretest-bug, 2982

> although, as before, a.txt is unchanged. In a new Emacs instance,
> "C-x v =" again behaves like the first time. git version: 1.6.2.

VC tries to avoid running the backend for "vc-diff" when the file is
unchanged, by keeping track of the file's modtime when the backend (in
this case, git) tells VC that the file is up-to-date.

So when you open the file, Emacs asks `git' the status of the file and
so knows that this modtime corresponds to "up-to-date".  After `touch',
OTOH, Emacs isn't so sure any more, so it runs `git diff' which happens
to output "diff --git a/a.txt b/a.txt".  IIRC if "git diff" didn't
output anything at all, the *vc-diff* window would not be made visible
and VC would have also indicated "No changes between working revision
and workfile", but since "git diff" did output something, VC presumes
that there is some kind of difference (without trying to understand the
actual content of that process output).


        Stefan








^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
       [not found] ` <mailman.5259.1239647042.31690.bug-gnu-emacs@gnu.org>
@ 2009-04-18 17:03   ` Markus Triska
  2009-04-18 19:38     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Triska @ 2009-04-18 17:03 UTC (permalink / raw)
  To: gnu-emacs-bug

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> So when you open the file, Emacs asks `git' the status of the file and
> so knows that this modtime corresponds to "up-to-date".  After `touch',
> OTOH, Emacs isn't so sure any more, so it runs `git diff'

OK, external modtime changes may be harder to handle than an Emacs use
case: Say you resume working on a file with uncommitted changes, and you
first do vc-diff and decide to throw them away. Then in the *vc-diff*
buffer, you do C-u C-c C-a until all chunks are reverted, then save the
file and see if really all changes are gone with C-x v =. At this point
the *vc-diff* buffer is shown unexpectedly without remaining changes.







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
  2009-04-18 17:03   ` Markus Triska
@ 2009-04-18 19:38     ` Stefan Monnier
  2009-04-18 19:51       ` Markus Triska
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2009-04-18 19:38 UTC (permalink / raw)
  To: Markus Triska; +Cc: gnu-emacs-bug, 2982

>> So when you open the file, Emacs asks `git' the status of the file and
>> so knows that this modtime corresponds to "up-to-date".  After `touch',
>> OTOH, Emacs isn't so sure any more, so it runs `git diff'
> OK, external modtime changes may be harder to handle than an Emacs use
> case: Say you resume working on a file with uncommitted changes, and you
> first do vc-diff and decide to throw them away. Then in the *vc-diff*
> buffer, you do C-u C-c C-a until all chunks are reverted, then save the
> file and see if really all changes are gone with C-x v =. At this point
> the *vc-diff* buffer is shown unexpectedly without remaining changes.

Yup: Emacs has no idea that the buffer-modifications you've performed
ended up undoing all the changes.  Figuring this out would be
a major challenge.  In the case of git, it would be easier to ask git
the status of the file.


        Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
  2009-04-18 19:38     ` Stefan Monnier
@ 2009-04-18 19:51       ` Markus Triska
  2009-04-18 20:07         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Triska @ 2009-04-18 19:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: gnu-emacs-bug, 2982

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>  In the case of git, it would be easier to ask git the status

Exactly, after what you explained before, it seems to me that Emacs
should ask git for the status of the file right after saving as well,
and store the new modification time (you explained that it already does
it after opening). Of course, this does not solve the problem of
external modtime changes, but it seems that this is solvable as well:
Before running diff, Emacs could ask git whether the status has changed.
It seems that this would yield consistent behaviour of vc-diff
regardless of whether the file was just opened or saved in between.







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
  2009-04-18 19:51       ` Markus Triska
@ 2009-04-18 20:07         ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2009-04-18 20:07 UTC (permalink / raw)
  To: Markus Triska; +Cc: gnu-emacs-bug, 2982

>> In the case of git, it would be easier to ask git the status
> Exactly, after what you explained before, it seems to me that Emacs
> should ask git for the status of the file right after saving as well,
> and store the new modification time (you explained that it already does
> it after opening). Of course, this does not solve the problem of
> external modtime changes, but it seems that this is solvable as well:
> Before running diff, Emacs could ask git whether the status has changed.
> It seems that this would yield consistent behaviour of vc-diff
> regardless of whether the file was just opened or saved in between.

Yes, doing it just before diff might be OK.  Patches welcome.  Note that
it may turn out to be trickier than it seems because of the division
between the generic VC code and the Git-specific one: any change to the
generic code may have nasty consequences on other backends where
`status' may take a non-negligible amount of time.


        Stefan






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git
  2009-04-13 11:23 bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git Markus Triska
  2009-04-13 17:58 ` Stefan Monnier
       [not found] ` <mailman.5259.1239647042.31690.bug-gnu-emacs@gnu.org>
@ 2012-06-28 12:51 ` Dmitry Gutov
  2 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2012-06-28 12:51 UTC (permalink / raw)
  To: 2982

I believe this is already fixed.

At least, I couldn't reproduce it on Windows or Linux with trunk Emacs 
and recent versions of Git.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-06-28 12:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-13 11:23 bug#2982: 23.0.92; `vc-diff' behaves inconsistently with git Markus Triska
2009-04-13 17:58 ` Stefan Monnier
     [not found] ` <mailman.5259.1239647042.31690.bug-gnu-emacs@gnu.org>
2009-04-18 17:03   ` Markus Triska
2009-04-18 19:38     ` Stefan Monnier
2009-04-18 19:51       ` Markus Triska
2009-04-18 20:07         ` Stefan Monnier
2012-06-28 12:51 ` Dmitry Gutov

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).