File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
git-branchless-record/src Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,10 @@ pub struct RecordArgs {
334
334
/// How should newly encountered, untracked files be handled?
335
335
#[ clap( value_parser, long = "untracked" , conflicts_with_all( & [ "interactive" ] ) ) ]
336
336
pub untracked_file_strategy : Option < UntrackedFileStrategy > ,
337
+
338
+ /// Allow creating an empty commit.
339
+ #[ clap( action, long = "allow-empty" ) ]
340
+ pub allow_empty : bool ,
337
341
}
338
342
339
343
/// Display a nice graph of the commits you've recently worked on.
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ pub fn command_main(ctx: CommandContext, args: RecordArgs) -> EyreExitOr<()> {
60
60
insert,
61
61
stash,
62
62
untracked_file_strategy,
63
+ allow_empty,
63
64
} = args;
64
65
record (
65
66
& effects,
@@ -71,6 +72,7 @@ pub fn command_main(ctx: CommandContext, args: RecordArgs) -> EyreExitOr<()> {
71
72
insert,
72
73
stash,
73
74
untracked_file_strategy,
75
+ allow_empty,
74
76
)
75
77
}
76
78
@@ -85,6 +87,7 @@ fn record(
85
87
insert : bool ,
86
88
stash : bool ,
87
89
untracked_file_strategy : Option < UntrackedFileStrategy > ,
90
+ allow_empty : bool ,
88
91
) -> EyreExitOr < ( ) > {
89
92
let now = SystemTime :: now ( ) ;
90
93
let repo = Repo :: from_dir ( & git_run_info. working_directory ) ?;
@@ -113,7 +116,7 @@ fn record(
113
116
) ?)
114
117
} ;
115
118
116
- if files_to_add. is_empty ( ) {
119
+ if files_to_add. is_empty ( ) && !allow_empty {
117
120
writeln ! (
118
121
effects. get_output_stream( ) ,
119
122
"There are no changes to tracked files in the working copy to commit."
@@ -222,6 +225,9 @@ fn record(
222
225
if working_copy_changes_type == WorkingCopyChangesType :: Unstaged {
223
226
args. push ( "--all" ) ;
224
227
}
228
+ if allow_empty {
229
+ args. push ( "--allow-empty" ) ;
230
+ }
225
231
args
226
232
} ;
227
233
try_exit_code ! ( git_run_info. run_direct_no_wrapping( Some ( event_tx_id) , & args) ?) ;
You can’t perform that action at this time.
0 commit comments