diff options
author | Patrick Steinhardt <ps@pks.im> | 2019-07-11 12:10:48 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2019-07-11 12:10:48 +0200 |
commit | b30dab8fa7e1c2d6bd938cd5941c9d1cd55a0004 (patch) | |
tree | 1089b6ec7260f4fbc24c8f684a979b0693a43b16 | |
parent | 001d76e1fe783448cd6d241c59cf69b1e0dd1aaa (diff) | |
download | libgit2-b30dab8fa7e1c2d6bd938cd5941c9d1cd55a0004.tar.gz |
apply: refactor to use a switch statement
-rw-r--r-- | src/apply.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/apply.c b/src/apply.c index f876e437e..291d63b8d 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; } } |