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

Re: [PATCH 1/1] gitk: add --cwd=path commandline parameter to change path

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Nov 3, 2015, 18:27 UTC
Message-ID
<CAPig+cSs0v88AiQwSrqm-wK7rY4RdykaVf5Axh5jFyij25rfvg@mail.gmail.com>
In-Reply-To
<1446562842-8478-2-git-send-email-juhapekka.heikkila@gmail.com>

On Tue, Nov 3, 2015 at 10:00 AM, Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> wrote:

> This patch adds --cwd (change working directory) parameter to
> gitk. With this parameter, instead of need to cd to directory
> with .git folder, one can point the correct folder from
> commandline.

git itself supports this sort of functionality via -C, as does GNU tar, which suggests such an option in gitk should be named -C, as well.

Show 10 quoted lines
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
> ---
> diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
> @@ -146,6 +146,11 @@ gitk-specific options
>         Select the specified commit after loading the graph.
>         Default behavior is equivalent to specifying '--select-commit=HEAD'.
>
> +--cwd=<path>::
> +
> +       Change working direcoty to <path>. If the git tree exist elsewhere
s/direcoty/directory/
> +       gitk first cd to given path before start to operate.

Taking git's -C documentation as a template, perhaps this could be written instead as:

    Run as if gitk 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 description correctly reflects your implementation which allows --cwd to be specified multiple times.

Show 45 quoted lines
>  Examples
>  --------
>  gitk v2.6.12.. include/scsi drivers/scsi::
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index fcc606e..5fdf459 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -12279,12 +12279,6 @@ setui $uicolor
>
>  setoptions
>
> -# check that we can find a .git directory somewhere...
> -if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {
> -    show_error {} . [mc "Cannot find a git repository here."]
> -    exit 1
> -}
> -
>  set selecthead {}
>  set selectheadid {}
>
> @@ -12305,6 +12299,9 @@ foreach arg $argv {
>         "--argscmd=*" {
>             set revtreeargscmd [string range $arg 10 end]
>         }
> +       "--cwd=*" {
> +           cd [string range $arg 6 end]
> +       }
>         default {
>             lappend revtreeargs $arg
>         }
> @@ -12312,6 +12309,12 @@ foreach arg $argv {
>      incr i
>  }
>
> +# check that we can find a .git directory somewhere...
> +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {
> +    show_error {} . [mc "Cannot find a git repository here."]
> +    exit 1
> +}
> +
>  if {$selecthead eq "HEAD"} {
>      set selecthead {}
>  }
> --
> 1.9.1
Previous: Juha-Pekka HeikkilaNext: Juha-Pekka Heikkila
Message 3 of 8 in “gitk: add --cwd=path commandline parameter to change path”
  1. 0/1 gitk: add --cwd=path commandline parameter to change pathJuha-Pekka Heikkila, Nov 3, 2015
  2. 1/1 gitk: add --cwd=path commandline parameter to change pathJuha-Pekka Heikkila, Nov 3, 2015
  3. Eric SunshineNov 3, 2015
  4. gitk: add -C <path> commandline parameter to change pathJuha-Pekka Heikkila, Nov 5, 2015
  5. Eric SunshineNov 6, 2015
  6. Juha-Pekka HeikkilaNov 6, 2015
  7. gitk: add -C <path> commandline parameter to change pathJuha-Pekka Heikkila, Nov 9, 2015
  8. Paul MackerrasDec 19, 2015

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.