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.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com>
---
 Documentation/gitk.txt |  5 +++++
 gitk-git/gitk          | 15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 6ade002..1f42198 100644
--- 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
+       gitk first cd to given path before start to operate.
+
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to