From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Nazri Ramliy <ayiehere@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] Teach git to change to a given directory using -C option
Date: Sat, 20 Apr 2013 15:18:38 -0700 [thread overview]
Message-ID: <20130420221752.GA9980@elie.Belkin> (raw)
In-Reply-To: <20130419161250.GC14263@sigill.intra.peff.net>
Jeff King wrote:
> On Fri, Apr 19, 2013 at 08:21:48PM +0800, Nazri Ramliy wrote:
>> Often I find myself needing to find out quickly the status of a repository that
>> is not in my currenct working directory, like this:
>>
>> $ (cd ~/foo; git log -1)
>>
>> With this patch now i can simply do:
>>
>> $ git -C ~/.zsh log -1
>>
>> That's just one example.
[...]
> You can _almost_ do this with "git --git-dir". But it expects the actual
> git directory, not a starting point for finding the git directory.
[...]
> It is redundant with "(cd foo && git ...)" in the shell, as you note,
> but sometimes it is more convenient to use "-C" (especially if you are
> exec-ing git from another program and want to avoid the shell entirely
> for quoting reasons).
When I want to run "git log" for a repository outside the cwd, I do
use --git-dir (or more precisely,
$ GIT_DIR=$HOME/src/git/.git git log
), which works.
The "sometimes you just want to pass a command to 'exec'" use case
does not convince me. I equally well might want to run "git" after
another command, or run "git" if and only if a repository exists
there, or do any number of other things. If someone asked me how to
do that by passing a command to 'exec', I'd point them to
sh -c 'cd foo && git ...'
as a way to answer all such questions at the same time. So we're left
with "--git-dir does not automatically append .git when appropriate"
as the problem being solved, which is a real problem. Maybe that is
worth fixing more directly?
It might also be convenient to be able to do something like
git --git-dir=~/src/git log -- Documentation/
which this -C option makes easy. *checks* Actually it works without,
but for subtle reasons. A more sensible way to spell that is
git --git-dir=<wherever> -- :/Documentation/
which works fine.
All that said, I don't mind -C terribly as long as it can maintain
itself, which means including thorough documentation that covers the
purpose and how pathname parameters and envvars interact with the new
option and including tests under t/ to ensure it continues to work
correctly in the future.
Thanks for an interesting patch, and hope that helps,
Jonathan
next prev parent reply other threads:[~2013-04-20 22:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 12:21 [PATCH] Teach git to change to a given directory using -C option Nazri Ramliy
2013-04-19 16:12 ` Jeff King
2013-04-20 22:18 ` Jonathan Nieder [this message]
2013-04-21 3:58 ` Jeff King
2013-04-21 13:48 ` Nazri Ramliy
-- strict thread matches above, loose matches on Subject: below --
2013-08-30 13:35 Nazri Ramliy
2013-09-01 4:48 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130420221752.GA9980@elie.Belkin \
--to=jrnieder@gmail.com \
--cc=ayiehere@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).