diff options
author | Russell Belfer <rb@github.com> | 2013-10-30 13:56:42 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-11-01 10:20:51 -0700 |
commit | 3940310e29363978ccdc1f3b557bc6f48ebae8f0 (patch) | |
tree | 0a1d4704fe3329064ad2344ccf8a9a46b843d125 /src/diff.c | |
parent | 567649f2ada60e5c3009cc985af238b452b14a81 (diff) | |
download | libgit2-3940310e29363978ccdc1f3b557bc6f48ebae8f0.tar.gz |
Fix some of the glaring errors in GIT_DIFF_REVERSE
These changes fix the basic problem with GIT_DIFF_REVERSE being
broken for text diffs. The reversed diff entries were getting
added to the git_diff correctly, but some of the metadata was kept
incorrectly in a way that prevented the text diffs from being
generated correctly. Once I fixed that, it became clear that it
was not possible to merge reversed diffs correctly. This has a
first pass at fixing that problem. We probably need more tests
to make sure that is really fixed thoroughly.
Diffstat (limited to 'src/diff.c')
-rw-r--r-- | src/diff.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/diff.c b/src/diff.c index 37bc737d6..b1f64e6a3 100644 --- a/src/diff.c +++ b/src/diff.c @@ -448,6 +448,13 @@ static int diff_list_apply_options( /* add other defaults here */ } + /* Reverse src info if diff is reversed */ + if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { + git_iterator_type_t tmp_src = diff->old_src; + diff->old_src = diff->new_src; + diff->new_src = tmp_src; + } + /* if ignore_submodules not explicitly set, check diff config */ if (diff->opts.ignore_submodules <= 0) { const char *str; @@ -484,9 +491,9 @@ static int diff_list_apply_options( return -1; if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) { - const char *swap = diff->opts.old_prefix; - diff->opts.old_prefix = diff->opts.new_prefix; - diff->opts.new_prefix = swap; + const char *tmp_prefix = diff->opts.old_prefix; + diff->opts.old_prefix = diff->opts.new_prefix; + diff->opts.new_prefix = tmp_prefix; } return 0; |