Skip to content

Commit

Permalink
Fix: Always Use Default Diff
Browse files Browse the repository at this point in the history
This fix resolves issues that arise when the user has configured an
alternative diff provider through diff.external. It also ensures that
the default prefix setting is consistently used, allowing `revgrep` to
operate correctly regardless of user settings.
  • Loading branch information
dan-smetana authored and ldez committed Sep 2, 2023
1 parent 66007ad commit 52c4d25
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 52c4d25

Please sign in to comment.