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>
Paolo Bonzini committed
Mar 5, 2007 at 08:57 UTC
6cbf07efc5702351897dee4742525c9b9f7828ac
2 files changed
+23
-7
Documentation/git-commit.txt
+7
-2
@@ -8,8 +8,9 @@ git-commit - Record changes to the repository
8
SYNOPSIS
9
--------
10
[verse]
11
-'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> |
12
- --amend] [--no-verify] [-e] [--author <author>]
11
+'git-commit' [-a | --interactive] [-s] [-v]
12
+ [(-c | -C) <commit> | -F <file> | -m <msg> | --amend]
13
+ [--no-verify] [-e] [--author <author>]
14
[--] [[-i | -o ]<file>...]
15
16
DESCRIPTION
@@ -35,6 +36,10 @@ methods:
36
before, and to automatically "rm" files that have been
37
removed from the working tree, and perform the actual commit.
38
39
+5. by using the --interactive switch with the 'commit' command to decide one
40
+ by one which files should be part of the commit, before finalizing the
41
+ operation. Currently, this is done by invoking `git-add --interactive`.
42
+
43
The gitlink:git-status[1] command can be used to obtain a
44
summary of what is included by any of the above for the next
45
commit by giving the same set of parameters you would give to
git-commit.sh
+16
-5
@@ -3,7 +3,7 @@
3
# Copyright (c) 2005 Linus Torvalds
4
# Copyright (c) 2006 Junio C Hamano
5
6
-USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
6
+USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
7
SUBDIRECTORY_OK=Yes
8
. git-sh-setup
9
require_work_tree
@@ -71,6 +71,7 @@ trap '
71
72
all=
73
also=
74
+interactive=
75
only=
76
logfile=
77
use_commit=
@@ -131,6 +132,11 @@ do
132
also=t
133
shift
134
;;
135
+ --int|--inte|--inter|--intera|--interac|--interact|--interacti|\
136
+ --interactiv|--interactive)
137
+ interactive=t
138
+ shift
139
+ ;;
140
-o|--o|--on|--onl|--only)
141
only=t
142
shift
@@ -304,12 +310,14 @@ case "$#,$also,$only,$amend" in
310
;;
311
esac
312
unset only
307
-case "$all,$also,$#" in
308
-t,t,*)
309
- die "Cannot use -a and -i at the same time." ;;
313
+case "$all,$interactive,$also,$#" in
314
+*t,*t,*)
315
+ die "Cannot use -a, --interactive or -i at the same time." ;;
316
t,,[1-9]*)
317
die "Paths with -a does not make sense." ;;
312
-,t,0)
318
+,t,[1-9]*)
319
+ die "Paths with --interactive does not make sense." ;;
320
+,,t,0)
321
die "No paths with -i does not make sense." ;;
322
esac
323
@@ -344,6 +352,9 @@ t,)
352
) || exit
353
;;
354
,)
355
+ if test "$interactive" = t; then
356
+ git add --interactive || exit
357
+ fi
358
case "$#" in
359
0)
360
;; # commit as-is