Skip to content

Commit

Permalink
fix: force use of default diff (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-smetana authored Sep 2, 2023
1 parent 66007ad commit 358f9e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions revgrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
}

if revisionFrom != "" {
cmd := exec.Command("git", "diff", "--color=never", "--relative", revisionFrom)
cmd := exec.Command("git", "diff", "--color=never", "--no-ext-diff", "--default-prefix", "--relative", revisionFrom)
if revisionTo != "" {
cmd.Args = append(cmd.Args, revisionTo)
}
Expand All @@ -384,8 +384,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {
}

// make a patch for unstaged changes
// use --no-prefix to remove b/ given: +++ b/main.go
cmd := exec.Command("git", "diff", "--color=never", "--relative", "--")
cmd := exec.Command("git", "diff", "--color=never", "--no-ext-diff", "--default-prefix", "--relative", "--")
cmd.Stdout = &patch
if err := cmd.Run(); err != nil {
return nil, nil, fmt.Errorf("error executing git diff: %w", err)
Expand All @@ -400,7 +399,7 @@ func GitPatch(revisionFrom, revisionTo string) (io.Reader, []string, error) {

// check for changes in recent commit

cmd = exec.Command("git", "diff", "--color=never", "--relative", "HEAD~", "--")
cmd = exec.Command("git", "diff", "--color=never", "--no-ext-diff", "--default-prefix", "--relative", "HEAD~", "--")
cmd.Stdout = &patch
if err := cmd.Run(); err != nil {
return nil, nil, fmt.Errorf("error executing git diff HEAD~: %w", err)
Expand Down

0 comments on commit 358f9e2

Please sign in to comment.