diff options
Diffstat (limited to 'line-log.c')
-rw-r--r-- | line-log.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/line-log.c b/line-log.c index 1008e72258..af6e2f799e 100644 --- a/line-log.c +++ b/line-log.c @@ -237,7 +237,7 @@ static void diff_ranges_release(struct diff_ranges *diff) range_set_release(&diff->target); } -void line_log_data_init(struct line_log_data *r) +static void line_log_data_init(struct line_log_data *r) { memset(r, 0, sizeof(struct line_log_data)); range_set_init(&r->ranges, 0); @@ -325,7 +325,7 @@ static int collect_diff_cb(long start_a, long count_a, return 0; } -static void collect_diff(mmfile_t *parent, mmfile_t *target, struct diff_ranges *out) +static int collect_diff(mmfile_t *parent, mmfile_t *target, struct diff_ranges *out) { struct collect_diff_cbdata cbdata = {NULL}; xpparam_t xpp; @@ -340,7 +340,7 @@ static void collect_diff(mmfile_t *parent, mmfile_t *target, struct diff_ranges xecfg.hunk_func = collect_diff_cb; memset(&ecb, 0, sizeof(ecb)); ecb.priv = &cbdata; - xdi_diff(parent, target, &xpp, &xecfg, &ecb); + return xdi_diff(parent, target, &xpp, &xecfg, &ecb); } /* @@ -502,7 +502,7 @@ static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec) unsigned mode; unsigned char sha1[20]; - if (get_tree_entry(commit->object.sha1, spec->path, + if (get_tree_entry(commit->object.oid.hash, spec->path, sha1, &mode)) die("There is no path %s in the commit", spec->path); fill_filespec(spec, sha1, 1, mode); @@ -533,7 +533,7 @@ static void fill_line_ends(struct diff_filespec *spec, long *lines, } /* shrink the array to fit the elements */ - ends = xrealloc(ends, cur * sizeof(*ends)); + REALLOC_ARRAY(ends, cur); *lines = cur-1; *line_ends = ends; } @@ -575,7 +575,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args) name_part = skip_range_arg(item->string); if (!name_part || *name_part != ':' || !name_part[1]) - die("-L argument '%s' not of the form start,end:file", + die("-L argument not 'start,end:file' or ':funcname:file': %s", item->string); range_part = xstrndup(item->string, name_part - item->string); name_part++; @@ -824,8 +824,8 @@ static void queue_diffs(struct line_log_data *range, assert(commit); DIFF_QUEUE_CLEAR(&diff_queued_diff); - diff_tree_sha1(parent ? parent->tree->object.sha1 : NULL, - commit->tree->object.sha1, "", opt); + diff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL, + commit->tree->object.oid.hash, "", opt); if (opt->detect_rename) { filter_diffs_for_paths(range, 1); if (diff_might_be_rename()) @@ -893,7 +893,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang const char *c_meta = diff_get_color(opt->use_color, DIFF_METAINFO); const char *c_old = diff_get_color(opt->use_color, DIFF_FILE_OLD); const char *c_new = diff_get_color(opt->use_color, DIFF_FILE_NEW); - const char *c_plain = diff_get_color(opt->use_color, DIFF_PLAIN); + const char *c_context = diff_get_color(opt->use_color, DIFF_CONTEXT); if (!pair || !diff) return; @@ -957,7 +957,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang int k; for (; t_cur < diff->target.ranges[j].start; t_cur++) print_line(prefix, ' ', t_cur, t_ends, pair->two->data, - c_plain, c_reset); + c_context, c_reset); for (k = diff->parent.ranges[j].start; k < diff->parent.ranges[j].end; k++) print_line(prefix, '-', k, p_ends, pair->one->data, c_old, c_reset); @@ -968,7 +968,7 @@ static void dump_diff_hacky_one(struct rev_info *rev, struct line_log_data *rang } for (; t_cur < t_end; t_cur++) print_line(prefix, ' ', t_cur, t_ends, pair->two->data, - c_plain, c_reset); + c_context, c_reset); } free(p_ends); @@ -1030,7 +1030,8 @@ static int process_diff_filepair(struct rev_info *rev, } diff_ranges_init(&diff); - collect_diff(&file_parent, &file_target, &diff); + if (collect_diff(&file_parent, &file_target, &diff)) + die("unable to generate diff for %s", pair->one->path); /* NEEDSWORK should apply some heuristics to prevent mismatches */ free(rg->path); @@ -1099,6 +1100,7 @@ static int process_all_files(struct line_log_data **range_out, rg->pair = diff_filepair_dup(queue->queue[i]); memcpy(&rg->diff, pairdiff, sizeof(struct diff_ranges)); } + free(pairdiff); } return changed; @@ -1141,6 +1143,9 @@ static int process_ranges_merge_commit(struct rev_info *rev, struct commit *comm int i; int nparents = commit_list_count(commit->parents); + if (nparents > 1 && rev->first_parent_only) + nparents = 1; + diffqueues = xmalloc(nparents * sizeof(*diffqueues)); cand = xmalloc(nparents * sizeof(*cand)); parents = xmalloc(nparents * sizeof(*parents)); |