Using "git reset" in a pre-commit hook can create an empty commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

git version 1.8.4.2
Linux 3.0.74-0.6.8-xen

"git commit" does not properly reevaluate the state after the
pre-commit hook has been executed, and lists files which have been
reset as part of the commit, and will create an empty commit, despite
that no "--allow-empty" was given.

Steps to reproduce:

1. Create a tracked file called "ignoreme"

2. Add the following line to ".git/hooks/pre-commit":

git reset HEAD ignoreme

3. Make a change to the ignoreme file

4. Run "git commit -a"

Result:

The commit template will still list the file:

# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   ignoreme
#


Adding a commit message will create an empty commit:

ign2$ git --no-pager diff HEAD^ HEAD
ign2$

Expected behavior:

- Git should refuse to continue if the pre-commit hook resets all changes
- The commit message should not list files removed from the index


Best Regards
Gunnar Strand
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]