emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Don't complain about changed file when it hasn't changed


From: Davis Herring
Subject: Re: Don't complain about changed file when it hasn't changed
Date: Mon, 29 Aug 2016 13:22:15 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2

I don't understand why Git touches files it doesn't need to change.
It can (and does, AFAIK) compute the checksum of a file to know
whether it changed.

True that for a basic "git checkout new-branch" Git compares the (tree and blob) hashes to decide what files to touch. However:

$ git init
Initialized empty Git repository in /tmp/grd/.git/
$ touch a b
$ git add a b
$ git commit -m "initial"
[master (root-commit) ad16e59] initial
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
 create mode 100644 b
$ echo >>a
$ git commit -am "newline: a"
[master 9023233] newline: a
 1 files changed, 1 insertions(+), 0 deletions(-)
$ echo >>a
$ git commit -am "newline 2: a"
[master eeb78ed] newline 2: a
 1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout -q HEAD^
$ echo >>b
$ git commit -am "newline: b"
[detached HEAD 2332479] newline: b
 1 files changed, 1 insertions(+), 0 deletions(-)
$ stat -c %y b
2016-08-29 13:15:46.820780908 -0600
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: newline: b
$ stat -c %y b
2016-08-29 13:16:04.538756145 -0600

As the output says, it "rewinds" your changes and reapplies them on top of the chosen commit. This could be considered an artifact of "git rebase"'s implementation as a shell script on top of the other git commands, but given the possibility of merge conflicts to resolve it's not clear that it "ought" to be done entirely in-memory before updating only those files that need it on disk.

AFAIU, the undo records are kept because you don't revert the buffer,
not because of the check.  You could refuse to revert with the current
code, and keep the undo information, right?

You could, but Emacs would be trusting you that the file really wasn't altered. You could check yourself with `diff-buffer-with-file', but that's tedious; I find I usually just toss the undo information (by typing 'r' in response to the query).

Davis

--
This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]