From: Junio C Hamano Date: Sun, 21 Sep 2014 06:19:19 GMT Subject: Re: [PATCH] diff --no-index: allow pathspec after -- Message-ID: In-Reply-To: Junio C Hamano writes: > Coming back to the command line syntax for the new feature, if I had > to choose, I would say > > git diff --no-index [-] [--] > > 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 [-] --src= --dst= [--] 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= --{src,dst}-index --{src,dst}-worktree --{src,dst}-tree= which allows us to express funky combinations like git diff --src-index --dst-worktree [--] git diff --src-tree=HEAD --dst-index [--] git diff --src-tree=maint --dst-tree=master [--] The above three would be ugly ways to spell the traditional "short hands", e.g. git diff [--] git diff --cached [--] git diff maint master [--] respectively. And an obvious fallout of the above is this command line: git diff --src-path=A --dst-path=B [--] 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.