threads / patch / 31867

patch, 2 partsgitk: fix --full-diff handling

Subject: [PATCH 0/2] gitk: fix --full-diff handling

## tl;dr

5 messages between Oct 19, 2012 and Oct 19, 2012. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Felipe Contreras· Oct 19, 2012, 10:56 UTC · lore
Hi,

I find usel to do 'git log --full-duff -- file' to find out all the commits that touched the file, and show the full diff (not just the one of the file).

Unfortunately gitk doesn't honour this option; the diff is limited in the UI.
The following patches fix that.
Felipe Contreras (2):
  gitk: simplify file filtering
  gitk: handle --full-diff correctly
 gitk-git/gitk | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
-- 
1.8.0.rc2.7.g0961fdf.dirty
Felipe Contreras· Oct 19, 2012, 10:56 UTC · re: Felipe Contreras · lore

[PATCH 1/2] gitk: simplify file filtering

git diff is perfectly able to do this with '-- files', no need for manual filtering.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 gitk-git/gitk | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
Show changes to gitk-git/gitk +7 −13
diff --git a/gitk-git/gitk b/gitk-git/gitk
index d93bd99..b79dfdf 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -7519,9 +7519,13 @@ proc diffcmd {ids flags} {
 }
 
 proc gettreediffs {ids} {
-    global treediff treepending
+    global treediff treepending limitdiffs vfilelimit curview
 
-    if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
+    set cmd [diffcmd $ids {--no-commit-id}]
+    if {$limitdiffs && $vfilelimit($curview) ne {}} {
+	    set cmd [concat $cmd -- $vfilelimit($curview)]
+    }
+    if {[catch {set gdtf [open $cmd r]}]} return
 
     set treepending $ids
     set treediff {}
@@ -7565,17 +7569,7 @@ proc gettreediffline {gdtf ids} {
 	return [expr {$nr >= $max? 2: 1}]
     }
     close $gdtf
-    if {$limitdiffs && $vfilelimit($curview) ne {}} {
-	set flist {}
-	foreach f $treediff {
-	    if {[path_filter $vfilelimit($curview) $f]} {
-		lappend flist $f
-	    }
-	}
-	set treediffs($ids) $flist
-    } else {
-	set treediffs($ids) $treediff
-    }
+    set treediffs($ids) $treediff
     unset treepending
     if {$cmitmode eq "tree" && [llength $diffids] == 1} {
 	gettree $diffids
-- 
1.8.0.rc2.7.g0961fdf.dirty
Felipe Contreras· Oct 19, 2012, 10:56 UTC · re: Felipe Contreras · lore

[PATCH 2/2] gitk: handle --full-diff correctly

Otherwise the files are missing from the diff, and the list of files.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 gitk-git/gitk | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
Show changes to gitk-git/gitk +11 −4
diff --git a/gitk-git/gitk b/gitk-git/gitk
index b79dfdf..8109eed 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -155,7 +155,7 @@ proc unmerged_files {files} {
 }
 
 proc parseviewargs {n arglist} {
-    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
+    global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs vfileargs env
     global worddiff git_version
 
     set vdatemode($n) 0
@@ -165,6 +165,7 @@ proc parseviewargs {n arglist} {
     set nextisval 0
     set revargs {}
     set origargs $arglist
+    set fileargs {}
     set allknown 1
     set filtered 0
     set i -1
@@ -187,7 +188,7 @@ proc parseviewargs {n arglist} {
 	    "--no-renames" - "--full-index" - "--binary" - "--abbrev=*" -
 	    "--find-copies-harder" - "-l*" - "--ext-diff" - "--no-ext-diff" -
 	    "--src-prefix=*" - "--dst-prefix=*" - "--no-prefix" -
-	    "-O*" - "--text" - "--full-diff" - "--ignore-space-at-eol" -
+	    "-O*" - "--text" - "--ignore-space-at-eol" -
 	    "--ignore-space-change" - "-U*" - "--unified=*" {
 		# These request or affect diff output, which we don't want.
 		# Some could be used to set our defaults for diff display.
@@ -233,6 +234,9 @@ proc parseviewargs {n arglist} {
 		set filtered 1
 		lappend glflags $arg
 	    }
+	    "--full-diff" {
+		lappend fileargs $arg
+	    }
 	    "-n" {
 		# This appears to be the only one that has a value as a
 		# separate word following it
@@ -276,6 +280,7 @@ proc parseviewargs {n arglist} {
     set vrevs($n) $revargs
     set vfiltered($n) $filtered
     set vorigargs($n) $origargs
+    set vfileargs($n) $fileargs
     return $allknown
 }
 
@@ -7519,10 +7524,11 @@ proc diffcmd {ids flags} {
 }
 
 proc gettreediffs {ids} {
-    global treediff treepending limitdiffs vfilelimit curview
+    global treediff treepending limitdiffs vfilelimit vfileargs curview
 
     set cmd [diffcmd $ids {--no-commit-id}]
     if {$limitdiffs && $vfilelimit($curview) ne {}} {
+	    set cmd [concat $cmd $vfileargs($curview)]
 	    set cmd [concat $cmd -- $vfilelimit($curview)]
     }
     if {[catch {set gdtf [open $cmd r]}]} return
@@ -7613,7 +7619,7 @@ proc getblobdiffs {ids} {
     global diffcontext
     global ignorespace
     global worddiff
-    global limitdiffs vfilelimit curview
+    global limitdiffs vfilelimit vfileargs curview
     global diffencoding targetline diffnparents
     global git_version currdiffsubmod
 
@@ -7633,6 +7639,7 @@ proc getblobdiffs {ids} {
 	append cmd " --word-diff=porcelain"
     }
     if {$limitdiffs && $vfilelimit($curview) ne {}} {
+	set cmd [concat $cmd $vfileargs($curview)]
 	set cmd [concat $cmd -- $vfilelimit($curview)]
     }
     if {[catch {set bdf [open $cmd r]} err]} {
-- 
1.8.0.rc2.7.g0961fdf.dirty
Johannes Sixt· Oct 19, 2012, 13:12 UTC · re: Felipe Contreras · lore

Re: [PATCH 0/2] gitk: fix --full-diff handling

Am 10/19/2012 12:56, schrieb Felipe Contreras:
> I find usel to do 'git log --full-duff -- file' to find out all the commits
> that touched the file, and show the full diff (not just the one of the file).
> 
> Unfortunately gitk doesn't honour this option; the diff is limited in the UI.

There is Edit->Preferences->General->Limit diff to listed paths. Doesn't it do what you want if you switch it off?

-- Hannes
Felipe Contreras· Oct 19, 2012, 13:22 UTC · re: Johannes Sixt · lore

Re: [PATCH 0/2] gitk: fix --full-diff handling

On Fri, Oct 19, 2012 at 3:12 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 8 quoted lines
> Am 10/19/2012 12:56, schrieb Felipe Contreras:
>> I find usel to do 'git log --full-duff -- file' to find out all the commits
>> that touched the file, and show the full diff (not just the one of the file).
>>
>> Unfortunately gitk doesn't honour this option; the diff is limited in the UI.
>
> There is Edit->Preferences->General->Limit diff to listed paths. Doesn't
> it do what you want if you switch it off?

Hmm, I guess so, but it's not triggered from the command line. Maybe the --full-diff option should enable that flag.

-- 
Felipe Contreras

← back to recent threads