Web lists-archives.com

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

Johannes Schindelin <Johannes.Schindelin@xxxxxx> 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.