Code

Fix 'git commit -a' in a newly initialized repository
authorFredrik Kuivinen <frekui@gmail.com>
Thu, 22 Feb 2007 20:28:12 +0000 (21:28 +0100)
committerJunio C Hamano <junkio@cox.net>
Fri, 23 Feb 2007 05:02:39 +0000 (21:02 -0800)
With current git:

$ git init
$ git commit -a
cp: cannot stat `.git/index': No such file or directory

Output a nice error message instead.

Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-commit.sh

index ec506d956fa2858897c53b35d28db8083b7fdcec..476f4f18dbb76041fbbfe6243785ad4997a7e7c7 100755 (executable)
@@ -318,6 +318,10 @@ esac
 
 case "$all,$also" in
 t,)
+       if test ! -f "$THIS_INDEX"
+       then
+               die 'nothing to commit (use "git add file1 file2" to include for commit)'
+       fi
        save_index &&
        (
                cd_to_toplevel &&