Commit Diff
- Commit:
56275f3b8784d02cc619785d1926615cb54fd059
- From:
- Mark Jamsek <mark@jamsek.dev>
- Date:
- Message:
- fix diffstat path order bug in field width computation The order in which get_diffstat() receives paths may not be the same as the lexicographic order of the changed paths path list, so do not use RB_MAX() to get the path that will be used in the current max path len check. Use the path entry returned by the current got_pathlist_insert() call instead. In such cases that get_diffstat() does not receive paths in lexicographic order, this can produce a bogus diffstat max_path_len if the last lexicographically sorted path entry doesn't have the longest pathname of all changed paths in the diff, which manifests as misaligned diffstat path separators as reported by stsp on IRC. ok stsp@
- Actions:
- Patch | Tree
--- lib/diff.c +++ lib/diff.c @@ -118,11 +118,9 @@ get_diffstat(struct got_diffstat_cb_arg *ds, const cha err = got_pathlist_insert(&pe, ds->paths, path, change); if (err || pe == NULL) { free(change); - if (err) - return err; + return err; } - pe = RB_MAX(got_pathlist_head, ds->paths); diffstat_field_width(&ds->max_path_len, &ds->add_cols, &ds->rm_cols, pe->path_len, change->add, change->rm);