fix indentation on git add --patch

Viewed 288

git diff shows the correct indentation, but git add -p does not. Here's are how the same changes are represented.

$ git diff
diff --git a/utils/utils.go b/utils/utils.go
index 3796954..b755bd5 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -11,7 +11,7 @@ import (
 )

 func LogsDir(homeDir string) string {
-       return filepath.Join(homeDir, "logs")
+       return filepath.Join(homeDirs, "logs")
 }
$ git add -p
diff --git a/utils/utils.go b/utils/utils.go
index 3796954..b755bd5 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -11,7 +11,7 @@ import (
 )

 func LogsDir(homeDir string) string {
-   return filepath.Join(homeDir, "logs")
+ return filepath.Join(homeDirs, "logs")
 }

(1/1) Stage this hunk [y,n,q,a,d,e,?]?

What's wrong with my configuration?

1 Answers

The output of git diff may go through the pager (if git detect that it is longer than one screen ...), and the pager may introduce some formatting of its own before printing on the terminal.

Try running git diff | cat or git --no-pager diff to see if you still have the same output.

Do also check the content of the versioned file (git show HEAD:utils/utils.go > /tmp/utils.go) and the current content of that file on your disk.

Related