git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] -C/--chdir command line option

From
Maciej Pasternacki <maciej@pasternacki.net>
Date
Oct 19, 2008, 15:24 UTC
Message-ID
<81E9D278-4851-4B1E-BE7D-D8563CEDA6F9@pasternacki.net>
In-Reply-To
<20081019141634.GA8997@coredump.intra.peff.net>
On 2008-10-19, at 16:16, Jeff King wrote:
Show 6 quoted lines
> Though I am not clear from your original description if that is even
> what you want. It sounds like you might be doing:
>
>  git -C /chdir/path --git-dir=/back/to/where/I/was
>
> in which case I think work-tree _is_ a better fit.

No. I have a regular "git clone"'d work tree inside some "shelf" directory containing many repos (not only from git), and I'd like to pull changes into this work tree. As simple as "cvs up". But -- I don't want to chdir() there myself, and I had no problem with cvs, svn and darcs (didn't do other VC systems yet). So, -C would do exactly what I need.

Show 22 quoted lines
>>> Also, the envchanged flag should probably be set, as for the git-dir
>>> and work-tree options.
>>
>> OK.  I thought it means literally environment change, as in setenv().
>
> It is really used to tell the options parser for aliases that some
> options which change the operating environment should not be used in  
> an
> alias. I.e., something like:
>
>  git config alias.foo "--git-dir=/path/to/whatever log"
>
> isn't allowed, because we have already done some work on setting up  
> the
> git-dir at this point. IMHO, this is a limitation of the current
> approach to setting up the environment, but fixing it would be
> nontrivial.
>
> I'm not 100% sure that doing a chdir should be disallowed in this
> instance, but I suspect it would cause problems. I think it is  
> better in
> this instance to be conservative and disallow it in aliases.

In this case, I think envchanged should not be set -- I would expect - C dir to work *exactly* like "cd dir && git ...", including configuration, environment variables and so on. OTOH, option like "-- no-env" may be useful in my case -- I want git to behave consistently on users' machines, regardless of their configuration. This, however, is only a minor issue.

Regards, Maciej.

-- 
-><- Maciej Pasternacki -><- http://www.pasternacki.net/ -><-
Previous: Jeff KingNext: Junio C Hamano
Message 5 of 10 in “-C/--chdir command line option”
  1. -C/--chdir command line optionMaciej Pasternacki, Oct 19, 2008
  2. Jeff KingOct 19, 2008
  3. Maciej PasternackiOct 19, 2008
  4. Jeff KingOct 19, 2008
  5. Maciej PasternackiOct 19, 2008
  6. Junio C HamanoOct 20, 2008
  7. Junio C HamanoOct 20, 2008
  8. Alex RiesenOct 20, 2008
  9. Michael J GruberOct 20, 2008
  10. Nguyen Thai Ngoc DuyOct 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.