summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-11-28 19:56:34 -0800
committerJunio C Hamano <gitster@pobox.com>2008-11-30 17:59:19 -0800
commit331fcb598ec0127fd89c992361bc573dcd3a4a63 (patch)
treea6ef30a49739d914475a5c4bba38d98d2b8a6cae /cache-tree.c
parent388b2acd6e649145d4368a10cf4df5f5bbbac2c2 (diff)
downloadgit-331fcb598ec0127fd89c992361bc573dcd3a4a63.tar.gz
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>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 5f8ee87bb1..3d8f218a5f 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -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)