-rwxr-xr-x | tests/t0105-commit.sh | 2 | ||||
-rw-r--r-- | ui-diff.c | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh index 4e1236b..a864612 100755 --- a/tests/t0105-commit.sh +++ b/tests/t0105-commit.sh @@ -1,37 +1,37 @@ #!/bin/sh . ./setup.sh prepare_tests "Check content on commit page" run_test 'generate foo/commit' 'cgit_url "foo/commit" >trash/tmp' run_test 'find tree link' 'grep -e "<a href=./foo/tree/.>" trash/tmp' run_test 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" trash/tmp' run_test 'find commit subject' ' grep -e "<div class=.commit-subject.>commit 5</div>" trash/tmp ' run_test 'find commit msg' 'grep -e "<div class=.commit-msg.></div>" trash/tmp' run_test 'find diffstat' 'grep -e "<table summary=.diffstat. class=.diffstat.>" trash/tmp' run_test 'find diff summary' ' grep -e "1 files changed, 1 insertions, 0 deletions" trash/tmp ' run_test 'get root commit' ' root=$(cd trash/repos/foo && git rev-list --reverse HEAD | head -1) && cgit_url "foo/commit&id=$root" >trash/tmp && grep "</html>" trash/tmp ' run_test 'root commit contains diffstat' ' - grep "<a href=./foo/diff/file-1.>file-1</a>" trash/tmp + grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" trash/tmp ' run_test 'root commit contains diff' ' grep ">diff --git a/file-1 b/file-1<" trash/tmp && grep -e "<div class=.add.>+1</div>" trash/tmp ' tests_done @@ -116,64 +116,65 @@ static void inspect_filepair(struct diff_filepair *pair) lines_removed = 0; cgit_diff_files(pair->one->sha1, pair->two->sha1, count_diff_lines); if (files >= slots) { if (slots == 0) slots = 4; else slots = slots * 2; items = xrealloc(items, slots * sizeof(struct fileinfo)); } items[files-1].status = pair->status; hashcpy(items[files-1].old_sha1, pair->one->sha1); hashcpy(items[files-1].new_sha1, pair->two->sha1); items[files-1].old_mode = pair->one->mode; items[files-1].new_mode = pair->two->mode; items[files-1].old_path = xstrdup(pair->one->path); items[files-1].new_path = xstrdup(pair->two->path); items[files-1].added = lines_added; items[files-1].removed = lines_removed; if (lines_added + lines_removed > max_changes) max_changes = lines_added + lines_removed; total_adds += lines_added; total_rems += lines_removed; } void cgit_print_diffstat(const unsigned char *old_sha1, const unsigned char *new_sha1) { int i; html("<div class='diffstat-header'>Diffstat</div>"); html("<table summary='diffstat' class='diffstat'>"); max_changes = 0; + curr_rev = xstrdup(sha1_to_hex(new_sha1)); cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); for(i = 0; i<files; i++) print_fileinfo(&items[i]); html("</table>"); html("<div class='diffstat-summary'>"); htmlf("%d files changed, %d insertions, %d deletions", files, total_adds, total_rems); html("</div>"); } /* * print a single line returned from xdiff */ static void print_line(char *line, int len) { char *class = "ctx"; char c = line[len-1]; if (line[0] == '+') class = "add"; else if (line[0] == '-') class = "del"; else if (line[0] == '@') class = "hunk"; htmlf("<div class='%s'>", class); line[len-1] = '\0'; html_txt(line); html("</div>"); line[len-1] = c; } |