git-commit: add a --interactive option
PATCH 1/1 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.
---
While I agree with the point you make, I suggest that the flow indicated in your message (stash, pick, test, commit, repeat) could be activated exactly by a "commit --interactive" command. Since interactive stuff does not require backward compatibility in general, I would ask to commit my patch anyway, assuming that in the future the feature is rewritten to conform to the flow you indicate -- and at the same time, "add --interactive" is deprecated or even removed.
Documentation/git-commit.txt | 9 +++++++-- git-commit.sh | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-)
Documentation/git-commit.txt +7 -2
@@ -8,8 +8,9 @@ git-commit - Record changes to the repository SYNOPSIS -------- [verse] -'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> | - --amend] [--no-verify] [-e] [--author <author>] +'git-commit' [-a | --interactive] [-s] [-v] + [(-c | -C) <commit> | -F <file> | -m <msg> | --amend] + [--no-verify] [-e] [--author <author>] [--] [[-i | -o ]<file>...] DESCRIPTION
@@ -35,6 +36,10 @@ methods: before, and to automatically "rm" files that have been 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 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
git-commit.sh +16 -5
@@ -3,7 +3,7 @@ # Copyright (c) 2005 Linus Torvalds # 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 . git-sh-setup require_work_tree
@@ -71,6 +71,7 @@ trap ' all= also= +interactive= only= logfile= use_commit=
@@ -131,6 +132,11 @@ do also=t shift ;; + --int|--inte|--inter|--intera|--interac|--interact|--interacti|\ + --interactiv|--interactive) + interactive=t + shift + ;; -o|--o|--on|--onl|--only) only=t shift
@@ -304,12 +310,14 @@ case "$#,$also,$only,$amend" in ;; esac unset only -case "$all,$also,$#" in -t,t,*) - die "Cannot use -a and -i at the same time." ;; +case "$all,$interactive,$also,$#" in +*t,*t,*) + die "Cannot use -a, --interactive or -i at the same time." ;; t,,[1-9]*) 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." ;; esac
@@ -344,6 +352,9 @@ t,) ) || exit ;; ,) + if test "$interactive" = t; then + git add --interactive || exit + fi case "$#" in 0) ;; # commit as-is
Quoted 4 lines · Paolo Bonzini
... Since
interactive stuff does not require backward compatibility in general, I would ask to commit my patch anyway, assuming that in the future the feature is rewritten to conform to the flow you indicate...
I think people feel changes to interactive workflow is a big deal.
Quoted 7 lines
git-commit.sh +0
-0esac unset only
git-commit.sh case "$#,$also,$only,$amend" in · line 322
Quoted 10 lines
git-commit.sh +6
-0+case "$all,$interactive,$also,$#" in +*t,*t,*) + die "Cannot use -a, --interactive or -i at the same time." ;; t,,[1-9]*) die "Paths with -a does not make sense." ;; +,t,[1-9]*) + die "Paths with --interactive does not make sense." ;; +,,t,0) die "No paths with -i does not make sense." ;; esac
Clever.
git-commit.sh t,) · line 360
Quoted 10 lines
git-commit.sh +3
-0@@ -344,6 +352,9 @@ t,) ) || exit ;; ,) + if test "$interactive" = t; then + git add --interactive || exit + fi case "$#" in 0) ;; # commit as-is
If we were to do this, we probably would want a way to exit non-zero from "git-add -i", but I guess we can say we already have that way via ^C.
Will queue for 'next', but it's getting late here so it probably would not appear on the public repository tonight.
Thanks.