Skip to content

Commit ba7c3b1

Browse files
authored
Merge pull request #37 from dtaniwaki/handle-empty-patch
Handle empty patch
2 parents 81ef491 + 81380b6 commit ba7c3b1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/ghost/git/file.go

+13
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ func AppendNonIndexedDiffFiles(dir, filepath string, nonIndexedFilepaths []strin
110110

111111
// ApplyDiffPatchFile apply a diff file created by CreateDiffPatchFile
112112
func ApplyDiffPatchFile(dir, filepath string) errors.GitGhostError {
113+
// Handle empty patch
114+
fi, err := os.Stat(filepath)
115+
if err != nil {
116+
return errors.WithStack(err)
117+
}
118+
if fi.Size() == 0 {
119+
log.WithFields(util.MergeFields(
120+
log.Fields{
121+
"srcDir": dir,
122+
"filepath": filepath,
123+
})).Info("ignore empty patch")
124+
return nil
125+
}
113126
return util.JustRunCmd(
114127
exec.Command("git", "-C", dir, "apply", filepath),
115128
)

0 commit comments

Comments
 (0)