@@ -1188,6 +1188,19 @@ static void finalize_deferred_config(struct wt_status *s)
1188
1188
s -> ahead_behind_flags = AHEAD_BEHIND_FULL ;
1189
1189
}
1190
1190
1191
+ static void check_fixup_reword_options (int argc , const char * argv []) {
1192
+ if (whence != FROM_COMMIT ) {
1193
+ if (whence == FROM_MERGE )
1194
+ die (_ ("You are in the middle of a merge -- cannot reword." ));
1195
+ else if (is_from_cherry_pick (whence ))
1196
+ die (_ ("You are in the middle of a cherry-pick -- cannot reword." ));
1197
+ }
1198
+ if (argc )
1199
+ die (_ ("cannot combine reword option of --fixup with path '%s'" ), * argv );
1200
+ if (patch_interactive || interactive || all || also || only )
1201
+ die (_ ("reword option of --fixup is mutually exclusive with --patch/--interactive/--all/--include/--only" ));
1202
+ }
1203
+
1191
1204
static int parse_and_validate_options (int argc , const char * argv [],
1192
1205
const struct option * options ,
1193
1206
const char * const usage [],
@@ -1269,8 +1282,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
1269
1282
* We limit --fixup's suboptions to only alpha characters.
1270
1283
* If the first character after a run of alpha is colon,
1271
1284
* then the part before the colon may be a known suboption
1272
- * name `amend` or a misspelt suboption name. In this case,
1273
- * we treat it as --fixup=<suboption>:<arg>.
1285
+ * name like `amend` or `reword`, or a misspelt suboption
1286
+ * name. In either case, we treat it as
1287
+ * --fixup=<suboption>:<arg>.
1274
1288
*
1275
1289
* Otherwise, we are dealing with --fixup=<commit>.
1276
1290
*/
@@ -1280,9 +1294,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
1280
1294
if (p > fixup_message && * p == ':' ) {
1281
1295
* p = '\0' ;
1282
1296
fixup_commit = p + 1 ;
1283
- if (!strcmp ("amend" , fixup_message )) {
1297
+ if (!strcmp ("amend" , fixup_message ) ||
1298
+ !strcmp ("reword" , fixup_message )) {
1284
1299
fixup_prefix = "amend" ;
1285
1300
allow_empty = 1 ;
1301
+ if (* fixup_message == 'r' ) {
1302
+ check_fixup_reword_options (argc , argv );
1303
+ only = 1 ;
1304
+ }
1286
1305
} else {
1287
1306
die (_ ("unknown option: --fixup=%s:%s" ), fixup_message , fixup_commit );
1288
1307
}
@@ -1571,10 +1590,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1571
1590
OPT_STRING ('c' , "reedit-message" , & edit_message , N_ ("commit" ), N_ ("reuse and edit message from specified commit" )),
1572
1591
OPT_STRING ('C' , "reuse-message" , & use_message , N_ ("commit" ), N_ ("reuse message from specified commit" )),
1573
1592
/*
1574
- * TRANSLATORS: Leave "[amend:]" as-is, and
1575
- * only translate <commit>.
1593
+ * TRANSLATORS: Leave "[( amend|reword) :]" as-is,
1594
+ * and only translate <commit>.
1576
1595
*/
1577
- OPT_STRING (0 , "fixup" , & fixup_message , N_ ("[amend:]commit" ), N_ ("use autosquash formatted message to fixup or amend specified commit" )),
1596
+ OPT_STRING (0 , "fixup" , & fixup_message , N_ ("[( amend|reword) :]commit" ), N_ ("use autosquash formatted message to fixup or amend/reword specified commit" )),
1578
1597
OPT_STRING (0 , "squash" , & squash_message , N_ ("commit" ), N_ ("use autosquash formatted message to squash specified commit" )),
1579
1598
OPT_BOOL (0 , "reset-author" , & renew_authorship , N_ ("the commit is authored by me now (used with -C/-c/--amend)" )),
1580
1599
OPT_BOOL ('s' , "signoff" , & signoff , N_ ("add a Signed-off-by trailer" )),
0 commit comments