diff options
author | Russell Belfer <arrbee@arrbee.com> | 2012-03-21 23:33:09 +0400 |
---|---|---|
committer | Russell Belfer <arrbee@arrbee.com> | 2012-03-21 23:33:09 +0400 |
commit | a48ea31d69a76d6b398d3a1e522a1c7363a9b92a (patch) | |
tree | 1205730de9c5a02688a61360081c284c8ab6e535 /src/diff.h | |
parent | a4c291ef128e870d4e748dedfb3798c33df0ac15 (diff) |
Reimplment git_status_foreach using git diff
This is an initial reimplementation of status using diff a la
the way that core git does it.
Diffstat (limited to 'src/diff.h')
-rw-r--r-- | src/diff.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/diff.h b/src/diff.h index 7d69199ea..058a1f5e8 100644 --- a/src/diff.h +++ b/src/diff.h @@ -21,5 +21,19 @@ struct git_diff_list { git_iterator_type_t new_src; }; +/* macro lets you iterate over two diff lists together */ + +#define GIT_DIFF_COITERATE(A,B,AD,BD,LEFT,RIGHT,BOTH,AFTER) do { \ + unsigned int _i = 0, _j = 0; int _cmp; \ + while (((A) && _i < (A)->deltas.length) || ((B) && _j < (B)->deltas.length)) { \ + (AD) = (A) ? GIT_VECTOR_GET(&(A)->deltas,_i) : NULL; \ + (BD) = (B) ? GIT_VECTOR_GET(&(B)->deltas,_j) : NULL; \ + _cmp = !(BD) ? -1 : !(AD) ? 1 : strcmp((AD)->old.path,(BD)->old.path); \ + if (_cmp < 0) { LEFT; _i++; } \ + else if (_cmp > 0) { RIGHT; _j++; } \ + else { BOTH; _i++; _j++; } \ + AFTER; \ + } } while (0) + #endif |