Skip to content

Options to only show functional changes in diffs #349

Description

@dgunay

Is your feature request related to a problem? Please describe.

I noticed that diffsitter returns 0 when the two files have the same AST, which is awesome. However, it still produces output if there are nonfunctional changes. Example programs:

package main

import "fmt"

func main() {
	a := "string"
	fmt.Println(a)
}
package main

import "fmt"

// comments in the file
func main() {
	b := "string"
	fmt.Println(b)
}

Produces:

diffsitter a/main.go b/main.go                                                                                                                      main  
a/main.go -> b/main.go
======================

4:
--
+ // comments in the file

6 - 7:
------
+       b := "string"
+       fmt.Println(b)

5 - 6:
------
-       a := "string"
-       fmt.Println(a)

In the event that you have something like a mass refactor which you expect not to have functional changes, if one ends up showing up you are not easily able to find it.

Describe the solution you'd like

I would like it if there were a setting which, when enabled, would make diffsitter print only the changes which meaningfully alter the AST.

Describe alternatives you've considered

I thought about writing my own but it would only support Go. This project seems like a great base to bring this to many languages.

Additional context

I am not sure but I would suspect the various different semantics between languages may make this a somewhat complicated request (I don't know off the top of my head but I suspect, software being the way it is, that there may exist a language or framework where merely changing a variable name has functional impacts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    diff-algoIssues related to the algorithms that compute a diff between two documents.enhancementNew feature or request

    Projects

    Status
    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions