threads / discuss / 19676

preventing checking out remote branch in gitk

Subject: preventing checking out remote branch in gitk

## tl;dr

2 messages between Jun 5, 2009 and Jun 6, 2009.

replies: 1people: 1as markdown or json

Sitaram Chamarty· Jun 5, 2009, 15:21 UTC · lore
Hello,

I have a fair number of new users, mostly refugees from VSS and SVN, and they do use the GUIs a fair bit.

And they keep doing this :-) I know what you're thinking: teach them not to do it...

But doing this at the command line gives you a nice warning, and a GUI is (like it or not) considered more "safe" (aka less powerful). So it should go one better and just refuse :-)

Is there any way we can disable "Checkout this branch" for branches that are not local in gitk? I'm willing to play around with the code and test it if someone can give me a couple of pointers at least.

Thanks,
Sitaram
Sitaram Chamarty· Jun 6, 2009, 04:06 UTC · re: Sitaram Chamarty · lore

[PATCH] gitk: disable checkout of remote branch

At the command line, this gives you a detailed warning message, but the GUI currently allows it without any fuss.

Since the GUI is often used by people much less familiar with git, it seems reasonable to make the GUI more restrictive than the command line, not less.

This prevents a lot of detached HEAD commits by new users.
Signed-off-by: Sitaram Chamarty <sitaramc@gmail.com>
---

I have a lot of new users, and I'd really appreciate it if someone could review (hey it's my first Tcl code in all my life!) and approve; this will save me a whole boatload of trouble :-)

If someone disagrees with the logic that the GUI should be more "safe" than the command line please do let me know.

 gitk-git/gitk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 gitk-git/gitk
diff --git a/gitk-git/gitk b/gitk-git/gitk
old mode 100644
new mode 100755
index 8c66d17..411bc52
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -8770,6 +8770,9 @@ proc headmenu {x y id head} {
     set headmenuid $id
     set headmenuhead $head
     set state normal
+    if {[string match "remotes/*" $head]} {
+	set state disabled
+    }
     if {$head eq $mainhead} {
 	set state disabled
     }
-- 
1.6.3.2

← back to recent threads