Commit d536ceacf56e0ff1f02c8dc29d496bc1c357914f

Edward Thomson 2015-09-23T10:47:34

patch_parse: don't set new mode when deleted

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/patch_parse.c b/src/patch_parse.c
index f375688..df2492e 100644
--- a/src/patch_parse.c
+++ b/src/patch_parse.c
@@ -881,10 +881,10 @@ static int check_patch(git_patch_parsed *patch)
 			patch->base.delta->status != GIT_DELTA_DELETED)
 		return parse_err("missing new file path");
 
-	if (patch->base.delta->old_file.path && patch->base.delta->new_file.path) {
-		if (!patch->base.delta->new_file.mode)
-			patch->base.delta->new_file.mode = patch->base.delta->old_file.mode;
-	}
+	if (patch->base.delta->old_file.path &&
+			patch->base.delta->status != GIT_DELTA_DELETED &&
+			!patch->base.delta->new_file.mode)
+		patch->base.delta->new_file.mode = patch->base.delta->old_file.mode;
 
 	if (patch->base.delta->status == GIT_DELTA_MODIFIED &&
 		!(patch->base.delta->flags & GIT_DIFF_FLAG_BINARY) &&