threads / patch / 29132

patchgitk: make "git describe" output clickable, too

Subject: [PATCH] gitk: make "git describe" output clickable, too

## tl;dr

3 messages between Dec 10, 2011 and Feb 1, 2012. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Jim Meyering· Dec 10, 2011, 15:08 UTC · lore

I noticed that automake's contribution guidelines suggest using "git describe" output in commit logs to reference previous commits. By contrast, in coreutils, I had acquired the habit of using a bare SHA1 prefix (8 hex digits), since gitk creates clickable links for that, and not for "git describe" output.

I prefer the readability of the full "git describe" output, yet want to retain the gitk links, so wrote the following that renders as clickable not just SHA1-like strings, but also an SHA1-like string that is prefixed by "-g".

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
This is relative to master.
Think of this as mere proof-of-concept:

Ideally, the string preceding the -g would be used to disambiguate the SHA1 prefix, but that would require more code.

I confess that I haven't looked to see if documentation needs to be updated or if this would merit test suite additions.

 gitk-git/gitk |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Show changes to gitk-git/gitk +5 −2
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 4cde0c4..f8eb613 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6688,7 +6688,7 @@ proc appendwithlinks {text tags} {

     set start [$ctext index "end - 1c"]
     $ctext insert end $text $tags
-    set links [regexp -indices -all -inline {\m[0-9a-f]{6,40}\M} $text]
+    set links [regexp -indices -all -inline {(?:\m|-g)[0-9a-f]{6,40}\M} $text]
     foreach l $links {
 	set s [lindex $l 0]
 	set e [lindex $l 1]
@@ -6704,6 +6704,10 @@ proc appendwithlinks {text tags} {
 proc setlink {id lk} {
     global curview ctext pendinglinks

+    if {[string range $id 0 1] eq "-g"} {
+      set id [string range $id 2 end]
+    }
+
     set known 0
     if {[string length $id] < 40} {
 	set matches [longid $id]
--
1.7.8.163.g9859a
Junio C Hamano· Dec 12, 2011, 19:48 UTC · re: Jim Meyering · lore

Re: [PATCH] gitk: make "git describe" output clickable, too

Jim Meyering <jim@meyering.net> writes:
Show 15 quoted lines
> I noticed that automake's contribution guidelines suggest using
> "git describe" output in commit logs to reference previous commits.
> By contrast, in coreutils, I had acquired the habit of using a bare SHA1
> prefix (8 hex digits), since gitk creates clickable links for that, and
> not for "git describe" output.
>
> I prefer the readability of the full "git describe" output, yet want to
> retain the gitk links, so wrote the following that renders as clickable
> not just SHA1-like strings, but also an SHA1-like string that is
> prefixed by "-g".
>
> Signed-off-by: Jim Meyering <meyering@redhat.com>
> ---
> This is relative to master.
> Think of this as mere proof-of-concept:
Paul, I think this makes tons of sense. Comments?
Show 35 quoted lines
> Ideally, the string preceding the -g would be used to disambiguate
> the SHA1 prefix, but that would require more code.
>
> I confess that I haven't looked to see if documentation needs
> to be updated or if this would merit test suite additions.
>
>  gitk-git/gitk |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 4cde0c4..f8eb613 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -6688,7 +6688,7 @@ proc appendwithlinks {text tags} {
>
>      set start [$ctext index "end - 1c"]
>      $ctext insert end $text $tags
> -    set links [regexp -indices -all -inline {\m[0-9a-f]{6,40}\M} $text]
> +    set links [regexp -indices -all -inline {(?:\m|-g)[0-9a-f]{6,40}\M} $text]
>      foreach l $links {
>  	set s [lindex $l 0]
>  	set e [lindex $l 1]
> @@ -6704,6 +6704,10 @@ proc appendwithlinks {text tags} {
>  proc setlink {id lk} {
>      global curview ctext pendinglinks
>
> +    if {[string range $id 0 1] eq "-g"} {
> +      set id [string range $id 2 end]
> +    }
> +
>      set known 0
>      if {[string length $id] < 40} {
>  	set matches [longid $id]
> --
> 1.7.8.163.g9859a
Jim Meyering· Feb 1, 2012, 13:17 UTC · re: Junio C Hamano · lore

Re: [PATCH] gitk: make "git describe" output clickable, too

Junio C Hamano wrote:
Show 19 quoted lines
> Jim Meyering <jim@meyering.net> writes:
>
>> I noticed that automake's contribution guidelines suggest using
>> "git describe" output in commit logs to reference previous commits.
>> By contrast, in coreutils, I had acquired the habit of using a bare SHA1
>> prefix (8 hex digits), since gitk creates clickable links for that, and
>> not for "git describe" output.
>>
>> I prefer the readability of the full "git describe" output, yet want to
>> retain the gitk links, so wrote the following that renders as clickable
>> not just SHA1-like strings, but also an SHA1-like string that is
>> prefixed by "-g".
>>
>> Signed-off-by: Jim Meyering <meyering@redhat.com>
>> ---
>> This is relative to master.
>> Think of this as mere proof-of-concept:
>
> Paul, I think this makes tons of sense. Comments?
Thanks for the feedback, Junio.
Show 35 quoted lines
>> Ideally, the string preceding the -g would be used to disambiguate
>> the SHA1 prefix, but that would require more code.
>>
>> I confess that I haven't looked to see if documentation needs
>> to be updated or if this would merit test suite additions.
>>
>>  gitk-git/gitk |    6 +++++-
>>  1 files changed, 5 insertions(+), 1 deletions(-)
>>
>> diff --git a/gitk-git/gitk b/gitk-git/gitk
>> index 4cde0c4..f8eb613 100755
>> --- a/gitk-git/gitk
>> +++ b/gitk-git/gitk
>> @@ -6688,7 +6688,7 @@ proc appendwithlinks {text tags} {
>>
>>      set start [$ctext index "end - 1c"]
>>      $ctext insert end $text $tags
>> -    set links [regexp -indices -all -inline {\m[0-9a-f]{6,40}\M} $text]
>> +    set links [regexp -indices -all -inline {(?:\m|-g)[0-9a-f]{6,40}\M} $text]
>>      foreach l $links {
>>  	set s [lindex $l 0]
>>  	set e [lindex $l 1]
>> @@ -6704,6 +6704,10 @@ proc appendwithlinks {text tags} {
>>  proc setlink {id lk} {
>>      global curview ctext pendinglinks
>>
>> +    if {[string range $id 0 1] eq "-g"} {
>> +      set id [string range $id 2 end]
>> +    }
>> +
>>      set known 0
>>      if {[string length $id] < 40} {
>>  	set matches [longid $id]
>> --
>> 1.7.8.163.g9859a

← back to recent threads