From 55cbd05b18960e761a4d237ce5f1ff06455da98d Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 8 Nov 2012 16:56:34 -0800 Subject: Some diff refactorings to help code reuse There are some diff functions that are useful in a rewritten checkout and this lays some groundwork for that. This contains three main things: 1. Share the function diff uses to calculate the OID for a file in the working directory (now named `git_diff__oid_for_file` 2. Add a `git_diff__paired_foreach` function to iterator over two diff lists concurrently. Convert status to use it. 3. Move all the string/prefix/index entry comparisons into function pointers inside the `git_diff_list` object so they can be switched between case sensitive and insensitive versions. This makes them easier to reuse in various functions without replicating logic. As part of this, move a couple of index functions out of diff.c and into index.c. --- src/util.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 3d00e9c85..23d4bc6e9 100644 --- a/src/util.h +++ b/src/util.h @@ -81,6 +81,11 @@ extern int git__prefixcmp(const char *str, const char *prefix); extern int git__prefixcmp_icase(const char *str, const char *prefix); extern int git__suffixcmp(const char *str, const char *suffix); +GIT_INLINE(int) git__signum(int val) +{ + return ((val > 0) - (val < 0)); +} + extern int git__strtol32(int32_t *n, const char *buff, const char **end_buf, int base); extern int git__strtol64(int64_t *n, const char *buff, const char **end_buf, int base); -- cgit v1.2.3