git-pickaxe: do not keep commit buffer.
We need the commit buffer data while generating the final result, but until then we do not need them. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 20, 2006 at 23:49 UTC
612702e8ea3aa070586001f1aa0a2070058664e0
1 file changed
+19
-7
builtin-pickaxe.c
+19
-7
@@ -108,6 +108,7 @@ struct scoreboard {
108
/* linked list of blames */
109
struct blame_entry *ent;
110
111
+ /* look-up a line in the final buffer */
112
int num_lines;
113
int *lineno;
114
};
@@ -188,7 +189,8 @@ static struct origin *find_rename(struct scoreboard *sb,
189
190
for (i = 0; i < diff_queued_diff.nr; i++) {
191
struct diff_filepair *p = diff_queued_diff.queue[i];
191
- if (p->status == 'R' && !strcmp(p->one->path, origin->path)) {
192
+ if ((p->status == 'R' || p->status == 'C') &&
193
+ !strcmp(p->one->path, origin->path)) {
194
porigin = find_origin(sb, parent, p->two->path);
195
break;
196
}
@@ -457,7 +459,7 @@ static void split_blame(struct scoreboard *sb,
459
460
if (1) { /* sanity */
461
struct blame_entry *ent;
460
- int lno = 0, corrupt = 0;
462
+ int lno = sb->ent->lno, corrupt = 0;
463
464
for (ent = sb->ent; ent; ent = ent->next) {
465
if (lno != ent->lno)
@@ -467,7 +469,7 @@ static void split_blame(struct scoreboard *sb,
469
lno += ent->num_lines;
470
}
471
if (corrupt) {
470
- lno = 0;
472
+ lno = sb->ent->lno;
473
for (ent = sb->ent; ent; ent = ent->next) {
474
printf("L %8d l %8d n %8d\n",
475
lno, ent->lno, ent->num_lines);
@@ -508,10 +510,9 @@ static void blame_chunk(struct scoreboard *sb,
510
int tlno, int plno, int same,
511
struct origin *target, struct origin *parent)
512
{
511
- struct blame_entry *e, *n;
513
+ struct blame_entry *e;
514
513
- for (e = sb->ent; e; e = n) {
514
- n = e->next;
515
+ for (e = sb->ent; e; e = e->next) {
516
if (e->guilty || e->suspect != target)
517
continue;
518
if (same <= e->s_lno)
@@ -556,7 +557,7 @@ static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
557
if (e->score)
558
return e->score;
559
559
- score = 0;
560
+ score = 1;
561
cp = nth_line(sb, e->lno);
562
ep = nth_line(sb, e->lno + e->num_lines);
563
while (cp < ep) {
@@ -933,6 +934,15 @@ static void get_commit_info(struct commit *commit,
934
static char committer_buf[1024];
935
static char summary_buf[1024];
936
937
+ /* We've operated without save_commit_buffer, so
938
+ * we now need to populate them for output.
939
+ */
940
+ if (!commit->buffer) {
941
+ char type[20];
942
+ unsigned long size;
943
+ commit->buffer =
944
+ read_sha1_file(commit->object.sha1, type, &size);
945
+ }
946
ret->author = author_buf;
947
get_ac_line(commit->buffer, "\nauthor ",
948
sizeof(author_buf), author_buf, &ret->author_mail,
@@ -1214,6 +1224,8 @@ int cmd_pickaxe(int argc, const char **argv, const char *prefix)
1224
const char *final_commit_name = NULL;
1225
char type[10];
1226
1227
+ save_commit_buffer = 0;
1228
+
1229
opt = 0;
1230
bottom = top = 0;
1231
seen_dashdash = 0;