Junio C Hamano <[email protected]> writes:
> Coming back to the command line syntax for the new feature, if I had
> to choose, I would say
>
> git diff --no-index [-<options>] [--] <path> <path> <pathspec>
>
> perhaps? As we never compare anything other than two things,...
Actually, I am not so sure about this anymore.
It is not entirely fair to say that
git diff --no-index [--options] A B C D
as comparing A and B while using C and D as pathspec and declare a
person who expects otherwise a moron. To a person whose brain is
not rotten by years of use of Git, "we never compare anything other
than two things with --no-index" is not a given, I am afraid.
It is equally plausible that the same command line may be asking to
compare A with B and C with D, i.e. producing
diff --no-git a/A b/B
...
diff --no-git a/C b/D
...
It also equally plausible (taking a cue from "mv A B C Dir/") that
it is comparing A, B and C with D/A, D/B and D/C, respectively,
producing
diff --no-git a/A b/D/A
...
diff --no-git a/B b/D/B
...
diff --no-git a/C b/D/C
...
The only unambiguous syntax I can think of that avoids such
alternative interpretations is something ugly like
git diff --no-index [-<options>] --src=<path> --dst=<path> [--] <pathspec>
where "src" and "dst" are in line with the existing src/dst-prefix
options.
Perhaps we could declare that this is the "canonical" way to spell
pathspec-filtered no-index comparison of two directories, but we
allow the syntax suggested in the message I am responding to as a
short-hand, but I am not sure if that would fly well.
This --src/--dst thing could lead to even uglier tangent. We could
use these options to specify what is compared with what else
--{src,dst}-path=<directory in the working tree>
--{src,dst}-index
--{src,dst}-worktree
--{src,dst}-tree=<tree object>
which allows us to express funky combinations like
git diff --src-index --dst-worktree [--] <pathspec>
git diff --src-tree=HEAD --dst-index [--] <pathspec>
git diff --src-tree=maint --dst-tree=master [--] <pathspec>
The above three would be ugly ways to spell the traditional "short
hands", e.g.
git diff [--] <pathspec>
git diff --cached [--] <pathspec>
git diff maint master [--] <pathspec>
respectively. And an obvious fallout of the above is this command
line:
git diff --src-path=A --dst-path=B [--] <pathspec>
Because this does not involve any index, tree or worktree, it cannot
be a Git operation, so we know that is --no-index mode; the command
line does not need to say --no-index anywhere if we go that route.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html