summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-03-25 13:23:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-25 22:09:49 (GMT)
commit1b32decefd840e0ca5d18eefd6472fd8624dd849 (patch)
tree4faa70e96564653ee1c31dff5a1312bfb1110d2d /revision.c
parent208acbfb82f722fb22320c381e7da8c8fb2e37e8 (diff)
downloadgit-1b32decefd840e0ca5d18eefd6472fd8624dd849.zip
git-1b32decefd840e0ca5d18eefd6472fd8624dd849.tar.gz
git-1b32decefd840e0ca5d18eefd6472fd8624dd849.tar.bz2
log: add --show-linear-break to help see non-linear history
Option explanation is in rev-list-options.txt. The interaction with -z is left undecided. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/revision.c b/revision.c
index a68fde6..05b76c7 100644
--- a/revision.c
+++ b/revision.c
@@ -1832,6 +1832,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->notes_opt.use_default_notes = 1;
} else if (!strcmp(arg, "--show-signature")) {
revs->show_signature = 1;
+ } else if (!strcmp(arg, "--show-linear-break") ||
+ starts_with(arg, "--show-linear-break=")) {
+ if (starts_with(arg, "--show-linear-break="))
+ revs->break_bar = xstrdup(arg + 20);
+ else
+ revs->break_bar = " ..........";
+ revs->track_linear = 1;
+ revs->track_first_time = 1;
} else if (starts_with(arg, "--show-notes=") ||
starts_with(arg, "--notes=")) {
struct strbuf buf = STRBUF_INIT;
@@ -1955,6 +1963,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
unkv[(*unkc)++] = arg;
return opts;
}
+ if (revs->graph && revs->track_linear)
+ die("--show-linear-break and --graph are incompatible");
return 1;
}
@@ -2897,6 +2907,27 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
return action;
}
+static void track_linear(struct rev_info *revs, struct commit *commit)
+{
+ if (revs->track_first_time) {
+ revs->linear = 1;
+ revs->track_first_time = 0;
+ } else {
+ struct commit_list *p;
+ for (p = revs->previous_parents; p; p = p->next)
+ if (p->item == NULL || /* first commit */
+ !hashcmp(p->item->object.sha1, commit->object.sha1))
+ break;
+ revs->linear = p != NULL;
+ }
+ if (revs->reverse) {
+ if (revs->linear)
+ commit->object.flags |= TRACK_LINEAR;
+ }
+ free_commit_list(revs->previous_parents);
+ revs->previous_parents = copy_commit_list(commit->parents);
+}
+
static struct commit *get_revision_1(struct rev_info *revs)
{
if (!revs->commits)
@@ -2936,6 +2967,8 @@ static struct commit *get_revision_1(struct rev_info *revs)
die("Failed to simplify parents of commit %s",
sha1_to_hex(commit->object.sha1));
default:
+ if (revs->track_linear)
+ track_linear(revs, commit);
return commit;
}
} while (revs->commits);
@@ -3102,14 +3135,23 @@ struct commit *get_revision(struct rev_info *revs)
revs->reverse_output_stage = 1;
}
- if (revs->reverse_output_stage)
- return pop_commit(&revs->commits);
+ if (revs->reverse_output_stage) {
+ c = pop_commit(&revs->commits);
+ if (revs->track_linear)
+ revs->linear = !!(c && c->object.flags & TRACK_LINEAR);
+ return c;
+ }
c = get_revision_internal(revs);
if (c && revs->graph)
graph_update(revs->graph, c);
- if (!c)
+ if (!c) {
free_saved_parents(revs);
+ if (revs->previous_parents) {
+ free_commit_list(revs->previous_parents);
+ revs->previous_parents = NULL;
+ }
+ }
return c;
}