summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-07-11 12:10:48 +0200
committerPatrick Steinhardt <ps@pks.im>2020-03-26 16:20:11 +0100
commitb8339912db0a02091f630c083dc1f4c2cd02cb11 (patch)
tree7a2185148e4b9946f178e8588861f4950b4f4bc8
parentef1651e64351eb8a7b11b4132c42464dbe8f386b (diff)
downloadlibgit2-b8339912db0a02091f630c083dc1f4c2cd02cb11.tar.gz
apply: refactor to use a switch statement
-rw-r--r--src/apply.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/apply.c b/src/apply.c
index 0becf9495..ddf4fbefc 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -206,16 +206,20 @@ static int apply_hunk(
goto done;
}
- if (line->origin == GIT_DIFF_LINE_CONTEXT ||
- line->origin == GIT_DIFF_LINE_DELETION) {
- if ((error = git_vector_insert(&preimage.lines, line)) < 0)
- goto done;
- }
-
- if (line->origin == GIT_DIFF_LINE_CONTEXT ||
- line->origin == GIT_DIFF_LINE_ADDITION) {
- if ((error = git_vector_insert(&postimage.lines, line)) < 0)
- goto done;
+ switch (line->origin) {
+ case GIT_DIFF_LINE_CONTEXT:
+ if ((error = git_vector_insert(&preimage.lines, line)) < 0 ||
+ (error = git_vector_insert(&postimage.lines, line)) < 0)
+ goto done;
+ break;
+ case GIT_DIFF_LINE_DELETION:
+ if ((error = git_vector_insert(&preimage.lines, line)) < 0)
+ goto done;
+ break;
+ case GIT_DIFF_LINE_ADDITION:
+ if ((error = git_vector_insert(&postimage.lines, line)) < 0)
+ goto done;
+ break;
}
}