History

Show number of changed lines in log view

Use the new file-diff interface to calculate number of changed lines per commit.

Lars Hjemli committed 19 years ago

Commit 80e577c1 parent 38a0f9c1 file · +11 −1Browse files

Unified · Split

ui-log.c+11−1
@@ -10,9 +10,16 @@ · 9 unmodified lines
10 10
11int files, lines;11int files, lines;
12 12
13void count_lines(char *line, int size)
14{
15 if (size>0 && (line[0] == '+' || line[0] == '-'))
16 lines++;
17}
18
13void inspect_files(struct diff_filepair *pair)19void inspect_files(struct diff_filepair *pair)
14{20{
15 files++;21 files++;
22 cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines);
16}23}
17 24
18void print_commit(struct commit *commit)25void print_commit(struct commit *commit)
@@ -32,11 +39,13 @@ void print_commit(struct commit *commit) · 13 unmodified lines
32 html_link_open(url, NULL, NULL);39 html_link_open(url, NULL, NULL);
33 html_ntxt(cgit_max_msg_len, info->subject);40 html_ntxt(cgit_max_msg_len, info->subject);
34 html_link_close();41 html_link_close();
35 html("</td><td class='right'>");
36 files = 0;42 files = 0;
37 lines = 0;43 lines = 0;
38 cgit_diff_commit(commit, inspect_files);44 cgit_diff_commit(commit, inspect_files);
45 html("</td><td class='right'>");
39 htmlf("%d", files);46 htmlf("%d", files);
47 html("</td><td class='right'>");
48 htmlf("%d", lines);
40 html("</td><td>");49 html("</td><td>");
41 html_txt(info->author);50 html_txt(info->author);
42 html("</td></tr>\n");51 html("</td></tr>\n");
@@ -70,6 +79,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) · 27 unmodified lines
70 html("<tr class='nohover'><th class='left'>Date</th>"79 html("<tr class='nohover'><th class='left'>Date</th>"
71 "<th class='left'>Message</th>"80 "<th class='left'>Message</th>"
72 "<th class='left'>Files</th>"81 "<th class='left'>Files</th>"
82 "<th class='left'>Lines</th>"
73 "<th class='left'>Author</th></tr>\n");83 "<th class='left'>Author</th></tr>\n");
74 84
75 if (ofs<0)85 if (ofs<0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t