Skip to content

Commit 2d9d246

Browse files
committed
diff: fix enum value being out of allowed range
The C89 standard states in §6.7.2.2 "Enumeration specifiers": > The expression that defines the value of an enumeration constant shall > be an integer constant expression that has a value representable as an > int. On most platforms, this effectively limits the range to a 32 bit signed integer. The enum `git_diff_option_t` though recently gained an entry `GIT_DIFF_INDENT_HEURISTIC = (1u << 31)`, which breaks this limit. Fix the issue by using a gap in `git_diff_option_t`'s enum values. While this has the benefit of retaining our API, it may break applications which do not get recompiled after upgrading libgit2. But as we are bumping the soversion on each release anyway and thus force a recompile of dependents, this is not a problem.
1 parent 795a5b2 commit 2d9d246

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

include/git2/diff.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ typedef enum {
171171
* Options controlling how output will be generated
172172
*/
173173

174+
/** Use a heuristic that takes indentation and whitespace into account
175+
* which generally can produce better diffs when dealing with ambiguous
176+
* diff hunks.
177+
*/
178+
GIT_DIFF_INDENT_HEURISTIC = (1u << 18),
179+
174180
/** Treat all files as text, disabling binary attributes & detection */
175181
GIT_DIFF_FORCE_TEXT = (1u << 20),
176182
/** Treat all files as binary, disabling text diffs */
@@ -206,12 +212,6 @@ typedef enum {
206212
* can apply given diff information to binary files.
207213
*/
208214
GIT_DIFF_SHOW_BINARY = (1u << 30),
209-
210-
/** Use a heuristic that takes indentation and whitespace into account
211-
* which generally can produce better diffs when dealing with ambiguous
212-
* diff hunks.
213-
*/
214-
GIT_DIFF_INDENT_HEURISTIC = (1u << 31),
215215
} git_diff_option_t;
216216

217217
/**

0 commit comments

Comments
 (0)