diff mbox series

[HYPOTHETICAL,1/2] apply: reject modification diffs to i-t-a entries

Message ID 20200808075827.36248-2-ray@ameretat.dev (mailing list archive)
State New, archived
Headers show
Series apply: reject modification diffs to i-t-a entries | expand

Commit Message

Raymond E. Pasco Aug. 8, 2020, 7:58 a.m. UTC
Because the correct diff between an i-t-a entry and a new file is now a
creation diff, reject diffs from the empty blob as not applying to the
preimage.

Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
---
 apply.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/apply.c b/apply.c
index c5ecb64102..656f00c113 100644
--- a/apply.c
+++ b/apply.c
@@ -3637,6 +3637,9 @@  static int apply_data(struct apply_state *state, struct patch *patch,
 	if (load_preimage(state, &image, patch, st, ce) < 0)
 		return -1;
 
+	if (!(patch->is_new || patch->is_delete) && ce->ce_flags & CE_INTENT_TO_ADD)
+		return -1;
+
 	if (patch->direct_to_threeway ||
 	    apply_fragments(state, &image, patch) < 0) {
 		/* Note: with --reject, apply_fragments() returns 0 */