Skip to content

Commit 5ca3f11

Browse files
committed
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`.
1 parent 90fc7f5 commit 5ca3f11

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/diff_generate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(((DIFF)->base.opts.flags & (FLAG)) == 0)
2525
#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->base.opts.flags = \
2626
(VAL) ? ((DIFF)->base.opts.flags | (FLAG)) : \
27-
((DIFF)->base.opts.flags & ~(VAL))
27+
((DIFF)->base.opts.flags & ~(FLAG))
2828

2929
typedef struct {
3030
struct git_diff base;

0 commit comments

Comments
 (0)