threads / patch / 23776

patchgitk: Show notes

Subject: [PATCH] gitk: Show notes

## tl;dr

3 messages between May 11, 2010 and May 12, 2010. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Kirill Smelkov· May 11, 2010, 08:26 UTC · lore
If in git.git I do
    $ git notes add -m 'This makes status significantly slower with Dokko' \
        ee6fc514
then `git log` shows the note...
    $ git log -1 ee6fc514
    commit ee6fc514f2df821c2719cc49499a56ef2fb136b0
    Author: Jens Lehmann <Jens.Lehmann@web.de>
    Date:   Sat Jan 16 18:42:24 2010 +0100
        Show submodules as modified when they contain a dirty work tree
        Until now a submodule only then showed up as modified in the supermodule
        when the last commit in the submodule differed from the one in the index
        or the diffed against commit of the superproject. A dirty work tree
        containing new untracked or modified files in a submodule was
        undetectable when looking at it from the superproject.
        Now git status and git diff (against the work tree) in the superproject
        will also display submodules as modified when they contain untracked or
        modified files, even if the compared ref matches the HEAD of the
        submodule.
        Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
        Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
        Signed-off-by: Junio C Hamano <gitster@pobox.com>
    Notes:
        This makes status significantly slower with Dokko
... but unfortunately gitk does not.
Let's fix this and teach gitk to show notes.
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 gitk |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
Show changes to gitk +6 −5
diff --git a/gitk b/gitk
index 1b0e09a..d537011 100755
--- a/gitk
+++ b/gitk
@@ -361,8 +361,8 @@ proc start_rev_list {view} {
     }
 
     if {[catch {
-	set fd [open [concat | git log --no-color -z --pretty=raw --parents \
-			 --boundary $args "--" $files] r]
+	set fd [open [concat | git log --no-color -z --pretty=raw --show-notes \
+			--parents --boundary $args "--" $files] r]
     } err]} {
 	error_popup "[mc "Error executing git log:"] $err"
 	return 0
@@ -508,8 +508,8 @@ proc updatecommits {} {
 	set args $vorigargs($view)
     }
     if {[catch {
-	set fd [open [concat | git log --no-color -z --pretty=raw --parents \
-			  --boundary $args "--" $vfilelimit($view)] r]
+	set fd [open [concat | git log --no-color -z --pretty=raw --show-notes \
+			--parents --boundary $args "--" $vfilelimit($view)] r]
     } err]} {
 	error_popup "[mc "Error executing git log:"] $err"
 	return
@@ -1586,7 +1586,8 @@ proc do_readcommit {id} {
     global tclencoding
 
     # Invoke git-log to handle automatic encoding conversion
-    set fd [open [concat | git log --no-color --pretty=raw -1 $id] r]
+    set fd [open [concat | git log --no-color --pretty=raw --show-notes \
+		     -1 $id] r]
     # Read the results using i18n.logoutputencoding
     fconfigure $fd -translation lf -eofchar {}
     if {$tclencoding != {}} {
-- 
1.7.1.89.g6b35c
Michael J Gruber· May 11, 2010, 14:35 UTC · re: Kirill Smelkov · lore

Re: [PATCH] gitk: Show notes

Kirill Smelkov venit, vidit, dixit 11.05.2010 10:26:
Show 7 quoted lines
> If in git.git I do
> 
>     $ git notes add -m 'This makes status significantly slower with Dokko' \
>         ee6fc514
> 
> then `git log` shows the note...
> 
because --show-notes is the default...
> ... but unfortunately gitk does not.
... unless --pretty is given, and gitk uses --pretty.
But what is wrong with gitk --show-notes?

If you mean to adjust gitk's default to log's current default please say so in the commit message. There's no need to include a longish sample output for that.

Also, I don't think proc do_readcommit needs the notes. The other two places use $args, so it might make sense to prepend --show-notes to the arg list in a central place.

Michael
Kirill Smelkov· May 12, 2010, 08:56 UTC · re: Michael J Gruber · lore

Re: gitk: Show notes

On Tue, May 11, 2010 at 04:35:45PM +0200, Michael J Gruber wrote:
Show 16 quoted lines
> Kirill Smelkov venit, vidit, dixit 11.05.2010 10:26:
> > If in git.git I do
> > 
> >     $ git notes add -m 'This makes status significantly slower with Dokko' \
> >         ee6fc514
> > 
> > then `git log` shows the note...
> > 
> 
> because --show-notes is the default...
> 
> > ... but unfortunately gitk does not.
> 
> ... unless --pretty is given, and gitk uses --pretty.
> 
> But what is wrong with gitk --show-notes?

Sorry, you are right. I learned notes just yesterday and forgot one can pass such options to gitk.

> If you mean to adjust gitk's default to log's current default please say
> so in the commit message. There's no need to include a longish sample
> output for that.
Ok, agree.
> Also, I don't think proc do_readcommit needs the notes. The other two
> places use $args, so it might make sense to prepend --show-notes to the
> arg list in a central place.
Right.

I've tried to rework the patch -- only I could not find a better way to prepend --show-notes to arg, than just define $show_notes based on $git_version and use it in 2 appropriate places.

Also, --show-notes was introduced in git-1.6.6.2, but our $git_version is 3 digits only, so this will be really enabled for git-1.7.0 .

Thanks for the review, and maybe there is a better way to do it?
Kirill
---- 8< ----
From: Kirill Smelkov <kirr@mns.spb.ru>
Date: Tue, 11 May 2010 12:17:11 +0400
Subject: [PATCH] gitk: Show notes by default (like git log do)
Starting from ~ git-1.6.6, log, show & whatchanged show notes by default.

On the other hand, gitk does not show notes by default, because under the hood it calls `git log --pretty=raw ...` to get the log, and in `git log` notes are turned off, when user specifies format or pretty settings.

Yes, it is possible to invoke `gitk --show-notes` explicitly, but since from user's perspective, gitk is gui enabled git log, it would be logical for gitk to show notes by default too for consistency.

In git, --show-notes was introduced in 66b2ed (Fix "log" family not to be too agressive about showing notes) which predates 1.6.6.2

Notes can still be supressed with `gitk --no-notes`.
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 gitk |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
Show changes to gitk +11 −4
diff --git a/gitk b/gitk
index 1b0e09a..45e3380 100755
--- a/gitk
+++ b/gitk
@@ -313,6 +313,7 @@ proc start_rev_list {view} {
     global viewactive viewinstances vmergeonly
     global mainheadid viewmainheadid viewmainheadid_orig
     global vcanopt vflags vrevs vorigargs
+    global show_notes
 
     set startmsecs [clock clicks -milliseconds]
     set commitidx($view) 0
@@ -361,8 +362,8 @@ proc start_rev_list {view} {
     }
 
     if {[catch {
-	set fd [open [concat | git log --no-color -z --pretty=raw --parents \
-			 --boundary $args "--" $files] r]
+	set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
+			--parents --boundary $args "--" $files] r]
     } err]} {
 	error_popup "[mc "Error executing git log:"] $err"
 	return 0
@@ -456,6 +457,7 @@ proc updatecommits {} {
     global mainheadid viewmainheadid viewmainheadid_orig pending_select
     global isworktree
     global varcid vposids vnegids vflags vrevs
+    global show_notes
 
     set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
     rereadrefs
@@ -508,8 +510,8 @@ proc updatecommits {} {
 	set args $vorigargs($view)
     }
     if {[catch {
-	set fd [open [concat | git log --no-color -z --pretty=raw --parents \
-			  --boundary $args "--" $vfilelimit($view)] r]
+	set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
+			--parents --boundary $args "--" $vfilelimit($view)] r]
     } err]} {
 	error_popup "[mc "Error executing git log:"] $err"
 	return
@@ -11521,6 +11523,11 @@ set NS [expr {$use_ttk ? "ttk" : ""}]
 
 set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
 
+set show_notes {}
+if {[package vcompare $git_version "1.6.6.2"] >= 0} {
+    set show_notes "--show-notes"
+}
+
 set runq {}
 set history {}
 set historyindex 0
-- 
1.7.1.91.ga63a7

← back to recent threads