summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-10-24 10:42:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-10-24 17:54:11 (GMT)
commit2c49f7ffb3063fdccccf2a038ab2eee66e7395e4 (patch)
treef4102aab046ebef724d75da52dbb52008c5cd3f1 /builtin/commit.c
parent018ec3c8203ad1aee683840a580cfba7914419b6 (diff)
downloadgit-2c49f7ffb3063fdccccf2a038ab2eee66e7395e4.zip
git-2c49f7ffb3063fdccccf2a038ab2eee66e7395e4.tar.gz
git-2c49f7ffb3063fdccccf2a038ab2eee66e7395e4.tar.bz2
commit: don't be fooled by ita entries when creating initial commit
ita entries are dropped at tree generation phase. If the entire index consists of just ita entries, the result would be a a commit with no entries, which should be caught unless --allow-empty is specified. The test "!!active_nr" is not sufficient to catch this. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
-rw-r--r--builtin/commit.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/commit.c b/builtin/commit.c
index 400d2a5..1e74bc1 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -894,9 +894,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (amend)
parent = "HEAD^1";
- if (get_sha1(parent, sha1))
- commitable = !!active_nr;
- else {
+ if (get_sha1(parent, sha1)) {
+ int i, ita_nr = 0;
+
+ for (i = 0; i < active_nr; i++)
+ if (ce_intent_to_add(active_cache[i]))
+ ita_nr++;
+ commitable = active_nr - ita_nr > 0;
+ } else {
/*
* Unless the user did explicitly request a submodule
* ignore mode by passing a command line option we do