mirror of
https://github.com/git/git
synced 2024-08-28 03:59:25 +00:00
blame: move progress updates to a scoreboard callback
Allow the interface user to decide how to handle a progress update. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4149c1860b
commit
8c59921dbf
|
@ -391,6 +391,9 @@ struct blame_scoreboard {
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
void(*on_sanity_fail)(struct blame_scoreboard *, int);
|
void(*on_sanity_fail)(struct blame_scoreboard *, int);
|
||||||
|
void(*found_guilty_entry)(struct blame_entry *, void *);
|
||||||
|
|
||||||
|
void *found_guilty_entry_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void sanity_check_refcnt(struct blame_scoreboard *);
|
static void sanity_check_refcnt(struct blame_scoreboard *);
|
||||||
|
@ -1729,9 +1732,10 @@ static int emit_one_suspect_detail(struct blame_origin *suspect, int repeat)
|
||||||
* The blame_entry is found to be guilty for the range.
|
* The blame_entry is found to be guilty for the range.
|
||||||
* Show it in incremental output.
|
* Show it in incremental output.
|
||||||
*/
|
*/
|
||||||
static void found_guilty_entry(struct blame_entry *ent,
|
static void found_guilty_entry(struct blame_entry *ent, void *data)
|
||||||
struct progress_info *pi)
|
|
||||||
{
|
{
|
||||||
|
struct progress_info *pi = (struct progress_info *)data;
|
||||||
|
|
||||||
if (incremental) {
|
if (incremental) {
|
||||||
struct blame_origin *suspect = ent->suspect;
|
struct blame_origin *suspect = ent->suspect;
|
||||||
|
|
||||||
|
@ -1754,11 +1758,6 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
|
||||||
{
|
{
|
||||||
struct rev_info *revs = sb->revs;
|
struct rev_info *revs = sb->revs;
|
||||||
struct commit *commit = prio_queue_get(&sb->commits);
|
struct commit *commit = prio_queue_get(&sb->commits);
|
||||||
struct progress_info pi = { NULL, 0 };
|
|
||||||
|
|
||||||
if (show_progress)
|
|
||||||
pi.progress = start_progress_delay(_("Blaming lines"),
|
|
||||||
sb->num_lines, 50, 1);
|
|
||||||
|
|
||||||
while (commit) {
|
while (commit) {
|
||||||
struct blame_entry *ent;
|
struct blame_entry *ent;
|
||||||
|
@ -1800,7 +1799,8 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
|
||||||
suspect->guilty = 1;
|
suspect->guilty = 1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct blame_entry *next = ent->next;
|
struct blame_entry *next = ent->next;
|
||||||
found_guilty_entry(ent, &pi);
|
if (sb->found_guilty_entry)
|
||||||
|
sb->found_guilty_entry(ent, sb->found_guilty_entry_data);
|
||||||
if (next) {
|
if (next) {
|
||||||
ent = next;
|
ent = next;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1816,8 +1816,6 @@ static void assign_blame(struct blame_scoreboard *sb, int opt)
|
||||||
if (sb->debug) /* sanity */
|
if (sb->debug) /* sanity */
|
||||||
sanity_check_refcnt(sb);
|
sanity_check_refcnt(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_progress(&pi.progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *format_time(timestamp_t time, const char *tz_str,
|
static const char *format_time(timestamp_t time, const char *tz_str,
|
||||||
|
@ -2550,6 +2548,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
|
||||||
char *final_commit_name = NULL;
|
char *final_commit_name = NULL;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
struct commit *final_commit = NULL;
|
struct commit *final_commit = NULL;
|
||||||
|
struct progress_info pi = { NULL, 0 };
|
||||||
|
|
||||||
struct string_list range_list = STRING_LIST_INIT_NODUP;
|
struct string_list range_list = STRING_LIST_INIT_NODUP;
|
||||||
int output_option = 0, opt = 0;
|
int output_option = 0, opt = 0;
|
||||||
|
@ -2905,8 +2904,16 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
read_mailmap(&mailmap, NULL);
|
read_mailmap(&mailmap, NULL);
|
||||||
|
|
||||||
|
sb.found_guilty_entry = &found_guilty_entry;
|
||||||
|
sb.found_guilty_entry_data = π
|
||||||
|
if (show_progress)
|
||||||
|
pi.progress = start_progress_delay(_("Blaming lines"),
|
||||||
|
sb.num_lines, 50, 1);
|
||||||
|
|
||||||
assign_blame(&sb, opt);
|
assign_blame(&sb, opt);
|
||||||
|
|
||||||
|
stop_progress(&pi.progress);
|
||||||
|
|
||||||
if (!incremental)
|
if (!incremental)
|
||||||
setup_pager();
|
setup_pager();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue