Re: [PATCH] diff --no-index: allow pathspec after --

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 21, 2014 at 1:19 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Junio C Hamano <gitster@xxxxxxxxx> 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
>         ...
>

Heh.. I wrote something like that [1]. An extension of this is feed
all filename pairs via stdin.

[1] http://thread.gmane.org/gmane.comp.version-control.git/188435

> 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
>         ...

This mode is weird... In real world, "A" may match to D/some-path/A
not just D/A. Which brings it back to the previous mode.

> 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.

Or let the user define a "separator", e.g.

git diff --no-index --pathspec-separator=<sep> [--] <paths...> [<sep>
<pathspec>]

Another option is pathspec magic (I'm not entirely sure how it looks
like at the implementaiton level yet), --src=<path> could become
:(source)path, --dst=path -> :(dst)path and so on..

> 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.

Sounds a lot like Jeff's "git-put", except with -- syntax instead of a
special one, and you only look at the diff, not move any content. Also
people who would go with "git diff --no-index A B C D E F..." usually
script it, not type it manually. And stdin would fit better than
command line arguments.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]