All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitk: add "Hightlight commit name" menu entry
@ 2024-01-30  8:53 Raphael Gallais-Pou
  2024-03-19 19:45 ` Raphaël Gallais-Pou
  2024-03-21 15:51 ` Marc Branchaud
  0 siblings, 2 replies; 6+ messages in thread
From: Raphael Gallais-Pou @ 2024-01-30  8:53 UTC (permalink / raw)
  To: git, David Aguilar, Junio C Hamano, Denton Liu, Paul Mackerras,
	Beat Bolli

When working with diverged branches, some patches can appear several times
on different branches without having the need to merge those branches.
On the other hand you may have to port a specific patch on another
branch you are working on. The search with a SHA1 cannot be applied here
since they would differ.

This patch adds an entry in the main context menu to highlight every
instance of a commit.

Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
---
 gitk-git/gitk | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 7a087f123d..4b15230a16 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2672,6 +2672,7 @@ proc makewindow {} {
         {mc "Make patch" command mkpatch}
         {mc "Create tag" command mktag}
         {mc "Copy commit reference" command copyreference}
+	{mc "Highlight commit name" command highlightcommitname}
         {mc "Write commit to file" command writecommit}
         {mc "Create new branch" command mkbranch}
         {mc "Cherry-pick this commit" command cherrypick}
@@ -9002,13 +9003,13 @@ proc rowmenu {x y id} {
     if {$id ne $nullid && $id ne $nullid2} {
         set menu $rowctxmenu
         if {$mainhead ne {}} {
-            $menu entryconfigure 8 -label [mc "Reset %s branch to here" $mainhead] -state normal
+            $menu entryconfigure 9 -label [mc "Reset %s branch to here" $mainhead] -state normal
         } else {
-            $menu entryconfigure 8 -label [mc "Detached head: can't reset" $mainhead] -state disabled
+            $menu entryconfigure 9 -label [mc "Detached head: can't reset" $mainhead] -state disabled
         }
-        $menu entryconfigure 10 -state $mstate
         $menu entryconfigure 11 -state $mstate
         $menu entryconfigure 12 -state $mstate
+        $menu entryconfigure 13 -state $mstate
     } else {
         set menu $fakerowmenu
     }
@@ -9481,6 +9482,22 @@ proc copyreference {} {
     clipboard append $reference
 }
 
+proc highlightcommitname {} {
+    global rowmenuid autosellen findstring gdttype
+
+    set format "%s"
+    set cmd [list git show -s --pretty=format:$format --date=short]
+    if {$autosellen < 40} {
+        lappend cmd --abbrev=$autosellen
+    }
+    set reference [eval exec $cmd $rowmenuid]
+    set findstring $reference
+    set gdttype [mc "containing:"]
+
+    clipboard clear
+    clipboard append $reference
+}
+
 proc writecommit {} {
     global rowmenuid wrcomtop commitinfo wrcomcmd NS
 
-- 
2.43.0


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

* Re: [PATCH] gitk: add "Hightlight commit name" menu entry
  2024-01-30  8:53 [PATCH] gitk: add "Hightlight commit name" menu entry Raphael Gallais-Pou
@ 2024-03-19 19:45 ` Raphaël Gallais-Pou
  2024-03-21 15:51 ` Marc Branchaud
  1 sibling, 0 replies; 6+ messages in thread
From: Raphaël Gallais-Pou @ 2024-03-19 19:45 UTC (permalink / raw)
  To: git, David Aguilar, Junio C Hamano, Denton Liu, Paul Mackerras,
	Beat Bolli

Hi,

Gentle ping since I haven't received any reviews or comment on this 
patch. :)

Do you guys actually take patches for the gitk tool ? I feel like there 
is not much features added on this.

Regards,
Raphaël

Le 30/01/2024 à 09:53, Raphael Gallais-Pou a écrit :
> When working with diverged branches, some patches can appear several times
> on different branches without having the need to merge those branches.
> On the other hand you may have to port a specific patch on another
> branch you are working on. The search with a SHA1 cannot be applied here
> since they would differ.
> 
> This patch adds an entry in the main context menu to highlight every
> instance of a commit.
> 
> Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
> ---
>   gitk-git/gitk | 23 ++++++++++++++++++++---
>   1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 7a087f123d..4b15230a16 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -2672,6 +2672,7 @@ proc makewindow {} {
>           {mc "Make patch" command mkpatch}
>           {mc "Create tag" command mktag}
>           {mc "Copy commit reference" command copyreference}
> +	{mc "Highlight commit name" command highlightcommitname}
>           {mc "Write commit to file" command writecommit}
>           {mc "Create new branch" command mkbranch}
>           {mc "Cherry-pick this commit" command cherrypick}
> @@ -9002,13 +9003,13 @@ proc rowmenu {x y id} {
>       if {$id ne $nullid && $id ne $nullid2} {
>           set menu $rowctxmenu
>           if {$mainhead ne {}} {
> -            $menu entryconfigure 8 -label [mc "Reset %s branch to here" $mainhead] -state normal
> +            $menu entryconfigure 9 -label [mc "Reset %s branch to here" $mainhead] -state normal
>           } else {
> -            $menu entryconfigure 8 -label [mc "Detached head: can't reset" $mainhead] -state disabled
> +            $menu entryconfigure 9 -label [mc "Detached head: can't reset" $mainhead] -state disabled
>           }
> -        $menu entryconfigure 10 -state $mstate
>           $menu entryconfigure 11 -state $mstate
>           $menu entryconfigure 12 -state $mstate
> +        $menu entryconfigure 13 -state $mstate
>       } else {
>           set menu $fakerowmenu
>       }
> @@ -9481,6 +9482,22 @@ proc copyreference {} {
>       clipboard append $reference
>   }
>   
> +proc highlightcommitname {} {
> +    global rowmenuid autosellen findstring gdttype
> +
> +    set format "%s"
> +    set cmd [list git show -s --pretty=format:$format --date=short]
> +    if {$autosellen < 40} {
> +        lappend cmd --abbrev=$autosellen
> +    }
> +    set reference [eval exec $cmd $rowmenuid]
> +    set findstring $reference
> +    set gdttype [mc "containing:"]
> +
> +    clipboard clear
> +    clipboard append $reference
> +}
> +
>   proc writecommit {} {
>       global rowmenuid wrcomtop commitinfo wrcomcmd NS
>   

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

* Re: [PATCH] gitk: add "Hightlight commit name" menu entry
  2024-01-30  8:53 [PATCH] gitk: add "Hightlight commit name" menu entry Raphael Gallais-Pou
  2024-03-19 19:45 ` Raphaël Gallais-Pou
@ 2024-03-21 15:51 ` Marc Branchaud
  2024-03-23  9:45   ` Raphaël Gallais-Pou
  1 sibling, 1 reply; 6+ messages in thread
From: Marc Branchaud @ 2024-03-21 15:51 UTC (permalink / raw)
  To: Raphael Gallais-Pou, git, David Aguilar, Junio C Hamano,
	Denton Liu, Paul Mackerras, Beat Bolli


On 2024-01-30 03:53, Raphael Gallais-Pou wrote:
> When working with diverged branches, some patches can appear several times
> on different branches without having the need to merge those branches.
> On the other hand you may have to port a specific patch on another
> branch you are working on. The search with a SHA1 cannot be applied here
> since they would differ.
> 
> This patch adds an entry in the main context menu to highlight every
> instance of a commit.

Thanks for working on gitk!

Unfortunately, I don't understand the description of your new option. 
How is this different from the existing "Find containing:" feature? 
Gitk can already highlights commits that match a specified string. 
Please explain what gitk does when this new option is selected.

Also, please explain how your code identifies "every instance" of a 
commit.  When I think of a "commit instance" I think of the
"git patch-id" command, which I don't see here.

(It looks to me like this is basically a shortcut to auto-fill gitk's 
"containing:" field with the subject line of the selected commit?)

> Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
> ---
>   gitk-git/gitk | 23 ++++++++++++++++++++---
>   1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 7a087f123d..4b15230a16 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -2672,6 +2672,7 @@ proc makewindow {} {
>           {mc "Make patch" command mkpatch}
>           {mc "Create tag" command mktag}
>           {mc "Copy commit reference" command copyreference}
> +	{mc "Highlight commit name" command highlightcommitname}

This line is indented with a tab, but it should use spaces.

>           {mc "Write commit to file" command writecommit}
>           {mc "Create new branch" command mkbranch}
>           {mc "Cherry-pick this commit" command cherrypick}
> @@ -9002,13 +9003,13 @@ proc rowmenu {x y id} {
>       if {$id ne $nullid && $id ne $nullid2} {
>           set menu $rowctxmenu
>           if {$mainhead ne {}} {
> -            $menu entryconfigure 8 -label [mc "Reset %s branch to here" $mainhead] -state normal
> +            $menu entryconfigure 9 -label [mc "Reset %s branch to here" $mainhead] -state normal
>           } else {
> -            $menu entryconfigure 8 -label [mc "Detached head: can't reset" $mainhead] -state disabled
> +            $menu entryconfigure 9 -label [mc "Detached head: can't reset" $mainhead] -state disabled
>           }
> -        $menu entryconfigure 10 -state $mstate
>           $menu entryconfigure 11 -state $mstate
>           $menu entryconfigure 12 -state $mstate
> +        $menu entryconfigure 13 -state $mstate
>       } else {
>           set menu $fakerowmenu
>       }
> @@ -9481,6 +9482,22 @@ proc copyreference {} {
>       clipboard append $reference
>   }
>   
> +proc highlightcommitname {} {
> +    global rowmenuid autosellen findstring gdttype
> +
> +    set format "%s"
> +    set cmd [list git show -s --pretty=format:$format --date=short]

Why bother with the $format variable here?  Couldn't you just quote the 
--pretty part?
	"--pretty=format:%s"
(FYI, I am not a TCL/TK coder.)

		M.

> +    if {$autosellen < 40} {
> +        lappend cmd --abbrev=$autosellen
> +    }
> +    set reference [eval exec $cmd $rowmenuid]
> +    set findstring $reference
> +    set gdttype [mc "containing:"]
> +
> +    clipboard clear
> +    clipboard append $reference
> +}
> +
>   proc writecommit {} {
>       global rowmenuid wrcomtop commitinfo wrcomcmd NS
>   

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

* Re: [PATCH] gitk: add "Hightlight commit name" menu entry
  2024-03-21 15:51 ` Marc Branchaud
@ 2024-03-23  9:45   ` Raphaël Gallais-Pou
  2024-03-25 12:52     ` Marc Branchaud
  0 siblings, 1 reply; 6+ messages in thread
From: Raphaël Gallais-Pou @ 2024-03-23  9:45 UTC (permalink / raw)
  To: Marc Branchaud, git, David Aguilar, Junio C Hamano, Denton Liu,
	Paul Mackerras, Beat Bolli

Hi Marc,

Le 21/03/2024 à 16:51, Marc Branchaud a écrit :
> 
> On 2024-01-30 03:53, Raphael Gallais-Pou wrote:
>> When working with diverged branches, some patches can appear several 
>> times
>> on different branches without having the need to merge those branches.
>> On the other hand you may have to port a specific patch on another
>> branch you are working on. The search with a SHA1 cannot be applied here
>> since they would differ.
>>
>> This patch adds an entry in the main context menu to highlight every
>> instance of a commit.
> 
> Thanks for working on gitk!
> 
> Unfortunately, I don't understand the description of your new option. 
> How is this different from the existing "Find containing:" feature? Gitk 
> can already highlights commits that match a specified string. Please 
> explain what gitk does when this new option is selected.
> 
> Also, please explain how your code identifies "every instance" of a 
> commit.  When I think of a "commit instance" I think of the
> "git patch-id" command, which I don't see here.

It is based on the name of the commit. I agree that it is not ideal 
since the name can change between two versions.

As you stated below it is exactly a shortcut, and now that we are 
talking about it I think this is not the right right approach to do what 
I want.

I was not aware of the 'git patch-id' command, but this it clearly a 
better idea to base the search of the commit instances on it.

One thing that I wonder is that 'git patch-id' seems to be based on 
standard input. This means that in order to highlight every instances of 
a commit the algorithm would need to parse each and every patch and then 
proceed to hash them and compare to the one referenced.

Wouldn't it be a tad long to process ?

> 
> (It looks to me like this is basically a shortcut to auto-fill gitk's 
> "containing:" field with the subject line of the selected commit?)
> 
>> Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
>> ---
>>   gitk-git/gitk | 23 ++++++++++++++++++++---
>>   1 file changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/gitk-git/gitk b/gitk-git/gitk
>> index 7a087f123d..4b15230a16 100755
>> --- a/gitk-git/gitk
>> +++ b/gitk-git/gitk
>> @@ -2672,6 +2672,7 @@ proc makewindow {} {
>>           {mc "Make patch" command mkpatch}
>>           {mc "Create tag" command mktag}
>>           {mc "Copy commit reference" command copyreference}
>> +    {mc "Highlight commit name" command highlightcommitname}
> 
> This line is indented with a tab, but it should use spaces.

I will change my setup to use spaces instead of tabs one this file.

> 
>>           {mc "Write commit to file" command writecommit}
>>           {mc "Create new branch" command mkbranch}
>>           {mc "Cherry-pick this commit" command cherrypick}
>> @@ -9002,13 +9003,13 @@ proc rowmenu {x y id} {
>>       if {$id ne $nullid && $id ne $nullid2} {
>>           set menu $rowctxmenu
>>           if {$mainhead ne {}} {
>> -            $menu entryconfigure 8 -label [mc "Reset %s branch to 
>> here" $mainhead] -state normal
>> +            $menu entryconfigure 9 -label [mc "Reset %s branch to 
>> here" $mainhead] -state normal
>>           } else {
>> -            $menu entryconfigure 8 -label [mc "Detached head: can't 
>> reset" $mainhead] -state disabled
>> +            $menu entryconfigure 9 -label [mc "Detached head: can't 
>> reset" $mainhead] -state disabled
>>           }
>> -        $menu entryconfigure 10 -state $mstate
>>           $menu entryconfigure 11 -state $mstate
>>           $menu entryconfigure 12 -state $mstate
>> +        $menu entryconfigure 13 -state $mstate
>>       } else {
>>           set menu $fakerowmenu
>>       }
>> @@ -9481,6 +9482,22 @@ proc copyreference {} {
>>       clipboard append $reference
>>   }
>> +proc highlightcommitname {} {
>> +    global rowmenuid autosellen findstring gdttype
>> +
>> +    set format "%s"
>> +    set cmd [list git show -s --pretty=format:$format --date=short]
> 
> Why bother with the $format variable here?  Couldn't you just quote the 
> --pretty part?
>      "--pretty=format:%s"
> (FYI, I am not a TCL/TK coder.)

I also am not a TCL developer. I pretty much duplicated the 
copyreference{} procedure to get what I wanted.

Best regards,
Raphaël
> 
>          M.
> 
>> +    if {$autosellen < 40} {
>> +        lappend cmd --abbrev=$autosellen
>> +    }
>> +    set reference [eval exec $cmd $rowmenuid]
>> +    set findstring $reference
>> +    set gdttype [mc "containing:"]
>> +
>> +    clipboard clear
>> +    clipboard append $reference
>> +}
>> +
>>   proc writecommit {} {
>>       global rowmenuid wrcomtop commitinfo wrcomcmd NS

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

* Re: [PATCH] gitk: add "Hightlight commit name" menu entry
  2024-03-23  9:45   ` Raphaël Gallais-Pou
@ 2024-03-25 12:52     ` Marc Branchaud
  2024-03-25 18:56       ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Branchaud @ 2024-03-25 12:52 UTC (permalink / raw)
  To: Raphaël Gallais-Pou, git, David Aguilar, Junio C Hamano,
	Denton Liu, Paul Mackerras, Beat Bolli


On 2024-03-23 05:45, Raphaël Gallais-Pou wrote:
> Hi Marc,
> 
> Le 21/03/2024 à 16:51, Marc Branchaud a écrit :
>>
>> On 2024-01-30 03:53, Raphael Gallais-Pou wrote:
>>> When working with diverged branches, some patches can appear several 
>>> times
>>> on different branches without having the need to merge those branches.
>>> On the other hand you may have to port a specific patch on another
>>> branch you are working on. The search with a SHA1 cannot be applied here
>>> since they would differ.
>>>
>>> This patch adds an entry in the main context menu to highlight every
>>> instance of a commit.
>>
>> Thanks for working on gitk!
>>
>> Unfortunately, I don't understand the description of your new option. 
>> How is this different from the existing "Find containing:" feature? 
>> Gitk can already highlights commits that match a specified string. 
>> Please explain what gitk does when this new option is selected.
>>
>> Also, please explain how your code identifies "every instance" of a 
>> commit.  When I think of a "commit instance" I think of the
>> "git patch-id" command, which I don't see here.
> 
> It is based on the name of the commit. I agree that it is not ideal 
> since the name can change between two versions.

Thanks for clarifying that.

(BTW, on this list we pronounce "the name of the commit" as "the commit 
subject (line)".)

> As you stated below it is exactly a shortcut, and now that we are 
> talking about it I think this is not the right right approach to do what 
> I want.
> 
> I was not aware of the 'git patch-id' command, but this it clearly a 
> better idea to base the search of the commit instances on it.
> 
> One thing that I wonder is that 'git patch-id' seems to be based on 
> standard input. This means that in order to highlight every instances of 
> a commit the algorithm would need to parse each and every patch and then 
> proceed to hash them and compare to the one referenced.
> 
> Wouldn't it be a tad long to process ?

Absolutely.  Maybe "git cherry" would be more appropriate?

		M.


>> (It looks to me like this is basically a shortcut to auto-fill gitk's 
>> "containing:" field with the subject line of the selected commit?)
>>
>>> Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
>>> ---
>>>   gitk-git/gitk | 23 ++++++++++++++++++++---
>>>   1 file changed, 20 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/gitk-git/gitk b/gitk-git/gitk
>>> index 7a087f123d..4b15230a16 100755
>>> --- a/gitk-git/gitk
>>> +++ b/gitk-git/gitk
>>> @@ -2672,6 +2672,7 @@ proc makewindow {} {
>>>           {mc "Make patch" command mkpatch}
>>>           {mc "Create tag" command mktag}
>>>           {mc "Copy commit reference" command copyreference}
>>> +    {mc "Highlight commit name" command highlightcommitname}
>>
>> This line is indented with a tab, but it should use spaces.
> 
> I will change my setup to use spaces instead of tabs one this file.
> 
>>
>>>           {mc "Write commit to file" command writecommit}
>>>           {mc "Create new branch" command mkbranch}
>>>           {mc "Cherry-pick this commit" command cherrypick}
>>> @@ -9002,13 +9003,13 @@ proc rowmenu {x y id} {
>>>       if {$id ne $nullid && $id ne $nullid2} {
>>>           set menu $rowctxmenu
>>>           if {$mainhead ne {}} {
>>> -            $menu entryconfigure 8 -label [mc "Reset %s branch to 
>>> here" $mainhead] -state normal
>>> +            $menu entryconfigure 9 -label [mc "Reset %s branch to 
>>> here" $mainhead] -state normal
>>>           } else {
>>> -            $menu entryconfigure 8 -label [mc "Detached head: can't 
>>> reset" $mainhead] -state disabled
>>> +            $menu entryconfigure 9 -label [mc "Detached head: can't 
>>> reset" $mainhead] -state disabled
>>>           }
>>> -        $menu entryconfigure 10 -state $mstate
>>>           $menu entryconfigure 11 -state $mstate
>>>           $menu entryconfigure 12 -state $mstate
>>> +        $menu entryconfigure 13 -state $mstate
>>>       } else {
>>>           set menu $fakerowmenu
>>>       }
>>> @@ -9481,6 +9482,22 @@ proc copyreference {} {
>>>       clipboard append $reference
>>>   }
>>> +proc highlightcommitname {} {
>>> +    global rowmenuid autosellen findstring gdttype
>>> +
>>> +    set format "%s"
>>> +    set cmd [list git show -s --pretty=format:$format --date=short]
>>
>> Why bother with the $format variable here?  Couldn't you just quote 
>> the --pretty part?
>>      "--pretty=format:%s"
>> (FYI, I am not a TCL/TK coder.)
> 
> I also am not a TCL developer. I pretty much duplicated the 
> copyreference{} procedure to get what I wanted.
> 
> Best regards,
> Raphaël
>>
>>          M.
>>
>>> +    if {$autosellen < 40} {
>>> +        lappend cmd --abbrev=$autosellen
>>> +    }
>>> +    set reference [eval exec $cmd $rowmenuid]
>>> +    set findstring $reference
>>> +    set gdttype [mc "containing:"]
>>> +
>>> +    clipboard clear
>>> +    clipboard append $reference
>>> +}
>>> +
>>>   proc writecommit {} {
>>>       global rowmenuid wrcomtop commitinfo wrcomcmd NS

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

* Re: [PATCH] gitk: add "Hightlight commit name" menu entry
  2024-03-25 12:52     ` Marc Branchaud
@ 2024-03-25 18:56       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2024-03-25 18:56 UTC (permalink / raw)
  To: Marc Branchaud
  Cc: Raphaël Gallais-Pou, git, David Aguilar, Denton Liu,
	Paul Mackerras, Beat Bolli

Marc Branchaud <marcnarc@xiplink.com> writes:

> (BTW, on this list we pronounce "the name of the commit" as "the
> commit subject (line)".)

Yup. "subject" probably comes from the fact that the title (the
first paragraph, folded into a single line) of the commit is used on
the "Subject:" header when formatted for e-mail submission, and also
's' in "git log --pretty='%s'" is described as "subject" in the
documentation.  Other words I've seen used are "commit title" and
"oneline description", but "subject" would be the most common, I
suspect.

"commit name" on the other hand brings a different concept, i.e.,
"the commit object name", more strongly to readers' minds, and can
be mistaken as what you'd get in "git log --pretty='%H'".

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

end of thread, other threads:[~2024-03-25 18:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30  8:53 [PATCH] gitk: add "Hightlight commit name" menu entry Raphael Gallais-Pou
2024-03-19 19:45 ` Raphaël Gallais-Pou
2024-03-21 15:51 ` Marc Branchaud
2024-03-23  9:45   ` Raphaël Gallais-Pou
2024-03-25 12:52     ` Marc Branchaud
2024-03-25 18:56       ` Junio C Hamano

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.