diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-10-15 13:48:00 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-15 13:48:00 +0900 |
commit | 6d5291be450594d453759650f466174f39953c4f (patch) | |
tree | bc8f0616f6748e59e43105c78f5c4505565ab76d /cache.h | |
parent | Merge branch 'gs/commit-graph-trace-with-cmd' (diff) | |
parent | ci: also build and test with MS Visual Studio on Azure Pipelines (diff) | |
download | tgif-6d5291be450594d453759650f466174f39953c4f.tar.xz |
Merge branch 'js/azure-pipelines-msvc'
CI updates.
* js/azure-pipelines-msvc:
ci: also build and test with MS Visual Studio on Azure Pipelines
ci: really use shallow clones on Azure Pipelines
tests: let --immediate and --write-junit-xml play well together
test-tool run-command: learn to run (parts of) the testsuite
vcxproj: include more generated files
vcxproj: only copy `git-remote-http.exe` once it was built
msvc: work around a bug in GetEnvironmentVariable()
msvc: handle DEVELOPER=1
msvc: ignore some libraries when linking
compat/win32/path-utils.h: add #include guards
winansi: use FLEX_ARRAY to avoid compiler warning
msvc: avoid using minus operator on unsigned types
push: do not pretend to return `int` from `die_push_simple()`
Diffstat (limited to 'cache.h')
-rw-r--r-- | cache.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -748,6 +748,19 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na */ int index_name_pos(const struct index_state *, const char *name, int namelen); +/* + * Some functions return the negative complement of an insert position when a + * precise match was not found but a position was found where the entry would + * need to be inserted. This helper protects that logic from any integer + * underflow. + */ +static inline int index_pos_to_insert_pos(uintmax_t pos) +{ + if (pos > INT_MAX) + die("overflow: -1 - %"PRIuMAX, pos); + return -1 - (int)pos; +} + #define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */ #define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */ #define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */ |