void test_blame_getters__byline(void) { const git_blame_hunk *h = git_blame_get_hunk_byline(g_blame, 5); cl_assert(h); cl_assert_equal_s(h->orig_path, "b"); h = git_blame_get_hunk_byline(g_blame, 95); cl_assert_equal_p(h, NULL); }
void test_blame_buffer__added_line(void) { const git_blame_hunk *hunk; const char *buffer = "\ EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\ EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\ EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\ EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\ \n\ abcdefg\n\ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n\ \n\ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n\ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n\ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n\ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\n\n"; cl_git_pass(git_blame_buffer(&g_bufferblame, g_fileblame, buffer, strlen(buffer))); cl_assert_equal_i(5, git_blame_get_hunk_count(g_bufferblame)); check_blame_hunk_index(g_repo, g_bufferblame, 2, 6, 1, 0, "000000", "b.txt"); hunk = git_blame_get_hunk_byline(g_bufferblame, 16); cl_assert(hunk); cl_assert_equal_s("Ben Straub", hunk->final_signature->name); }
emacs_value egit_blame_get_hunk_byline(emacs_env *env, emacs_value _blame, emacs_value _line) { EGIT_ASSERT_BLAME(_blame); EM_ASSERT_INTEGER(_line); git_blame *blame = EGIT_EXTRACT(_blame); size_t line = (size_t) env->extract_integer(env, _line); const git_blame_hunk *hunk = git_blame_get_hunk_byline(blame, line); if (!hunk) { em_signal_args_out_of_range(env, line); return em_nil; } return egit_wrap(env, EGIT_BLAME_HUNK, hunk, EM_EXTRACT_USER_PTR(_blame)); }
PyObject * Blame_for_line(Blame *self, PyObject *args) { size_t line_no; const git_blame_hunk *hunk; if (!PyArg_ParseTuple(args, "I", &line_no)) return NULL; hunk = git_blame_get_hunk_byline(self->blame, line_no); if (!hunk) { PyErr_SetObject(PyExc_IndexError, args); return NULL; } return wrap_blame_hunk(hunk, self); }
void test_mailmap_blame__hunks_no_mailmap(void) { size_t idx = 0; const git_blame_hunk *hunk = NULL; git_blame_options opts = GIT_BLAME_OPTIONS_INIT; g_repo = cl_git_sandbox_init("mailmap"); cl_git_pass(git_blame_file(&g_blame, g_repo, "file.txt", &opts)); cl_assert(g_blame); for (idx = 0; idx < ARRAY_SIZE(resolved); ++idx) { hunk = git_blame_get_hunk_byline(g_blame, idx + 1); cl_assert(hunk->final_signature != NULL); cl_assert(hunk->orig_signature != NULL); cl_assert_equal_s(hunk->final_signature->name, resolved[idx].replace_name); cl_assert_equal_s(hunk->final_signature->email, resolved[idx].replace_email); } }