@@ -57,8 +57,20 @@ func (self *DiffHelper) GetUpdateTaskForRenderingCommitsDiff(commit *models.Comm
5757 from , to := refRange .From , refRange .To
5858 args := []string {from .ParentRefName (), to .RefName (), "--stat" , "-p" }
5959 args = append (args , "--" )
60- if path := self .c .Modes ().Filtering .GetPath (); path != "" {
61- args = append (args , path )
60+ if filterPath := self .c .Modes ().Filtering .GetPath (); filterPath != "" {
61+ // If both refs are commits, filter by the union of their paths. This is useful for
62+ // example when diffing a range of commits in filter-by-path mode across a rename.
63+ fromCommit , ok1 := from .(* models.Commit )
64+ toCommit , ok2 := to .(* models.Commit )
65+ if ok1 && ok2 {
66+ paths := append (self .FilterPathsForCommit (fromCommit ), self .FilterPathsForCommit (toCommit )... )
67+ args = append (args , lo .Uniq (paths )... )
68+ } else {
69+ // If either ref is not a commit (which is possible in sticky diff mode, when
70+ // diffing against a branch or tag), we just filter by the filter path; that's the
71+ // best we can do in this case.
72+ args = append (args , filterPath )
73+ }
6274 }
6375 cmdObj := self .c .Git ().Diff .DiffCmdObj (args )
6476 prefix := style .FgYellow .Sprintf ("%s %s-%s\n \n " , self .c .Tr .ShowingDiffForRange , from .ShortRefName (), to .ShortRefName ())
0 commit comments