Re: git-diff on touched files: bug or feature?

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

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Matthieu Moy <Matthieu.Moy@xxxxxxx> writes:
>
>> $ touch bar
>> $ git diff
>> diff --git a/bar b/bar         <--- here ---<
>> $ git status
>> # On branch master
>> nothing to commit (working directory clean)
>> $ git diff                     <--- status updated
>>                                     the stat in the index.
>>
>> Is this intended,
>
> Yes.  Very much so, intentionally, from very early days of git.
> This serves as a reminder to the user that he started editing
> but changed his mind to end up with the same contents as the
> original, until the next "update-index --refresh" (which is
> internally invoked from "status").
>
> If the feature still makes sense in the modern world is a
> different story, but I do find it useful.

I understand that it can be usefull, but I really don't like having it
by default (is there a way to deactivate it BTW?):

I've hit this while working on a project, doing a lot of modifications
through scripting (some regexp substitutions and such kinds of
things). Then, git-diff shows me pages of "diff --git ...", and a few
relevant entries in the middle of it. That's very bad from the
usability point of view (I actually had some ~20 lines diff surrounded
by 100+ irrelevant lines), and also kills performance: if a script
touches a lot of files, I expect the next "diff" or "status" to be
slow, but not the second next. Here, diff will be slow until I run
git-status again.

And I find the "reminder" feature very fragile. That means git-status
is no longer a read-only operation for the user. As a user, I expect
to be able to run git-status without changing the behavior of
subsequent git commands, which is not the case here. That means for
example that someone used to running git-diff /before/ git-status will
get the reminder, while someone used to running git-diff /after/
git-status (which I find sensible, get an overview before getting the
details of what you did) won't get it. Note also that this makes a
difference between git-status (which updates the stat in the index)
and git-status -a (which doesn't). That's an implementation detail
that shouldn't be exposed to the user.

Since I don't see any mention of this in the man pages for git-diff or
git-status (I might have missed it), I wonder how many user actually
ever used this as a feature.

I'd be in favor of disabling this by default, and providing a
configuration option and/or a command line option to diff to enable
it. I can try writting a patch for this if people agree on the
specification.

-- 
Matthieu
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux