Merge pull request #4611 from erikvanzijst/erik/status_char diff: Add missing GIT_DELTA_TYPECHANGE -> 'T' mapping.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/src/diff_print.c b/src/diff_print.c
index 28ae384..5e53548 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -130,6 +130,7 @@ char git_diff_status_char(git_delta_t status)
case GIT_DELTA_COPIED: code = 'C'; break;
case GIT_DELTA_IGNORED: code = 'I'; break;
case GIT_DELTA_UNTRACKED: code = '?'; break;
+ case GIT_DELTA_TYPECHANGE: code = 'T'; break;
case GIT_DELTA_UNREADABLE: code = 'X'; break;
default: code = ' '; break;
}
diff --git a/tests/checkout/typechange.c b/tests/checkout/typechange.c
index 8a5110c..647b534 100644
--- a/tests/checkout/typechange.c
+++ b/tests/checkout/typechange.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+#include "diff_generate.h"
#include "git2/checkout.h"
#include "path.h"
#include "posix.h"
@@ -307,3 +308,28 @@ void test_checkout_typechange__checkout_with_conflicts(void)
git_object_free(obj);
}
}
+
+void test_checkout_typechange__status_char(void)
+{
+ size_t i;
+ git_oid oid;
+ git_commit *commit;
+ git_diff *diff;
+ const git_diff_delta *delta;
+ git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
+ char expected[8] = {'M', 'M', 'R', 'T', 'D', 'R', 'A', 'R'};
+
+ git_oid_fromstr(&oid, "9b19edf33a03a0c59cdfc113bfa5c06179bf9b1a");
+ cl_git_pass(git_commit_lookup(&commit, g_repo, &oid));
+ diffopts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
+ cl_git_pass(git_diff__commit(&diff, g_repo, commit, &diffopts));
+ cl_git_pass(git_diff_find_similar(diff, NULL));
+
+ for (i = 0; i < git_diff_num_deltas(diff); i++) {
+ delta = git_diff_get_delta(diff, i);
+ cl_assert_equal_i(expected[i], git_diff_status_char(delta->status));
+ }
+
+ git_diff_free(diff);
+ git_commit_free(commit);
+}
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 3171a44..347d0d7 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -254,7 +254,7 @@ void test_diff_stats__rename_nochanges_no_find(void)
git_buf_free(&buf);
}
-void test_diff_stats__rename_and_modifiy_no_find(void)
+void test_diff_stats__rename_and_modify_no_find(void)
{
git_buf buf = GIT_BUF_INIT;
const char *stat =