summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-01-25 18:57:45 -0500
committerJunio C Hamano <gitster@pobox.com>2020-01-27 11:17:41 -0800
commit4c616c2ba1c176573bd1ae7c4ec3271d1f175448 (patch)
treeb5c6c4ef5f8a8eef6518a0623ef498be9551e3eb /merge-recursive.c
parentee798742bd35d88770e4ef05a7944b5783790e60 (diff)
downloadgit-4c616c2ba1c176573bd1ae7c4ec3271d1f175448.tar.gz
merge-recursive: use subtraction to flip stage
The flip_stage() helper uses a bit-flipping xor to switch between "2" and "3". While clever, this relies on a property of those two numbers that is mostly coincidence. Let's write it as a subtraction; that's more clear and would extend to other numbers if somebody copies the logic. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index e6aedd3cab..aee1769a7a 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1713,12 +1713,11 @@ static char *find_path_for_conflict(struct merge_options *opt,
}
/*
- * Toggle the stage number between "ours" and "theirs" (2 and 3) by flipping
- * the 1-bit.
+ * Toggle the stage number between "ours" and "theirs" (2 and 3).
*/
static inline int flip_stage(int stage)
{
- return stage ^ 1;
+ return (2 + 3) - stage;
}
static int handle_rename_rename_1to2(struct merge_options *opt,