summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-11-30 15:12:48 +0000
committerPatrick Steinhardt <ps@pks.im>2017-11-30 15:26:05 +0000
commit5ca3f11592426f80c004cea5beefc0d05f23265b (patch)
tree8cede099ba33b4c8b657939eb8bec99422b37148
parent90fc7f5320976ae8b2d9fc0e5f55339bacfca1a6 (diff)
downloadlibgit2-5ca3f11592426f80c004cea5beefc0d05f23265b.tar.gz
diff_generate: fix unsetting diff flags
The macro `DIFF_FLAG_SET` can be used to set or unset a flag by modifying the diff's bitmask. While the case of setting the flag is handled correctly, the case of unsetting the flag was not. Instead of inverting the flags, we are inverting the value which is used to decide whether we want to set or unset the bits. The value being used here is a simple `bool` which is `false`. As that is being uplifted to `int` when getting the bitwise-complement, we will end up retaining all bits inside of the bitmask. As that's only ever used to set `GIT_DIFF_IGNORE_CASE`, we were actually always ignoring case for generated diffs. Fix that by instead getting the bitwise-complement of `FLAG`, not `VAL`.
-rw-r--r--src/diff_generate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/diff_generate.c b/src/diff_generate.c
index 6b3fa4fc5..bce2a683b 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -24,7 +24,7 @@
(((DIFF)->base.opts.flags & (FLAG)) == 0)
#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->base.opts.flags = \
(VAL) ? ((DIFF)->base.opts.flags | (FLAG)) : \
- ((DIFF)->base.opts.flags & ~(VAL))
+ ((DIFF)->base.opts.flags & ~(FLAG))
typedef struct {
struct git_diff base;