git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>,
	git@vger.kernel.org, Michele Ballabio <barra_cuda@katamail.com>
Subject: [PATCH v2] gitk: add menuitem for file checkout from this or parent commit
Date: Thu, 30 Sep 2010 20:29:49 +0200	[thread overview]
Message-ID: <20100930182949.GA15412@book.hvoigt.net> (raw)
In-Reply-To: <AANLkTinn-_Npv4+wGRkS6Sonf1VRV-cEMtHBEtyQeq8O@mail.gmail.com>

This is useful if a user wants to checkout a file from a certain
commit. This is equivalent to

  git checkout $commit $file

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---

On Wed, Sep 29, 2010 at 03:48:03PM +0000, Ævar Arnfjörð Bjarmason wrote:
> But as Michele points out you probably shouldn't update these, some
> projects do, but it probably makes more sense to leave these updates
> up to translators.

Here is an updated version of that patch without the po changes.

 gitk |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/gitk b/gitk
index 45e3380..c582bb5 100755
--- a/gitk
+++ b/gitk
@@ -2497,6 +2497,8 @@ proc makewindow {} {
 	{mc "Highlight this only" command {flist_hl 1}}
 	{mc "External diff" command {external_diff}}
 	{mc "Blame parent commit" command {external_blame 1}}
+	{mc "Checkout from this commit" command {external_checkout}}
+	{mc "Checkout from parent commit" command {external_checkout 1}}
     }
     $flist_menu configure -tearoff 0
 
@@ -3533,6 +3535,20 @@ proc make_relative {f} {
 }
 
 proc external_blame {parent_idx {line {}}} {
+
+    set cmdline [list git gui blame]
+    if {$line ne {} && $line > 1} {
+	lappend cmdline "--line=$line"
+    }
+    run_command_on_selected_file $cmdline $parent_idx
+}
+
+proc external_checkout {{parent_idx 0}} {
+    set cmdline [list git checkout]
+    run_command_on_selected_file $cmdline $parent_idx
+}
+
+proc run_command_on_selected_file {cmdline parent_idx} {
     global flist_menu_file gitdir
     global nullid nullid2
     global parentlist selectedline currentid
@@ -3548,17 +3564,13 @@ proc external_blame {parent_idx {line {}}} {
 	return
     }
 
-    set cmdline [list git gui blame]
-    if {$line ne {} && $line > 1} {
-	lappend cmdline "--line=$line"
-    }
     set f [file join [file dirname $gitdir] $flist_menu_file]
-    # Unfortunately it seems git gui blame doesn't like
+    # Unfortunately some commands do not like
     # being given an absolute path...
     set f [make_relative $f]
     lappend cmdline $base_commit $f
     if {[catch {eval exec $cmdline &} err]} {
-	error_popup "[mc "git gui blame: command failed:"] $err"
+	error_popup "[mc "$cmdline: command failed:"] $err"
     }
 }
 
-- 
1.7.2.2.177.geec0d

  reply	other threads:[~2010-09-30 18:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28 20:03 [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit Heiko Voigt
2010-09-28 21:09 ` Ævar Arnfjörð Bjarmason
2010-09-29 15:23   ` Heiko Voigt
2010-09-29 15:48     ` Ævar Arnfjörð Bjarmason
2010-09-30 18:29       ` Heiko Voigt [this message]
2010-09-29 15:27 ` Michele Ballabio
2010-12-11 23:23 ` Paul Mackerras
2010-12-13 21:46   ` [PATCH v3] gitk: add menuitem for file checkout from this " hvoigt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100930182949.GA15412@book.hvoigt.net \
    --to=hvoigt@hvoigt.net \
    --cc=avarab@gmail.com \
    --cc=barra_cuda@katamail.com \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).