@@ -96,6 +96,7 @@ func mainMode(cmd *cobra.Command, args []string, cfg *config.Cfg) {
96
96
97
97
commitParams := getGitCommitCmd (cmd )
98
98
committingAllChanges , _ := cmd .Flags ().GetBool ("all" )
99
+ allowEmpty , _ := cmd .Flags ().GetBool ("allow-empty" )
99
100
if ! cfg .DryRun && ! committingAllChanges {
100
101
buf := & bytes.Buffer {}
101
102
process := exec .Command ("git" , "diff" , "--name-only" , "--cached" )
@@ -104,7 +105,7 @@ func mainMode(cmd *cobra.Command, args []string, cfg *config.Cfg) {
104
105
if err != nil {
105
106
log .Fatalf ("fatal: not a git repository (or any of the parent directories): .git; %+v" , err )
106
107
}
107
- if buf .String () == "" {
108
+ if buf .String () == "" && ! allowEmpty {
108
109
log .Fatal ("No files staged" )
109
110
}
110
111
}
@@ -294,6 +295,7 @@ func init() {
294
295
flags .StringArrayP ("message" , "m" , []string {}, "pass a complete conventional commit. If valid, it'll be committed without editing." )
295
296
flags .Bool ("version" , false , "print the version" )
296
297
flags .Bool ("show-config" , false , "print the path to the config file and the relevant config " )
298
+ flags .Bool ("allow-empty" , false , "delegated to git-commit" )
297
299
// TODO: accept more of git commit's flags; see https://git-scm.com/docs/git-commit
298
300
// likely: --cleanup=<mode>
299
301
// more difficult, and possibly better done manually: --amend, -C <commit>
0 commit comments