Re: Relative ls-files

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

 



Junio C Hamano venit, vidit, dixit 23.03.2011 16:42:
> Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx> writes:
> 
>>>> What's wrong with --relative  or something?
>>
>> ??
>>
>> ls-files already lists files relative to cwd. What you need is a way to
>> specify that you want all files, not just those beneath cwd.
> 
> Exactly.
> 
>>>> I've never liked magical strange notations.  ":" already has a meaning.
>>>
>>> +1
>>
>> I think you've both been missing out on the discussions about
>> --full-tree and refspec notation for that...
> 
> I like this answer.  Don't pay any much attention +1/-1 from people who
> are clueless to the topic, but do pay attention to them as persons by
> showing that there are things for them to read and learn if they want to
> discuss the topic.  A URL or two to the recent thread may have been nicer.
> 
>> Of course ":" has a meaning. "git show HEAD:" lists all files at the
>> top-level of the tree at HEAD. That is exactly why ":" has been
>> suggested to denote the top-level for pathspecs also. Note that this is
>> much more general than just an option for ls-files.
> 
> Talking about the "pathspec magic", I think in addition to "this is
> relative to root", we at least would need "this is literal, don't apply
> globbing" magic.  I am afraid that using ':' as the sole "magic for
> from-root" as you advocate may turn out to be too short-sighted and would
> hurt us in the future.

I admit I haven't thought much about globbing. Does my current POC patch
affect globbing in the way you want to avoid?

> 
> It may be more extensible if we used a common "magic introducer" at the
> beginning, an character unlikely to collide with any pathspec existing
> scripts and people use, and then have additional "what magic I want"
> signature immediately following that introducer letter in these magic
> filespecs.
> 
> Off the to of my head, "/" may be a perfect choice for "here is a magic"
> introducer, as we never give absolute paths on the fiesystem from the root
> to git [*1*].
> 
> Then, even when you are in a subdirectory somewhere, this:
> 
>     $ git ls-tree pu -- '/:*.h' "/!$path"
> 
> would list paths in the pu branch, limiting its output to any "*.h" header
> file, and a path that matches exactly with whatever is in $path variable
> without globbing within the current level.  The above uses ':' as "this is
> relative to root" (your favorite, whose rationale being that HEAD:Makefile
> names Makefile at the top) and '!' (randombly chosen without any rationale
> other than being "NOT" and without any association with "glob", which make
> it a bad choice of the letter) as "this is NOT a glob".
> 
> If we use ':' as the magic introducer, '::*.h" may be more logical if you
> follow your "HEAD:Makefile names Makefile at the top" analogy; ':/' breaks
> the analogy (the first colon is a general introducer and does not talk
> anything about what kind of magic; the second letter should be what magic
> it is about, and should use ':' from HEAD:Makefile analogy).

Mainly I want "few characters" (up to 2) and "good analogy". "/" and
"//" have obvious good analogies to file system usage.

> 
> I personally think "//*.h" looks a lot more natural than either ':*.h' or

With current git:

(cd Documentation && git show :Makefile)

Which Makefile do you get? That is why I call the ":" proposal natural.
I know, "git show Makefile" does not give the local one, but

git show :./Makefile

does. Given this, I would find ":/Makefile" very natural as well.

> ':/*.h' that have been suggested on the command line, so I am tempted to
> suggest using '/' (the first slash in the example) as the magic introducer
> and using '/' (the second) as the 'from-root' magic signature.

I'm afraid (but not sure) that leading "/" would create problems for Git
on Win! ":/" is fine according to the experts.

Michael
--
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]