git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
@ 2010-09-28 20:03 Heiko Voigt
  2010-09-28 21:09 ` Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Heiko Voigt @ 2010-09-28 20:03 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

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>
---
 gitk     |   24 ++++++++++++++++++------
 po/de.po |    6 ++++++
 po/es.po |    6 ++++++
 po/fr.po |    6 ++++++
 po/hu.po |    6 ++++++
 po/it.po |    6 ++++++
 po/ja.po |    6 ++++++
 po/ru.po |    6 ++++++
 po/sv.po |    6 ++++++
 9 files changed, 66 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"
     }
 }
 
diff --git a/po/de.po b/po/de.po
index bd194a3..8cfd299 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1276,3 +1276,9 @@ msgstr "Falsche Kommandozeilen-Parameter für gitk:"
 #: gitk:11587
 msgid "Command line"
 msgstr "Kommandozeile"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/es.po b/po/es.po
index 0471dd0..a3092e0 100644
--- a/po/es.po
+++ b/po/es.po
@@ -909,3 +909,9 @@ msgstr "Argumentos incorrectos a Gitk:"
 #: gitk:10170
 msgid "Command line"
 msgstr "Línea de comandos"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/fr.po b/po/fr.po
index 5370ddc..e58cbdd 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -1252,3 +1252,9 @@ msgstr "Arguments invalides pour gitk :"
 #: gitk:11249
 msgid "Command line"
 msgstr "Ligne de commande"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/hu.po b/po/hu.po
index 7262b61..9237d2a 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -1293,3 +1293,9 @@ msgstr "Parancs sor"
 #~ msgstr ""
 #~ "Sajnáljuk, de a gitk nem futtatható ezzel a Tcl/Tk verzióval.\n"
 #~ "Gitk futtatásához legalább Tcl/Tk 8.4 szükséges."
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/it.po b/po/it.po
index a730d63..6e0b76f 100644
--- a/po/it.po
+++ b/po/it.po
@@ -1274,3 +1274,9 @@ msgstr "Gitk: argomenti errati:"
 #: gitk:11587
 msgid "Command line"
 msgstr "Linea di comando"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/ja.po b/po/ja.po
index 4f47051..b47faab 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -1253,3 +1253,9 @@ msgstr "gitkへの不正な引数:"
 #: gitk:11316
 msgid "Command line"
 msgstr "コマンド行"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
diff --git a/po/ru.po b/po/ru.po
index c3d0285..f136ec1 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -1083,3 +1083,9 @@ msgstr "Неправильные аргументы для gitk:"
 msgid "Command line"
 msgstr "Командная строка"
 
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
+
diff --git a/po/sv.po b/po/sv.po
index 386763a..b079016 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -1295,3 +1295,9 @@ msgstr "Kommandorad"
 
 #~ msgid "Name"
 #~ msgstr "Namn"
+
+msgid "Checkout from this commit"
+msgstr ""
+
+msgid "Checkout from parent commit"
+msgstr ""
-- 
1.7.2.2.177.geec0d

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
  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:27 ` [GITK PATCH] gitk: add menuitem for file checkout from selected " Michele Ballabio
  2010-12-11 23:23 ` Paul Mackerras
  2 siblings, 1 reply; 8+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-09-28 21:09 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: Paul Mackerras, git

On Tue, Sep 28, 2010 at 20:03, Heiko Voigt <hvoigt@hvoigt.net> wrote:
> This is useful if a user wants to checkout a file from a certain
> commit. This is equivalent to

It looks like the existing msgid/msgstr pairs have line number
comments. Why not add that for the new strings? Presumably it might
inflate the patch a lot though, as old strings get displaced.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Heiko Voigt @ 2010-09-29 15:23 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: Paul Mackerras, git

Hi,

On Tue, Sep 28, 2010 at 09:09:43PM +0000, Ævar Arnfjörð Bjarmason wrote:
> On Tue, Sep 28, 2010 at 20:03, Heiko Voigt <hvoigt@hvoigt.net> wrote:
> > This is useful if a user wants to checkout a file from a certain
> > commit. This is equivalent to
> 
> It looks like the existing msgid/msgstr pairs have line number
> comments. Why not add that for the new strings? Presumably it might
> inflate the patch a lot though, as old strings get displaced.

I was wondering what these numbers were for. Now it makes sense. I am
not against doing it but I would need a script to update the existing
ones. Is there something like that? Otherwise I would just add the line
number for the two new msgs.

Cheers Heiko

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
  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:27 ` Michele Ballabio
  2010-12-11 23:23 ` Paul Mackerras
  2 siblings, 0 replies; 8+ messages in thread
From: Michele Ballabio @ 2010-09-29 15:27 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: Paul Mackerras, git

On Tuesday 28 September 2010, Heiko Voigt wrote:
>  po/de.po |    6 ++++++
>  po/es.po |    6 ++++++
>  po/fr.po |    6 ++++++
>  po/hu.po |    6 ++++++
>  po/it.po |    6 ++++++
>  po/ja.po |    6 ++++++
>  po/ru.po |    6 ++++++
>  po/sv.po |    6 ++++++

You shouldn't change anything under po/ (unless you want to actually translate
something, of course): translators will do it for you. There would be less
of a chance of a conflicting merge.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
  2010-09-29 15:23   ` Heiko Voigt
@ 2010-09-29 15:48     ` Ævar Arnfjörð Bjarmason
  2010-09-30 18:29       ` [PATCH v2] gitk: add menuitem for file checkout from this " Heiko Voigt
  0 siblings, 1 reply; 8+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2010-09-29 15:48 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: Paul Mackerras, git, Michele Ballabio

On Wed, Sep 29, 2010 at 15:23, Heiko Voigt <hvoigt@hvoigt.net> wrote:
> Hi,
>
> On Tue, Sep 28, 2010 at 09:09:43PM +0000, Ęvar Arnfjörš Bjarmason wrote:
>> On Tue, Sep 28, 2010 at 20:03, Heiko Voigt <hvoigt@hvoigt.net> wrote:
>> > This is useful if a user wants to checkout a file from a certain
>> > commit. This is equivalent to
>>
>> It looks like the existing msgid/msgstr pairs have line number
>> comments. Why not add that for the new strings? Presumably it might
>> inflate the patch a lot though, as old strings get displaced.
>
> I was wondering what these numbers were for. Now it makes sense. I am
> not against doing it but I would need a script to update the existing
> ones. Is there something like that? Otherwise I would just add the line
> number for the two new msgs.

You should update PO files with the msgmerge(1) program, the ab/i18n
branch has docs on how to do that in po/README.

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] gitk: add menuitem for file checkout from this or parent commit
  2010-09-29 15:48     ` Ævar Arnfjörð Bjarmason
@ 2010-09-30 18:29       ` Heiko Voigt
  0 siblings, 0 replies; 8+ messages in thread
From: Heiko Voigt @ 2010-09-30 18:29 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Paul Mackerras, git, Michele Ballabio

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [GITK PATCH] gitk: add menuitem for file checkout from selected or parent commit
  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:27 ` [GITK PATCH] gitk: add menuitem for file checkout from selected " 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
  2 siblings, 1 reply; 8+ messages in thread
From: Paul Mackerras @ 2010-12-11 23:23 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: git

On Tue, Sep 28, 2010 at 10:03:45PM +0200, Heiko Voigt wrote:

> 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>

Thanks for the patch.  However, the commit message doesn't mention
that the patch also adds the 'checkout from parent' menu item or why
that's a useful thing to have.  I like the 'checkout from this commit'
thing but I don't immediately see why checking out from the first
parent is so useful that we have to have it as a menu item, but
checking out from other parents of a merge isn't.

Also, don't bother updating the po files.  The translators generally
prefer it if we don't.

Paul.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] gitk: add menuitem for file checkout from this or parent commit
  2010-12-11 23:23 ` Paul Mackerras
@ 2010-12-13 21:46   ` hvoigt
  0 siblings, 0 replies; 8+ messages in thread
From: hvoigt @ 2010-12-13 21:46 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git

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

  git checkout $commit $file

and

  git checkout $commit^ $file

Checkout of the first parent is useful in situations where you want to
checkout a file before some modification. In the patch view only the
modified filenames are shown. It is much quicker to select the commit
which modified the file and then choose the file from the patch view
compared to select the parent commit and then browse through the whole
tree to choose the file.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
On Sun, Dec 12, 2010 at 10:23:24AM +1100, Paul Mackerras wrote:
> Thanks for the patch.  However, the commit message doesn't mention
> that the patch also adds the 'checkout from parent' menu item or why
> that's a useful thing to have.  I like the 'checkout from this commit'
> thing but I don't immediately see why checking out from the first
> parent is so useful that we have to have it as a menu item, but
> checking out from other parents of a merge isn't.

Here is a new version of the patch with some added explanation why this
is useful in day to day use. I choose the first parent because in my
usecase I checkout single files by typically using non-merge commits.
Do you think there are usecases for second or other parent commits on
merge commits?

Cheers Heiko

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

diff --git a/gitk b/gitk
index e82c6bf..e0dd94d 100755
--- a/gitk
+++ b/gitk
@@ -2522,6 +2522,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
 
@@ -3558,6 +3560,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
@@ -3573,17 +3589,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.3.msysgit.0.1.g5a65e

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-12-13 21:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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       ` [PATCH v2] gitk: add menuitem for file checkout from this " Heiko Voigt
2010-09-29 15:27 ` [GITK PATCH] gitk: add menuitem for file checkout from selected " 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

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).