summaryrefslogtreecommitdiff
path: root/src/diff.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-11-08 16:56:34 -0800
committerRussell Belfer <rb@github.com>2012-11-09 13:52:07 -0800
commit55cbd05b18960e761a4d237ce5f1ff06455da98d (patch)
treeef602ca15261aa1d5ff6be6ea043d74d5fc45459 /src/diff.h
parent2e3d4b96c08f1b0e2ee9b248c53aec523d70fd25 (diff)
downloadlibgit2-55cbd05b18960e761a4d237ce5f1ff06455da98d.tar.gz
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.
Diffstat (limited to 'src/diff.h')
-rw-r--r--src/diff.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/diff.h b/src/diff.h
index ed66439bf..e9d8fd5a7 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -41,6 +41,11 @@ struct git_diff_list {
git_iterator_type_t old_src;
git_iterator_type_t new_src;
uint32_t diffcaps;
+
+ int (*strcmp)(const char *, const char *);
+ int (*strncmp)(const char *, const char *, size_t);
+ int (*prefixcmp)(const char *str, const char *pfx);
+ int (*entrycmp)(const void *a, const void *b);
};
extern void git_diff__cleanup_modes(
@@ -53,5 +58,8 @@ extern int git_diff_delta__cmp(const void *a, const void *b);
extern bool git_diff_delta__should_skip(
const git_diff_options *opts, const git_diff_delta *delta);
+extern int git_diff__oid_for_file(
+ git_repository *, const char *, uint16_t, git_off_t, git_oid *);
+
#endif