git add --intent-to-add: do not let an empty blob be committed by accident

Writing a tree out of an index with an "intent to add" entry is blocked.
This implies that you cannot "git commit" from such a state; however you
can still do "git commit -a" or "git commit $that_path".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2008-11-28 19:56:34 -08:00
parent 388b2acd6e
commit 331fcb598e
5 changed files with 45 additions and 5 deletions

View File

@ -155,13 +155,17 @@ static int verify_cache(struct cache_entry **cache,
funny = 0;
for (i = 0; i < entries; i++) {
struct cache_entry *ce = cache[i];
if (ce_stage(ce)) {
if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
if (10 < ++funny) {
fprintf(stderr, "...\n");
break;
}
fprintf(stderr, "%s: unmerged (%s)\n",
ce->name, sha1_to_hex(ce->sha1));
if (ce_stage(ce))
fprintf(stderr, "%s: unmerged (%s)\n",
ce->name, sha1_to_hex(ce->sha1));
else
fprintf(stderr, "%s: not added yet\n",
ce->name);
}
}
if (funny)