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:
@ -257,6 +257,14 @@ int ie_match_stat(const struct index_state *istate,
|
||||
if (!ignore_valid && (ce->ce_flags & CE_VALID))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Intent-to-add entries have not been added, so the index entry
|
||||
* by definition never matches what is in the work tree until it
|
||||
* actually gets added.
|
||||
*/
|
||||
if (ce->ce_flags & CE_INTENT_TO_ADD)
|
||||
return DATA_CHANGED | TYPE_CHANGED | MODE_CHANGED;
|
||||
|
||||
changed = ce_match_stat_basic(ce, st);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user