Re: [PATCH 2/2] Support "history replay" for git log commands
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:46
Linus Torvalds [off-list ref] writes:
quoted hunk
This notices if we aren't in topological order, and replays the history. Thus avoiding the need to sort history up front. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- See the code and the more complete explanations in [PATCH 0/2]. In particular, see the last section there about the downsides of this: the 50x expansion of output on the kernel is unacceptable, but if somebody can make a graphical viewer that can react correctly to the "Replay" thing, I'm sure I can make the replays themselves happen much more rarely. builtin-blame.c | 2 +- builtin-log.c | 35 +++++++++++++++++++++++++++++++++++ log-tree.c | 10 +++++++--- revision.c | 29 ++++++++++++++++++++++------- revision.h | 6 +++++- 5 files changed, 70 insertions(+), 12 deletions(-)diff --git a/builtin-blame.c b/builtin-blame.c index 8432b82..7b6af8c 100644 --- a/builtin-blame.c +++ b/builtin-blame.c@@ -1502,7 +1502,7 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt) else { commit->object.flags |= UNINTERESTING; if (commit->object.parsed) - mark_parents_uninteresting(commit); + mark_parents_uninteresting(revs, commit); } /* treat root commit as boundary */ if (!commit->parents && !show_root)diff --git a/builtin-log.c b/builtin-log.c index e8b982d..10e0821 100644 --- a/builtin-log.c +++ b/builtin-log.c@@ -77,6 +77,35 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, } } +static void replay_history(struct rev_info *revs) +{ + struct commit_list *entry; + + revs->trigger_replay = 0; + while ((entry = revs->shown) != NULL) { + struct commit *commit = entry->item; + unsigned flags = commit->object.flags; + + /* Undo the SHOWN and FORCE_REPLAY bits */ + commit->object.flags = flags & ~(SHOWN | FORCE_REPLAY); + commit->indegree = 0; + + /* Remove it from the shown list, put it on the commit list */ + revs->shown = entry->next; + entry->next = revs->commits; + revs->commits = entry; + + printf("Replay %s\n", sha1_to_hex(commit->object.sha1)); + + /* Was this the one that caused us to replay? */ + if (flags & FORCE_REPLAY) + break;
Can one iteration of loop in log_tree_commit() smudge more than one commits with FORCE_REPLAY? Maybe make the trigger_replay a counter and count down in this loop until we find that many commits that have the FORCE_REPLAY flag?