From: Gary V. Vaughan <g...@gnu.org> * clcommit.m4sh (func_commit): Commit only staged files instead of passing `-a' when no file list was given on the command line.
Signed-off-by: Gary V. Vaughan <g...@gnu.org> --- ChangeLog | 6 ++++++ clcommit.m4sh | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3287b2..49fe694 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-08-27 Gary V. Vaughan <g...@gnu.org> + + Fix partial commit support. + * clcommit.m4sh (func_commit): Commit only staged files instead + of passing `-a' when no file list was given on the command line. + 2010-08-26 Gary V. Vaughan <g...@gnu.org> Add --gnulib-version and --news options to announce-gen. diff --git a/clcommit.m4sh b/clcommit.m4sh index 8292d6a..f916cd9 100644 --- a/clcommit.m4sh +++ b/clcommit.m4sh @@ -268,11 +268,18 @@ func_commit () sleep 1 # give the user some time for a ^C - subject=`git status 2>/dev/null | $SED -n 's/^#.*[mad][ode][dl].*ed: *//p'` - test $# -gt 0 && subject="$@" + if test $# -gt 0; then + # Given a list of files to commit from the command line: unstage all + # files, and add back those in the list... + for staged in `$GIT status -s --porcelain 2>/dev/null | $SED -n 's/^M. //p'` + do + $GIT reset -- $staged + done + $GIT add ${1+"$@"} + fi + # ...otherwise, by default, only staged files are committed. - test $# -gt 0 || { set dummy -a; shift; } - func_show_eval "$GIT commit $git_flags -F $log_file ${...@}" "exit $EXIT_FAILURE" + func_show_eval "$GIT commit $git_flags -F $log_file" "exit $EXIT_FAILURE" $opt_push && { func_show_eval "$GIT push" -- 1.7.2.2