@@ -83,7 +83,7 @@ static const char *template_file;
8383static const char * author_message , * author_message_buffer ;
8484static char * edit_message , * use_message ;
8585static char * fixup_message , * squash_message ;
86- static int all , edit_flag , also , interactive , only , amend , signoff ;
86+ static int all , edit_flag , also , interactive , patch_interactive , only , amend , signoff ;
8787static int quiet , verbose , no_verify , allow_empty , dry_run , renew_authorship ;
8888static int no_post_rewrite , allow_empty_message ;
8989static char * untracked_files_arg , * force_date , * ignore_submodule_arg ;
@@ -152,6 +152,7 @@ static struct option builtin_commit_options[] = {
152152 OPT_BOOLEAN ('a' , "all" , & all , "commit all changed files" ),
153153 OPT_BOOLEAN ('i' , "include" , & also , "add specified files to index for commit" ),
154154 OPT_BOOLEAN (0 , "interactive" , & interactive , "interactively add files" ),
155+ OPT_BOOLEAN ('p' , "patch" , & patch_interactive , "interactively add changes" ),
155156 OPT_BOOLEAN ('o' , "only" , & only , "commit only specified files" ),
156157 OPT_BOOLEAN ('n' , "no-verify" , & no_verify , "bypass pre-commit hook" ),
157158 OPT_BOOLEAN (0 , "dry-run" , & dry_run , "show what would be committed" ),
@@ -360,7 +361,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
360361 old_index_env = getenv (INDEX_ENVIRONMENT );
361362 setenv (INDEX_ENVIRONMENT , index_lock .filename , 1 );
362363
363- if (interactive_add (argc , argv , prefix ) != 0 )
364+ if (interactive_add (argc , argv , prefix , patch_interactive ) != 0 )
364365 die (_ ("interactive add failed" ));
365366
366367 if (old_index_env && * old_index_env )
@@ -1061,8 +1062,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
10611062 author_message_buffer = read_commit_message (author_message );
10621063 }
10631064
1065+ if (patch_interactive )
1066+ interactive = 1 ;
1067+
10641068 if (!!also + !!only + !!all + !!interactive > 1 )
1065- die (_ ("Only one of --include/--only/--all/--interactive can be used." ));
1069+ die (_ ("Only one of --include/--only/--all/--interactive/--patch can be used." ));
10661070 if (argc == 0 && (also || (only && !amend )))
10671071 die (_ ("No paths with --include/--only does not make sense." ));
10681072 if (argc == 0 && only && amend )
0 commit comments