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

Re: [PATCH v3] Teach git to change to a given directory using -C option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 8, 2013, 10:32 UTC
Message-ID
<CAPig+cRt9o=6Amhx6qTkzfk5R9aQfRZ=357BOVELm_hPsWE3WQ@mail.gmail.com>
In-Reply-To
<20130904122020.GA25538@gmail.com>
On Wed, Sep 4, 2013 at 8:20 AM, Nazri Ramliy <ayiehere@gmail.com> wrote:
Show 17 quoted lines
> Subject: git: run in a directory given with -C option
>
> This is similar in spirit to to "make -C dir ..." and "tar -C dir ...".
> ---
> diff --git a/Documentation/git.txt b/Documentation/git.txt
> index 83edf30..ae049da 100644
> --- a/Documentation/git.txt
> +++ b/Documentation/git.txt
> @@ -395,6 +395,20 @@ displayed. See linkgit:git-help[1] for more information,
>  because `git --help ...` is converted internally into `git
>  help ...`.
>
> +-C <path>::
> +       Run as if git was started in <path> instead of the current working
> +       directory.  When multiple -C options are given, each subsequent
> +       non-absolute "-C <path>" is interpreted relative to the preceding "-C
> +       <path>".

For consistency with existing formatting in git.txt, you may want to squash in the following fixes (sans gmail whitespace damage):

--- >8 ---
diff --git a/Documentation/git.txt b/Documentation/git.txt
index ae049da..6622037 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -396,14 +396,14 @@ because `git --help ...` is converted internally into `git
 help ...`.

 -C <path>::
- Run as if git was started in <path> instead of the current working
- directory.  When multiple -C options are given, each subsequent
- non-absolute "-C <path>" is interpreted relative to the preceding "-C
- <path>".
+ Run as if git was started in '<path>' instead of the current working
+ directory.  When multiple '-C' options are given, each subsequent
+ non-absolute `-C <path>` is interpreted relative to the preceding `-C
+ <path>`.
 +
-This option affects options that expect path name like --git-dir and
---work-tree in that their interpretations of the path names would be
-made relative to the working directory caused by the -C option. For
+This option affects options that expect path name like '--git-dir' and
+'--work-tree' in that their interpretations of the path names would be
+made relative to the working directory caused by the '-C' option. For
 example the following invocations are equivalent:

     git --git-dir=a.git --work-tree=b -C c status
--- >8 ---

> +This option affects options that expect path name like --git-dir and
> +--work-tree in that their interpretations of the path names would be
> +made relative to the working directory caused by the -C option. For
> +example the following invocations are equivalent:
> +
> +    git --git-dir=a.git --work-tree=b -C c status
> +    git --git-dir=c/a.git --work-tree=c/b status

Is the interaction of -C with --work-tree and --git-dir desirable or
useful? (I'm genuinely curious.) Do you have use-cases in mind? Would
mentioning them in the commit message help to justify the interaction?
Previous: Nazri RamliyNext: Nazri Ramliy
Message 7 of 14 in “Teach git to change to a given directory using -C option”
  1. Teach git to change to a given directory using -C optionNazri Ramliy, Sep 3, 2013
  2. Junio C HamanoSep 3, 2013
  3. Eric SunshineSep 3, 2013
  4. Nazri RamliySep 4, 2013
  5. Eric SunshineSep 4, 2013
  6. Nazri RamliySep 4, 2013
  7. Eric SunshineSep 8, 2013
  8. Nazri RamliySep 9, 2013
  9. Eric SunshineSep 9, 2013
  10. Nazri RamliySep 9, 2013
  11. Junio C HamanoSep 9, 2013
  12. Eric SunshineSep 9, 2013
  13. Junio C HamanoSep 9, 2013
  14. Eric SunshineSep 9, 2013

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.