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

Re: js/difftool-no-index, was Re: What's cooking in git.git (May 2019, #02; Tue, 14)

From
Junio C Hamano <gitster@pobox.com>
Date
May 15, 2019, 08:50 UTC
Message-ID
<xmqqsgtg5cff.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<nycvar.QRO.7.76.6.1905151015540.44@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> As far as `--no-index` is concerned, all files are untracked anyway. There
> is no index, so there are no staged/committed/tracked files.
> ...

Ah, I see I completely misspoke; sorry, there should be no "pretend as if there were no --dir-diff".

In the normal usage, "difftool --dir-diff" materializes the two tree-shaped things (I am using an invented term loosely here---it may be a tree-ish, or what is in the index, or the working tree files) in two temporary directories and runs a tool to compare two directories, and what is copied out of the working tree is limited to the tracked ones (for the obvious purpose to avoid showing them the the directory comparison tool).

Extending that semantics literally to "--no-index" use would result in nonsense. As you say, there is no "tracked" thing under the mode, so doing what "--dir-diff" literally does (i.e. only copy out what is tracked for the purpose of comparison) would be to compare nothing against nothing. That is not useful.

What I was wondering when I wrote the message you are responding to was complete opposite. I was imagining what would happen if we treat _everything_ in the two directories being compared by "difftool --dir-diff --no-index" as if it is tracked. We do not even have to make copies (as we are not doing a selective "only the tracked ones" copy), but if it is easier to implement we could make redundant copies. In either case, the two directories given to the "difftool --no-index" would be compared with the same directory comparison tool the end user is used to (as that is the one the "--dir-diff" mode uses to compare without "--no-index"). When the end user does this sequence, for example:

    $ rm -fr /var/tmp/1 /var/tmp/2 && mkdir /var/tmp/1 /var/tmp/2
    $ (cd /var/tmp/1 && tar xvf -) <version1.tar
    $ (cd /var/tmp/2 && tar xvf -) <version2.tar
    $ git difftool --dir-diff --no-index /var/tmp/1 /var/tmp/2
isn't that what the user wanted to do?

Obviously "git difftool --dir-diff --no-index" can be replaced with the underlying comparison tool that "difftool--helper" would have chosen by the end user, so it is not the end of the world if we do not to support the combination and error it out instead, like your patch does. But I just thought it would be nicer to the end users who extracted two tarballs into a pair of pristine directories and wanted to compare them in a way familiar to them.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 6 of 9 in “What's cooking in git.git (May 2019, #02; Tue, 14)”
  1. Junio C HamanoMay 13, 2019
  2. Elijah NewrenMay 13, 2019
  3. js/difftool-no-index, was Re: What's cooking in git.git (May 2019, #02; Tue, 14)Johannes Schindelin, May 14, 2019
  4. Junio C HamanoMay 15, 2019
  5. Johannes SchindelinMay 15, 2019
  6. Junio C HamanoMay 15, 2019
  7. Johannes SchindelinMay 17, 2019
  8. Junio C HamanoMay 19, 2019
  9. Johannes SchindelinMay 21, 2019

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.