{"thread":{"id":"40718","subject":"[PATCH 0/1] gitk: add --cwd=path commandline parameter to change path","startedAt":"2015-11-03T15:00:41Z","lastAt":"2015-12-19T03:13:32Z","messageCount":8,"participants":["Juha-Pekka Heikkila","Eric Sunshine","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"272833","messageId":"1446562842-8478-1-git-send-email-juhapekka.heikkila@gmail.com","threadId":"40718","inReplyTo":null,"subject":"[PATCH 0/1] gitk: add --cwd=path commandline parameter to change path","fromName":"Juha-Pekka Heikkila","fromEmail":"juhapekka.heikkila@gmail.com","sentAt":"2015-11-03T15:00:41Z","receivedAt":"2015-11-03T15:00:41Z","isPatch":true,"sender":{"key":"juhapekka.heikkila@gmail.com","avatar":"https://gravatar.com/avatar/3ee96af8d37aa9c8056c9461867ebc8d0955b74c6701105419d75916086c6b54?d=mp&s=160"},"body":"I found I needed this option thus made it for myself, maybe others find it \nuseful too. I'm not skilled with tcl so if there is something totally wrong \nwith my change this is why.\n\n/Juha-Pekka\n\nJuha-Pekka Heikkila (1):\n  gitk: add --cwd=path commandline parameter to change path\n\n Documentation/gitk.txt |  5 +++++\n gitk-git/gitk          | 15 +++++++++------\n 2 files changed, 14 insertions(+), 6 deletions(-)\n\n-- \n1.9.1\n"},{"id":"272834","messageId":"1446562842-8478-2-git-send-email-juhapekka.heikkila@gmail.com","threadId":"40718","inReplyTo":"1446562842-8478-1-git-send-email-juhapekka.heikkila@gmail.com","subject":"[PATCH 1/1] gitk: add --cwd=path commandline parameter to change path","fromName":"Juha-Pekka Heikkila","fromEmail":"juhapekka.heikkila@gmail.com","sentAt":"2015-11-03T15:00:42Z","receivedAt":"2015-11-03T15:00:42Z","isPatch":true,"sender":{"key":"juhapekka.heikkila@gmail.com","avatar":"https://gravatar.com/avatar/3ee96af8d37aa9c8056c9461867ebc8d0955b74c6701105419d75916086c6b54?d=mp&s=160"},"body":"This patch adds --cwd (change working directory) parameter to\ngitk. With this parameter, instead of need to cd to directory\nwith .git folder, one can point the correct folder from\ncommandline.\n\nSigned-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n---\n Documentation/gitk.txt |  5 +++++\n gitk-git/gitk          | 15 +++++++++------\n 2 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\nindex 6ade002..1f42198 100644\n--- a/Documentation/gitk.txt\n+++ b/Documentation/gitk.txt\n@@ -146,6 +146,11 @@ gitk-specific options\n \tSelect the specified commit after loading the graph.\n \tDefault behavior is equivalent to specifying '--select-commit=HEAD'.\n \n+--cwd=<path>::\n+\n+\tChange working direcoty to <path>. If the git tree exist elsewhere\n+\tgitk first cd to given path before start to operate.\n+\n Examples\n --------\n gitk v2.6.12.. include/scsi drivers/scsi::\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex fcc606e..5fdf459 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -12279,12 +12279,6 @@ setui $uicolor\n \n setoptions\n \n-# check that we can find a .git directory somewhere...\n-if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n-    show_error {} . [mc \"Cannot find a git repository here.\"]\n-    exit 1\n-}\n-\n set selecthead {}\n set selectheadid {}\n \n@@ -12305,6 +12299,9 @@ foreach arg $argv {\n \t\"--argscmd=*\" {\n \t    set revtreeargscmd [string range $arg 10 end]\n \t}\n+\t\"--cwd=*\" {\n+\t    cd [string range $arg 6 end]\n+\t}\n \tdefault {\n \t    lappend revtreeargs $arg\n \t}\n@@ -12312,6 +12309,12 @@ foreach arg $argv {\n     incr i\n }\n \n+# check that we can find a .git directory somewhere...\n+if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n+    show_error {} . [mc \"Cannot find a git repository here.\"]\n+    exit 1\n+}\n+\n if {$selecthead eq \"HEAD\"} {\n     set selecthead {}\n }\n-- \n1.9.1\n"},{"id":"272842","messageId":"CAPig+cSs0v88AiQwSrqm-wK7rY4RdykaVf5Axh5jFyij25rfvg@mail.gmail.com","threadId":"40718","inReplyTo":"1446562842-8478-2-git-send-email-juhapekka.heikkila@gmail.com","subject":"Re: [PATCH 1/1] gitk: add --cwd=path commandline parameter to change path","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-03T18:27:00Z","receivedAt":"2015-11-03T18:27:00Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Nov 3, 2015 at 10:00 AM, Juha-Pekka Heikkila\n<juhapekka.heikkila@gmail.com> wrote:\n> This patch adds --cwd (change working directory) parameter to\n> gitk. With this parameter, instead of need to cd to directory\n> with .git folder, one can point the correct folder from\n> commandline.\n\ngit itself supports this sort of functionality via -C, as does GNU\ntar, which suggests such an option in gitk should be named -C, as\nwell.\n\n> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n> ---\n> diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\n> @@ -146,6 +146,11 @@ gitk-specific options\n>         Select the specified commit after loading the graph.\n>         Default behavior is equivalent to specifying '--select-commit=HEAD'.\n>\n> +--cwd=<path>::\n> +\n> +       Change working direcoty to <path>. If the git tree exist elsewhere\n\ns/direcoty/directory/\n\n> +       gitk first cd to given path before start to operate.\n\nTaking git's -C documentation as a template, perhaps this could be\nwritten instead as:\n\n    Run as if gitk was started in '<path>' instead of the current\n    working directory. When multiple `-C` options are given, each\n    subsequent non-absolute `-C <path>` is interpreted relative to\n    the preceding `-C <path>`.\n\nThis description correctly reflects your implementation which allows\n--cwd to be specified multiple times.\n\n>  Examples\n>  --------\n>  gitk v2.6.12.. include/scsi drivers/scsi::\n> diff --git a/gitk-git/gitk b/gitk-git/gitk\n> index fcc606e..5fdf459 100755\n> --- a/gitk-git/gitk\n> +++ b/gitk-git/gitk\n> @@ -12279,12 +12279,6 @@ setui $uicolor\n>\n>  setoptions\n>\n> -# check that we can find a .git directory somewhere...\n> -if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n> -    show_error {} . [mc \"Cannot find a git repository here.\"]\n> -    exit 1\n> -}\n> -\n>  set selecthead {}\n>  set selectheadid {}\n>\n> @@ -12305,6 +12299,9 @@ foreach arg $argv {\n>         \"--argscmd=*\" {\n>             set revtreeargscmd [string range $arg 10 end]\n>         }\n> +       \"--cwd=*\" {\n> +           cd [string range $arg 6 end]\n> +       }\n>         default {\n>             lappend revtreeargs $arg\n>         }\n> @@ -12312,6 +12309,12 @@ foreach arg $argv {\n>      incr i\n>  }\n>\n> +# check that we can find a .git directory somewhere...\n> +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n> +    show_error {} . [mc \"Cannot find a git repository here.\"]\n> +    exit 1\n> +}\n> +\n>  if {$selecthead eq \"HEAD\"} {\n>      set selecthead {}\n>  }\n> --\n> 1.9.1\n"},{"id":"272951","messageId":"1446715164-19165-1-git-send-email-juhapekka.heikkila@gmail.com","threadId":"40718","inReplyTo":"CAPig+cSs0v88AiQwSrqm-wK7rY4RdykaVf5Axh5jFyij25rfvg@mail.gmail.com","subject":"[PATCH v2] gitk: add -C <path> commandline parameter to change path","fromName":"Juha-Pekka Heikkila","fromEmail":"juhapekka.heikkila@gmail.com","sentAt":"2015-11-05T09:19:24Z","receivedAt":"2015-11-05T09:19:24Z","isPatch":true,"sender":{"key":"juhapekka.heikkila@gmail.com","avatar":"https://gravatar.com/avatar/3ee96af8d37aa9c8056c9461867ebc8d0955b74c6701105419d75916086c6b54?d=mp&s=160"},"body":"This patch adds -C (change working directory) parameter to\ngitk. With this parameter, instead of need to cd to directory\nwith .git folder, one can point the correct folder from\ncommandline.\n\nv2: Adjusted the parameter as per Eric's suggestion. I think\n    it now work in similar manner as in many GNU tools as well\n    as git itself.\n\nSigned-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n---\n Documentation/gitk.txt |  7 +++++++\n gitk-git/gitk          | 26 +++++++++++++++++---------\n 2 files changed, 24 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\nindex 6ade002..d194d9b 100644\n--- a/Documentation/gitk.txt\n+++ b/Documentation/gitk.txt\n@@ -146,6 +146,13 @@ gitk-specific options\n \tSelect the specified commit after loading the graph.\n \tDefault behavior is equivalent to specifying '--select-commit=HEAD'.\n \n+-C <path>::\n+\n+\tRun as if gitk was started in '<path>' instead of the current\n+\tworking directory. When multiple `-C` options are given, each\n+\tsubsequent non-absolute `-C <path>` is interpreted relative to\n+\tthe preceding `-C <path>`.\n+\n Examples\n --------\n gitk v2.6.12.. include/scsi drivers/scsi::\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex fcc606e..606474a 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -12279,20 +12279,14 @@ setui $uicolor\n \n setoptions\n \n-# check that we can find a .git directory somewhere...\n-if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n-    show_error {} . [mc \"Cannot find a git repository here.\"]\n-    exit 1\n-}\n-\n set selecthead {}\n set selectheadid {}\n \n set revtreeargs {}\n set cmdline_files {}\n-set i 0\n set revtreeargscmd {}\n-foreach arg $argv {\n+for {set i 0} {$i < [llength $argv]} {incr i} {\n+\tset arg [lindex $argv [expr {$i}]]\n     switch -glob -- $arg {\n \t\"\" { }\n \t\"--\" {\n@@ -12305,11 +12299,25 @@ foreach arg $argv {\n \t\"--argscmd=*\" {\n \t    set revtreeargscmd [string range $arg 10 end]\n \t}\n+\t\"-C*\" {\n+\t\tif {[string length $arg] < 3} {\n+\t\t\tincr i\n+\t\t\tcd [lindex $argv [expr {$i}]]\n+\t\t\tcontinue\n+\t\t} else {\n+\t\t\tcd [string range $arg 2 end]\n+\t\t}\n+\t}\n \tdefault {\n \t    lappend revtreeargs $arg\n \t}\n     }\n-    incr i\n+}\n+\n+# check that we can find a .git directory somewhere...\n+if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n+    show_error {} . [mc \"Cannot find a git repository here.\"]\n+    exit 1\n }\n \n if {$selecthead eq \"HEAD\"} {\n-- \n1.9.1\n"},{"id":"273004","messageId":"CAPig+cT9K2H_jzVNOHS0vaarU+tfDfp_=Z4c1n6o5EX9wE6JXA@mail.gmail.com","threadId":"40718","inReplyTo":"1446715164-19165-1-git-send-email-juhapekka.heikkila@gmail.com","subject":"Re: [PATCH v2] gitk: add -C <path> commandline parameter to change path","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-06T09:48:02Z","receivedAt":"2015-11-06T09:48:02Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Nov 5, 2015 at 4:19 AM, Juha-Pekka Heikkila\n<juhapekka.heikkila@gmail.com> wrote:\n> This patch adds -C (change working directory) parameter to\n> gitk. With this parameter, instead of need to cd to directory\n> with .git folder, one can point the correct folder from\n> commandline.\n\nThanks, -C makes more sense than --cwd, and is more consistent with\nother commands.\n\nYou'll want to also address the patch to Paul Mackerras (I've cc:'d\nhim) since he's the gitk maintainer, and Junio pulls gitk from him.\n\n> v2: Adjusted the parameter as per Eric's suggestion. I think\n>     it now work in similar manner as in many GNU tools as well\n>     as git itself.\n\nThis sort of explanation of of changes between versions is definitely\nwelcome, but should be placed below the \"---\" line just under your\nsign-off so that it does not become part of the permanent commit\nmessage.\n\n> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n> ---\n\nYou'd place your commentary about changes between patch versions here.\nMore below...\n\n>  Documentation/gitk.txt |  7 +++++++\n>  gitk-git/gitk          | 26 +++++++++++++++++---------\n>  2 files changed, 24 insertions(+), 9 deletions(-)\n>\n> diff --git a/gitk-git/gitk b/gitk-git/gitk\n> @@ -12279,20 +12279,14 @@ setui $uicolor\n>\n>  setoptions\n>\n> -# check that we can find a .git directory somewhere...\n> -if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n> -    show_error {} . [mc \"Cannot find a git repository here.\"]\n> -    exit 1\n> -}\n> -\n>  set selecthead {}\n>  set selectheadid {}\n>\n>  set revtreeargs {}\n>  set cmdline_files {}\n> -set i 0\n>  set revtreeargscmd {}\n> -foreach arg $argv {\n> +for {set i 0} {$i < [llength $argv]} {incr i} {\n> +       set arg [lindex $argv [expr {$i}]]\n>      switch -glob -- $arg {\n>         \"\" { }\n>         \"--\" {\n> @@ -12305,11 +12299,25 @@ foreach arg $argv {\n>         \"--argscmd=*\" {\n>             set revtreeargscmd [string range $arg 10 end]\n>         }\n> +       \"-C*\" {\n> +               if {[string length $arg] < 3} {\n> +                       incr i\n> +                       cd [lindex $argv [expr {$i}]]\n\nWhat happens if no arguments follow -C (that is, the entire\ncommand-line is \"gitk -C\")? Will this simply run \"cd\" with no argument\nor with an empty argument or error out or what? Should there be a\ncheck for this condition?\n\n> +                       continue\n\nWhy does this 'continue' need to be here? Am I missing something obvious?\n\n> +               } else {\n> +                       cd [string range $arg 2 end]\n> +               }\n> +       }\n>         default {\n>             lappend revtreeargs $arg\n>         }\n>      }\n> -    incr i\n> +}\n> +\n> +# check that we can find a .git directory somewhere...\n> +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n> +    show_error {} . [mc \"Cannot find a git repository here.\"]\n> +    exit 1\n>  }\n>\n>  if {$selecthead eq \"HEAD\"} {\n> --\n> 1.9.1\n"},{"id":"273006","messageId":"563C85C5.80703@gmail.com","threadId":"40718","inReplyTo":"CAPig+cT9K2H_jzVNOHS0vaarU+tfDfp_=Z4c1n6o5EX9wE6JXA@mail.gmail.com","subject":"Re: [PATCH v2] gitk: add -C <path> commandline parameter to change path","fromName":"Juha-Pekka Heikkila","fromEmail":"juhapekka.heikkila@gmail.com","sentAt":"2015-11-06T10:49:41Z","receivedAt":"2015-11-06T10:49:41Z","isPatch":true,"sender":{"key":"juhapekka.heikkila@gmail.com","avatar":"https://gravatar.com/avatar/3ee96af8d37aa9c8056c9461867ebc8d0955b74c6701105419d75916086c6b54?d=mp&s=160"},"body":"On 06.11.2015 11:48, Eric Sunshine wrote:\n> On Thu, Nov 5, 2015 at 4:19 AM, Juha-Pekka Heikkila\n> <juhapekka.heikkila@gmail.com> wrote:\n>> This patch adds -C (change working directory) parameter to\n>> gitk. With this parameter, instead of need to cd to directory\n>> with .git folder, one can point the correct folder from\n>> commandline.\n>\n> Thanks, -C makes more sense than --cwd, and is more consistent with\n> other commands.\n>\n> You'll want to also address the patch to Paul Mackerras (I've cc:'d\n> him) since he's the gitk maintainer, and Junio pulls gitk from him.\n>\n>> v2: Adjusted the parameter as per Eric's suggestion. I think\n>>      it now work in similar manner as in many GNU tools as well\n>>      as git itself.\n>\n> This sort of explanation of of changes between versions is definitely\n> welcome, but should be placed below the \"---\" line just under your\n> sign-off so that it does not become part of the permanent commit\n> message.\n\nOk, I'll make bit later another version. I didn't realize to check where \nto put this comment as some projects want these in the commit message.\n\n>\n>> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n>> ---\n>\n> You'd place your commentary about changes between patch versions here.\n> More below...\n>\n>>   Documentation/gitk.txt |  7 +++++++\n>>   gitk-git/gitk          | 26 +++++++++++++++++---------\n>>   2 files changed, 24 insertions(+), 9 deletions(-)\n>>\n>> diff --git a/gitk-git/gitk b/gitk-git/gitk\n>> @@ -12279,20 +12279,14 @@ setui $uicolor\n>>\n>>   setoptions\n>>\n>> -# check that we can find a .git directory somewhere...\n>> -if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n>> -    show_error {} . [mc \"Cannot find a git repository here.\"]\n>> -    exit 1\n>> -}\n>> -\n>>   set selecthead {}\n>>   set selectheadid {}\n>>\n>>   set revtreeargs {}\n>>   set cmdline_files {}\n>> -set i 0\n>>   set revtreeargscmd {}\n>> -foreach arg $argv {\n>> +for {set i 0} {$i < [llength $argv]} {incr i} {\n>> +       set arg [lindex $argv [expr {$i}]]\n>>       switch -glob -- $arg {\n>>          \"\" { }\n>>          \"--\" {\n>> @@ -12305,11 +12299,25 @@ foreach arg $argv {\n>>          \"--argscmd=*\" {\n>>              set revtreeargscmd [string range $arg 10 end]\n>>          }\n>> +       \"-C*\" {\n>> +               if {[string length $arg] < 3} {\n>> +                       incr i\n>> +                       cd [lindex $argv [expr {$i}]]\n>\n> What happens if no arguments follow -C (that is, the entire\n> command-line is \"gitk -C\")? Will this simply run \"cd\" with no argument\n> or with an empty argument or error out or what? Should there be a\n> check for this condition?\n>\n>> +                       continue\n>\n> Why does this 'continue' need to be here? Am I missing something obvious?\n>\n\nI'll add the missing try/catch for these cd commands, I slowly start to \nunderstand how tcl work. Earlier catch was not for some reason needed \nhere when the loop was ran with 'foreach', error was reported once \nreached UI but now it seem to advertise \"error in startup script..\" \n'continue' was part of this skipping but doesn't do its trick anymore.\n\nAnyway, I'll make v3 and resend. :)\n\n>> +               } else {\n>> +                       cd [string range $arg 2 end]\n>> +               }\n>> +       }\n>>          default {\n>>              lappend revtreeargs $arg\n>>          }\n>>       }\n>> -    incr i\n>> +}\n>> +\n>> +# check that we can find a .git directory somewhere...\n>> +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n>> +    show_error {} . [mc \"Cannot find a git repository here.\"]\n>> +    exit 1\n>>   }\n>>\n>>   if {$selecthead eq \"HEAD\"} {\n>> --\n>> 1.9.1\n"},{"id":"273077","messageId":"1447069522-19895-1-git-send-email-juhapekka.heikkila@gmail.com","threadId":"40718","inReplyTo":"563C85C5.80703@gmail.com","subject":"[PATCH v3] gitk: add -C <path> commandline parameter to change path","fromName":"Juha-Pekka Heikkila","fromEmail":"juhapekka.heikkila@gmail.com","sentAt":"2015-11-09T11:45:22Z","receivedAt":"2015-11-09T11:45:22Z","isPatch":true,"sender":{"key":"juhapekka.heikkila@gmail.com","avatar":"https://gravatar.com/avatar/3ee96af8d37aa9c8056c9461867ebc8d0955b74c6701105419d75916086c6b54?d=mp&s=160"},"body":"This patch adds -C (change working directory) parameter to\ngitk. With this parameter, instead of need to cd to directory\nwith .git folder, one can point the correct folder from\ncommandline.\n\nSigned-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n\n---\nv2: Adjusted the parameter as per Eric's suggestion. I think\n    it now work in similar manner as in many GNU tools as well\n    as git itself.\n\nv3: catch error from cd and other small refinement.\n\n Documentation/gitk.txt |  7 +++++++\n gitk-git/gitk          | 30 +++++++++++++++++++++---------\n 2 files changed, 28 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/gitk.txt b/Documentation/gitk.txt\nindex 6ade002..d194d9b 100644\n--- a/Documentation/gitk.txt\n+++ b/Documentation/gitk.txt\n@@ -146,6 +146,13 @@ gitk-specific options\n \tSelect the specified commit after loading the graph.\n \tDefault behavior is equivalent to specifying '--select-commit=HEAD'.\n \n+-C <path>::\n+\n+\tRun as if gitk was started in '<path>' instead of the current\n+\tworking directory. When multiple `-C` options are given, each\n+\tsubsequent non-absolute `-C <path>` is interpreted relative to\n+\tthe preceding `-C <path>`.\n+\n Examples\n --------\n gitk v2.6.12.. include/scsi drivers/scsi::\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex fcc606e..a7076f8 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -12279,20 +12279,14 @@ setui $uicolor\n \n setoptions\n \n-# check that we can find a .git directory somewhere...\n-if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n-    show_error {} . [mc \"Cannot find a git repository here.\"]\n-    exit 1\n-}\n-\n set selecthead {}\n set selectheadid {}\n \n set revtreeargs {}\n set cmdline_files {}\n-set i 0\n set revtreeargscmd {}\n-foreach arg $argv {\n+for {set i 0} {$i < [llength $argv]} {incr i} {\n+\tset arg [lindex $argv [expr {$i}]]\n     switch -glob -- $arg {\n \t\"\" { }\n \t\"--\" {\n@@ -12305,11 +12299,29 @@ foreach arg $argv {\n \t\"--argscmd=*\" {\n \t    set revtreeargscmd [string range $arg 10 end]\n \t}\n+\t\"-C*\" {\n+\t\tif {[string length $arg] < 3} {\n+\t\t\tincr i\n+\t\t\tset cwd_path [lindex $argv [expr {$i}]]\n+\t\t} else {\n+\t\t\tset cwd_path [string range $arg 2 end]\n+\t\t}\n+\n+\t\tif {[catch {cd $cwd_path}]} {\n+\t\t\tshow_error {} . [mc \"Cannot change directory to '%s'\" $cwd_path]\n+\t\t\texit 1\n+\t\t}\n+\t}\n \tdefault {\n \t    lappend revtreeargs $arg\n \t}\n     }\n-    incr i\n+}\n+\n+# check that we can find a .git directory somewhere...\n+if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {\n+    show_error {} . [mc \"Cannot find a git repository here.\"]\n+    exit 1\n }\n \n if {$selecthead eq \"HEAD\"} {\n-- \n1.9.1\n"},{"id":"274743","messageId":"20151219031332.GE422@fergus.ozlabs.ibm.com","threadId":"40718","inReplyTo":"1447069522-19895-1-git-send-email-juhapekka.heikkila@gmail.com","subject":"Re: [PATCH v3] gitk: add -C <path> commandline parameter to change path","fromName":"Paul Mackerras","fromEmail":"paulus@ozlabs.org","sentAt":"2015-12-19T03:13:32Z","receivedAt":"2015-12-19T03:13:32Z","isPatch":true,"sender":{"key":"paulus@ozlabs.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Mon, Nov 09, 2015 at 01:45:22PM +0200, Juha-Pekka Heikkila wrote:\n> This patch adds -C (change working directory) parameter to\n> gitk. With this parameter, instead of need to cd to directory\n> with .git folder, one can point the correct folder from\n> commandline.\n> \n> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>\n\nThanks.\n\nWhile I like the idea, there are a couple of minor problems with the\npatch.  First, the Documentation directory is in Junio's tree, not\nmine, so the change to gitk and the change to Documentation need to be\nseparated.  Secondly, please use 4-space indentation rather than\n8-space for consistency with the rest of the file.  See also the\ncomments below.\n\n> +\t\"-C*\" {\n> +\t\tif {[string length $arg] < 3} {\n> +\t\t\tincr i\n> +\t\t\tset cwd_path [lindex $argv [expr {$i}]]\n\nNo need to say [expr {$i}] here; [lindex $argv $i] works just fine.\n\nAlso, if i is now >= [llength $argv], we'll get an empty string in\ncwd_path.  Is that what you meant?  Shouldn't we display an\nappropriate error message instead of trying to cd to \"\"?\n\nPaul.\n"}]}