From: Pierre Dumuid <pmdumuid@gmail.com>
To: paulus@ozlabs.org, git@vger.kernel.org
Cc: Pierre Dumuid <pmdumuid@gmail.com>, Andreas Amann <andreas.amann@web.de>
Subject: [PATCH 5/6] gitk: Add a "Save file as" menu item
Date: Thu, 15 Dec 2016 21:58:46 +1030 [thread overview]
Message-ID: <20161215112847.14719-5-pmdumuid@gmail.com> (raw)
In-Reply-To: <20161215112847.14719-1-pmdumuid@gmail.com>
Previously, there was no easy way to save a particular file from the
currently selected revision.
This patch adds a menu item "Save file as" to the file list popup
menu, which opens a file selection dialog to determine the name under
which a file should be saved. The default filename is of the form
"[shortid] basename". If the current revision is the index, the
default pattern is of the form "[index] basename". This works for
both, the "Patch" and "Tree" view. The menu item is disabled for the
"local uncommitted changes" fake revision.
Signed-off-by: Andreas Amann <andreas.amann@web.de>
Signed-off-by: Pierre Dumuid <pmdumuid@gmail.com>
---
gitk | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/gitk b/gitk
index 5f27716..0903d2d 100755
--- a/gitk
+++ b/gitk
@@ -2693,6 +2693,7 @@ proc makewindow {} {
{mc "Highlight this too" command {flist_hl 0}}
{mc "Highlight this only" command {flist_hl 1}}
{mc "External diff" command {external_diff}}
+ {mc "Save file as" command {save_file_as}}
{mc "Blame parent commit" command {external_blame 1}}
{mc "Copy path" command {clipboard clear; clipboard append $flist_menu_file}}
}
@@ -3504,6 +3505,7 @@ proc sel_flist {w x y} {
proc pop_flist_menu {w X Y x y} {
global ctext cflist cmitmode flist_menu flist_menu_file
global treediffs diffids
+ global nullid
stopfinding
set l [lindex [split [$w index "@$x,$y"] "."] 0]
@@ -3521,6 +3523,12 @@ proc pop_flist_menu {w X Y x y} {
}
# Disable "External diff" item in tree mode
$flist_menu entryconf 2 -state $xdiffstate
+ set savefilestate "normal"
+ if {[lindex $diffids 0] eq $nullid} {
+ set savefilestate "disabled"
+ }
+ # Disable "Save file as" item "local uncommited changes" revision
+ $flist_menu entryconf 3 -state $savefilestate
tk_popup $flist_menu $X $Y
}
@@ -3632,6 +3640,34 @@ proc external_diff_get_one_file {diffid filename diffdir} {
"revision $diffid"]
}
+proc save_file_as {} {
+ global nullid nullid2
+ global flist_menu_file cmitmode
+ global diffids
+
+ set diffid [lindex $diffids 0]
+ if {$diffid == $nullid} {
+ return
+ } elseif {$diffid == $nullid2} {
+ set diffidtext [mc "index"]
+ set diffid ""
+ set whattext $diffidtext
+ } else {
+ set diffidtext [shortids $diffid]
+ set whattext "[mc "revision"] $diffidtext"
+ }
+ set diffid $diffid:
+ if {$cmitmode eq "tree"} {
+ set diffid $diffid./
+ }
+ set difffile "\[$diffidtext\] [file tail $flist_menu_file]"
+ set difffile [tk_getSaveFile -initialfile $difffile -title [mc "Save file as"] -parent .]
+ if {$difffile eq {}} {
+ return
+ }
+ save_file_from_commit $diffid$flist_menu_file $difffile $whattext
+}
+
proc external_diff {} {
global nullid nullid2
global flist_menu_file
--
2.10.2
next prev parent reply other threads:[~2016-12-15 11:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 11:28 [PATCH 1/6] Enable ability to visualise the results of git cherry C1 C2 Pierre Dumuid
2016-12-15 11:28 ` [PATCH 2/6] Add ability to follow a remote branch with a dialog Pierre Dumuid
2016-12-31 8:53 ` Paul Mackerras
2016-12-15 11:28 ` [PATCH 3/6] Add a tree view to the local branches, remote branches and tags, where / is treated as a directory seperator Pierre Dumuid
2016-12-31 9:08 ` Paul Mackerras
2016-12-15 11:28 ` [PATCH 4/6] Add DirDiffTool as additional option Pierre Dumuid
2016-12-15 11:28 ` Pierre Dumuid [this message]
2016-12-15 11:28 ` [PATCH 6/6] Rename 'remotes/' to 'r../' in heads Pierre Dumuid
2016-12-31 8:30 ` [PATCH 1/6] Enable ability to visualise the results of git cherry C1 C2 Paul Mackerras
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161215112847.14719-5-pmdumuid@gmail.com \
--to=pmdumuid@gmail.com \
--cc=andreas.amann@web.de \
--cc=git@vger.kernel.org \
--cc=paulus@ozlabs.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.