Raimund Bauer offered this suggestion (paraphrased):
"Maybe we could do git-commit -a _only_ if the index matches HEAD, and
otherwise keep current behavior? So people who don't care about the
index won't get tripped up, and when you do have a dirty index, you get
told about it?"Johannes Schindelin pointed out that this isn't the right thing to do for
an --amend, so that is checked for. Additionally, it's probably not the
right thing to do if any files are specified with "--only" or
"--include", so they turn this behaviour off as well.Nguyen Thai Ngoc Duy asked that git-commit let you know it's done this
by adding an extra comment to the commit message.Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
This time we also inhibit if "all" mode is already set; if the user
has specified "-a" we don't need to tell them that we've switched "-a"
mode on.git-commit.sh | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)diff --git a/git-commit.sh b/git-commit.sh
index 81c3a0c..4552727 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -265,6 +265,16 @@ $1"
done
case "$edit_flag" in t) no_edit= ;; esac+# Clever commit - if this commit would do nothing, then make it an "all"
+# commit
+if [ -z "$(git-diff-index --cached --name-only HEAD)" \
+ -a -z "$amend" -a -z "$only" -a -z "$also" -a -z "$all" ]; then
+ echo "# There was nothing to commit but changes were detected in the" > $GIT_DIR/SQUASH_MSG
+ echo "# working tree. 'git commit -a' mode activated." >> $GIT_DIR/SQUASH_MSG
+ echo "#" >> $GIT_DIR/SQUASH_MSG
+ all=t
+fi
+
################################################################
# Sanity check options--
1.4.4.1.g3ece-dirty-
I think another exception should be needed. If the index does
not match the working tree, it should not default to "-a".Otherwise,
I want to fix another thing in pickaxe.
$ edit builtin-blame.c
My wife calls me. Away from desk for 20 minutes. Later I come
back.$ git update-index builtin-pickaxe.c
I am so used to that name and did not realize that typo, and I
was not paying too much attention. My wife calls me again.
Away from desk and back in 20 minutes.$ git commit -m 'git-blame: Another fix.'
Oops.
So, please turn this "cleverness" off when the index does not
match the working tree.-
No problem: just don't apply the patch :-) What you've asked for leaves it as
a no-op.This patch activates "-a" when the index equals HEAD. i.e. git-commit would
do nothing in this situation. If it is disabled when the index doesn't match
the working tree, then we're back to "do nothing". i.e. HEAD==index==workingHow does that help you? You've updated the index manually, so the
automatic "-a" is already disabled. Without this patch you would still have
committed the wrong thing.$ edit builtin-blame.c
$ git update-index builtin-pickaxe.c
$ git commitWhat is that you would like to have happened at this point?
Andy
--
Dr Andy Parkins, M Eng (hons), MIEE
andyparkins@gmail.com
-
I think there needs a bit of explanation and additional step
that happened here. This by the way is not a made-up example.
Everything, including the 20-minute away, were what happened
when I did the latest blame fix you saw a few days ago.* I am still futzing with blame from time to time, and have
this change almost permanently in my working tree.$ cat P.diff
diff --git a/builtin-blame.c b/builtin-blame.c
index dc3ffea..46ce45c 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -38,7 +38,7 @@ static int max_digits;
static int max_score_digits;#ifndef DEBUG
-#define DEBUG 0
+#define DEBUG 1
#endif* And then reverted the DEBUG back to 0 in preparation for
"checking into the index"* And then I reverted it back for later futing.
* Oops here is not just that builtin-blame.c would have been
committed; I'd almost never do "commit -a" in this repository,
because it would take that "DEBUG 1" change _and_-
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| david | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
| Linus Torvalds | Linux 2.6.25-rc4 |
git: | |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 13/37] dccp: Deprecate Ack Ratio sysctl |
| Vladimir Ivashchenko | Re: HTB accuracy for high speed |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
