Skip to content

Commit b4c813b

Browse files
jlehmannspearce
authored andcommitted
git-gui: run post-checkout hook after clone
git-gui is using "git-read-tree -u" when cloning which doesn't invoke the post-checkout hook as a plain git-clone would. So git-gui must call the hook itself. Signed-off-by: Jens Lehmann <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 4339d51 commit b4c813b

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib/choose_repository.tcl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,34 @@ method _readtree_wait {fd} {
966966
return
967967
}
968968

969-
set done 1
969+
# -- Run the post-checkout hook.
970+
#
971+
set fd_ph [githook_read post-checkout [string repeat 0 40] \
972+
[git rev-parse HEAD] 1]
973+
if {$fd_ph ne {}} {
974+
global pch_error
975+
set pch_error {}
976+
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
977+
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
978+
} else {
979+
set done 1
980+
}
981+
}
982+
983+
method _postcheckout_wait {fd_ph} {
984+
global pch_error
985+
986+
append pch_error [read $fd_ph]
987+
fconfigure $fd_ph -blocking 1
988+
if {[eof $fd_ph]} {
989+
if {[catch {close $fd_ph}]} {
990+
hook_failed_popup post-checkout $pch_error 0
991+
}
992+
unset pch_error
993+
set done 1
994+
return
995+
}
996+
fconfigure $fd_ph -blocking 0
970997
}
971998

972999
######################################################################

0 commit comments

Comments
 (0)