git-commit: add a --interactive option

The --interactive option behaves like "git commit", except that
"git add --interactive" is executed before committing.  It is
incompatible with -a and -i.

Signed-off-by: Paolo Bonzini  <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Paolo Bonzini 2007-03-05 08:57:53 +01:00 committed by Junio C Hamano
parent bd1fc628b8
commit 6cbf07efc5
2 changed files with 23 additions and 7 deletions

View file

@ -8,8 +8,9 @@ git-commit - Record changes to the repository
SYNOPSIS SYNOPSIS
-------- --------
[verse] [verse]
'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> | 'git-commit' [-a | --interactive] [-s] [-v]
--amend] [--no-verify] [-e] [--author <author>] [(-c | -C) <commit> | -F <file> | -m <msg> | --amend]
[--no-verify] [-e] [--author <author>]
[--] [[-i | -o ]<file>...] [--] [[-i | -o ]<file>...]
DESCRIPTION DESCRIPTION
@ -35,6 +36,10 @@ methods:
before, and to automatically "rm" files that have been before, and to automatically "rm" files that have been
removed from the working tree, and perform the actual commit. removed from the working tree, and perform the actual commit.
5. by using the --interactive switch with the 'commit' command to decide one
by one which files should be part of the commit, before finalizing the
operation. Currently, this is done by invoking `git-add --interactive`.
The gitlink:git-status[1] command can be used to obtain a The gitlink:git-status[1] command can be used to obtain a
summary of what is included by any of the above for the next summary of what is included by any of the above for the next
commit by giving the same set of parameters you would give to commit by giving the same set of parameters you would give to

View file

@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds # Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2006 Junio C Hamano # Copyright (c) 2006 Junio C Hamano
USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]' USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
. git-sh-setup . git-sh-setup
require_work_tree require_work_tree
@ -71,6 +71,7 @@ trap '
all= all=
also= also=
interactive=
only= only=
logfile= logfile=
use_commit= use_commit=
@ -131,6 +132,11 @@ do
also=t also=t
shift shift
;; ;;
--int|--inte|--inter|--intera|--interac|--interact|--interacti|\
--interactiv|--interactive)
interactive=t
shift
;;
-o|--o|--on|--onl|--only) -o|--o|--on|--onl|--only)
only=t only=t
shift shift
@ -304,12 +310,14 @@ case "$#,$also,$only,$amend" in
;; ;;
esac esac
unset only unset only
case "$all,$also,$#" in case "$all,$interactive,$also,$#" in
t,t,*) *t,*t,*)
die "Cannot use -a and -i at the same time." ;; die "Cannot use -a, --interactive or -i at the same time." ;;
t,,[1-9]*) t,,[1-9]*)
die "Paths with -a does not make sense." ;; die "Paths with -a does not make sense." ;;
,t,0) ,t,[1-9]*)
die "Paths with --interactive does not make sense." ;;
,,t,0)
die "No paths with -i does not make sense." ;; die "No paths with -i does not make sense." ;;
esac esac
@ -344,6 +352,9 @@ t,)
) || exit ) || exit
;; ;;
,) ,)
if test "$interactive" = t; then
git add --interactive || exit
fi
case "$#" in case "$#" in
0) 0)
;; # commit as-is ;; # commit as-is