@matheusbsbs / matheus-bagliano / commits / b4c813bc71
Fork 0

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 <Jens.Lehmann@web.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Jens Lehmann committed Apr 6, 2009 at 21:05 UTC b4c813bc71f83804302f1c896c91dc499adf1922
1 file changed +28 -1
lib/choose_repository.tcl
+28 -1
@@ -966,7 +966,34 @@ method _readtree_wait {fd} {
966 return
967 }
968
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
997 }
998
999 ######################################################################