Skip to content

Instantly share code, notes, and snippets.

@tkf
Last active June 28, 2016 18:57
Show Gist options
  • Save tkf/12bde871bf794e59bea88b659ed5b95b to your computer and use it in GitHub Desktop.
Save tkf/12bde871bf794e59bea88b659ed5b95b to your computer and use it in GitHub Desktop.
#!/bin/bash -e
bin="${BASH_SOURCE[0]%.*}"
go build -o "$bin" "$bin.go"
for file in "$@"
do
for rev in $(git log --format='format:%H' "$file" | head -n-1)
do
if ! diff <("$bin" <(git show "$rev:./$file") <(git show "$rev^:./$file")) <(git show "$rev:./$file") >&2
then
echo "$rev:./$file"
fi
done
done
package main
import (
"io"
"io/ioutil"
"os"
"time"
"github.com/sergi/go-diff/diffmatchpatch"
)
func readall(path string) string {
file, _ := os.Open(path)
text, _ := ioutil.ReadAll(file)
return string(text)
}
func main() {
text1 := readall(os.Args[1])
text2 := readall(os.Args[2])
dmp := diffmatchpatch.New()
dmp.DiffTimeout = time.Hour
// dmp.DiffTimeout = 0
diffs := dmp.DiffMain(text1, text2, true)
io.WriteString(os.Stdout, dmp.DiffText1(diffs))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment