Re: [PATCH] git-gui: run post-checkout hook on checkout
- From
Jens Lehmann <jens.lehmann@web.de>
- Date
- Mar 30, 2009, 20:00 UTC
- Message-ID
- <49D124E6.8010206@web.de>
- In-Reply-To
- <20090330143435.GA23521@spearce.org>
Shawn O. Pearce schrieb:
Show 10 quoted lines
> Jens Lehmann <Jens.Lehmann@web.de> wrote:
>> + # -- Run the post-checkout hook.
>> + #
>> + set fd_ph [githook_read post-checkout $old_hash $new_hash 1]
>> + if {$fd_ph ne {}} {
>> + upvar #0 pch_error pc_err
>
> I'd rather spell this "global pch_error".
>
>> + set pc_err {}What i noticed when fixing this issue is that i copied this upvar statement from the calling of the post-commit hook in commit.tcl with only a minor change (ommitting the "$cmt_id" behind "pch_error").
It does seem to be incorrect there too, as i couldn't find any use of the variable "pc_err" or "pch_error$cmt_id" anywhere in git-gui. So setting "pc_err" to empty seems pretty pointless, as everywhere else in commit.tcl "pch_error" is used instead.
Or am i overlooking something? If not, the patch below should correct that.
Jens
--------------------- 8>< ---------------------
>From 5ddd7e8c2d52fc99e496ed3bc96358cc07e538f1 Mon Sep 17 00:00:00 2001
From: Jens Lehmann <Jens.Lehmann@web.de> Date: Mon, 30 Mar 2009 20:35:57 +0200 Subject: [PATCH] git-gui: When calling post-commit hook wrong variable was cleared.
Before calling the post-commit hook, the variable "pc_err" is cleared while later only "pch_error" is used. "pch_error$cmt_id" only appeared in "upvar"-Statements (which were changed to "global") and was removed.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> --- git-gui/lib/commit.tcl | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl index 9cc8410..7255efb 100644 --- a/git-gui/lib/commit.tcl +++ b/git-gui/lib/commit.tcl @@ -398,8 +398,8 @@ A rescan will be automatically started now. # set fd_ph [githook_read post-commit] if {$fd_ph ne {}} { - upvar #0 pch_error$cmt_id pc_err - set pc_err {} + global pch_error + set pch_error {} fconfigure $fd_ph -blocking 0 -translation binary -eofchar {} fileevent $fd_ph readable \ [list commit_postcommit_wait $fd_ph $cmt_id] @@ -461,7 +461,7 @@ A rescan will be automatically started now. } proc commit_postcommit_wait {fd_ph cmt_id} { - upvar #0 pch_error$cmt_id pch_error + global pch_error append pch_error [read $fd_ph] fconfigure $fd_ph -blocking 1
-- 1.6.2.1.414.g2daa3