git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] difftool --dir-diff: always use identical working tree file

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2013, 19:31 UTC
Message-ID
<7vtxlmzyt9.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130528190829.GB17475@serenity.lan>
John Keeping <john@keeping.me.uk> writes:
Show 19 quoted lines
>>  - When comparing two revisions, e.g. "--dir-diff HEAD^^ HEAD^",
>>    that checks out (via $rsha1 to "checkout -f" codepath) a blob
>>    that does not match what is in the working tree of HEAD to the
>>    temporary directory, we still allow modifications to the copy in
>>    the temporary directory, but what can the user do with these
>>    changes that are _not_ based on HEAD, short of checking out HEAD^
>>    and apply the difference first?
>> 
>> I still cannot shake this nagging feeling that giving a writable
>> temporary directory might have been a mistake in the first place.
>> Perhaps it may be a better design to make the ones that the user
>> shouldn't touch (or will lead to the above confusion) read-only,
>> while the ones that match the working tree read-write?
>
> My ideal scenario would be that we only allow users to edit files when
> they are comparing against the working tree, but that would require
> git-difftool to fully understand all git-diff options since it just
> passes through any it doesn't recognise.  I don't think there's an easy
> way to do that, which leaves us with this confusing situation.
Not necessarily.

Let's assume that changing files in "diff" tool is a sensible thing to do, as long as we make sure such a change is not lost (which I may not 100% agree with, but let's put it aside for now).

When you are viewing a file F in "--dir-diff HEAD^^ HEAD^", if there is no change for F in between HEAD^ and HEAD and you notice a typo that may or may not be related to the differences between HEAD^^ and HEAD^, it would be tempting to fix that right there. And as long as F in the working tree matches that of HEAD^ and the modification you make in the temporary directory gets copied back to the working tree, your typofix will end up to be in the working tree.

Which I _think_ is what people, who want to change files in "diff" tool, want to do.

Of course, your working tree may have been in the middle of doing something entirely different and you may have to "add [-p]" to separate such a typofix with other changes you were working on, but that is a separate issue.

And for that to work, the only think you need is "does the blob we show on the RHS temporary tree match what is in the working tree?" check. You do not need to know or care if you are comparing two old revisions, etc.

Previous: John KeepingNext: Kenichi Saita
Message 8 of 10 in “difftool --dir-diff: copy back all files matching the working tree”
  1. difftool --dir-diff: copy back all files matching the working treeKenichi Saita, May 26, 2013
  2. John KeepingMay 26, 2013
  3. difftool --dir-diff: always use identical working tree fileKenichi Saita, May 27, 2013
  4. Junio C HamanoMay 28, 2013
  5. John KeepingMay 28, 2013
  6. Junio C HamanoMay 28, 2013
  7. John KeepingMay 28, 2013
  8. Junio C HamanoMay 28, 2013
  9. difftool --dir-diff: allow changing any clean working tree fileKenichi Saita, May 29, 2013
  10. Junio C HamanoMay 29, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.