@@ -60,7 +60,10 @@ var FieldNames = map[string]string{
6060// Check warns if changes introduce whitespace errors.
6161// Returns non-zero if any issues are found.
6262func Check (commit string ) ([]byte , error ) {
63- cmd := exec .Command ("git" , "show" , "--check" , commit )
63+ cmd := exec .Command ("git" , "--no-pager" , "show" , "--check" , commit )
64+ if debug () {
65+ logrus .Infof ("[git] cmd: %q" , strings .Join (cmd .Args , " " ))
66+ }
6467 cmd .Stderr = os .Stderr
6568 return cmd .Output ()
6669}
@@ -69,7 +72,10 @@ func Check(commit string) ([]byte, error) {
6972//
7073// NOTE: This could be expensive for very large commits.
7174func Show (commit string ) ([]byte , error ) {
72- cmd := exec .Command ("git" , "show" , commit )
75+ cmd := exec .Command ("git" , "--no-pager" , "show" , commit )
76+ if debug () {
77+ logrus .Infof ("[git] cmd: %q" , strings .Join (cmd .Args , " " ))
78+ }
7379 cmd .Stderr = os .Stderr
7480 return cmd .Output ()
7581}
@@ -82,7 +88,10 @@ type CommitEntry map[string]string
8288func LogCommit (commit string ) (* CommitEntry , error ) {
8389 c := CommitEntry {}
8490 for k , v := range FieldNames {
85- cmd := exec .Command ("git" , "log" , "-1" , `--pretty=format:` + k + `` , commit )
91+ cmd := exec .Command ("git" , "--no-pager" , "log" , "-1" , `--pretty=format:` + k + `` , commit )
92+ if debug () {
93+ logrus .Infof ("[git] cmd: %q" , strings .Join (cmd .Args , " " ))
94+ }
8695 cmd .Stderr = os .Stderr
8796 out , err := cmd .Output ()
8897 if err != nil {
@@ -100,7 +109,7 @@ func debug() bool {
100109
101110// FetchHeadCommit returns the hash of FETCH_HEAD
102111func FetchHeadCommit () (string , error ) {
103- cmdArgs := []string {"git" , "rev-parse" , "--verify" , "FETCH_HEAD" }
112+ cmdArgs := []string {"git" , "--no-pager" , " rev-parse" , "--verify" , "FETCH_HEAD" }
104113 if debug () {
105114 logrus .Infof ("[git] cmd: %q" , strings .Join (cmdArgs , " " ))
106115 }
@@ -113,7 +122,7 @@ func FetchHeadCommit() (string, error) {
113122
114123// HeadCommit returns the hash of HEAD
115124func HeadCommit () (string , error ) {
116- cmdArgs := []string {"git" , "rev-parse" , "--verify" , "HEAD" }
125+ cmdArgs := []string {"git" , "--no-pager" , " rev-parse" , "--verify" , "HEAD" }
117126 if debug () {
118127 logrus .Infof ("[git] cmd: %q" , strings .Join (cmdArgs , " " ))
119128 }
0 commit comments