From ff9760981bb1a96bfe9bb88f6fde9e95dd98e94a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 11 Sep 2014 23:20:07 -0400 Subject: [PATCH] Rework last commit to show the simplified graph for --first-parent References #326 --- NEWS.adoc | 2 +- include/tig/main.h | 1 + src/argv.c | 2 +- src/main.c | 17 +++++++++++++- test/main/{no-graph-test => graph-argument-test} | 28 ++++++++++++------------ 5 files changed, 33 insertions(+), 17 deletions(-) rename test/main/{no-graph-test => graph-argument-test} (66%) diff --git a/NEWS.adoc b/NEWS.adoc index 1b772e5..c078f70 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -12,7 +12,7 @@ Improvements: Bug fixes: - Update manual to reflect default keybinding changes. (GH #325) - - Disable the graph when `--first-parent` is passed to the main view. (GH #326) + - Improve graph support for `--first-parent`. (GH #326) tig-2.0.3 --------- diff --git a/include/tig/main.h b/include/tig/main.h index 85583ef..f544d18 100644 --- a/include/tig/main.h +++ b/include/tig/main.h @@ -35,6 +35,7 @@ struct main_state { char reflogmsg[SIZEOF_STR / 2]; bool in_header; bool with_graph; + bool first_parent; bool add_changes_parents; }; diff --git a/src/argv.c b/src/argv.c index db94fb3..60742f6 100644 --- a/src/argv.c +++ b/src/argv.c @@ -406,6 +406,7 @@ argv_parse_rev_flag(const char *arg, struct rev_flags *rev_flags) "--date-order", "--dense", "--extended-regexp", + "--first-parent", "--fixed-strings", "--full-history", "--graph", @@ -443,7 +444,6 @@ argv_parse_rev_flag(const char *arg, struct rev_flags *rev_flags) "-i", }; static const char *no_graph[] = { - "--first-parent", "--follow", }; static const char *with_reflog[] = { diff --git a/src/main.c b/src/main.c index 1b79c2e..cc3d4d0 100644 --- a/src/main.c +++ b/src/main.c @@ -166,6 +166,9 @@ main_check_argv(struct view *view, const char *argv[]) continue; } + if (!strcmp(arg, "--first-parent")) + state->first_parent = TRUE; + if (!argv_parse_rev_flag(arg, &rev_flags)) continue; @@ -368,9 +371,21 @@ main_read(struct view *view, struct buffer *buf) } main_flush_commit(view, commit); - main_register_commit(view, &state->current, line, is_boundary); author = io_memchr(buf, line, 0); + + if (state->first_parent) { + char *parent = strchr(line, ' '); + char *parent_end = parent ? strchr(parent + 1, ' ') : NULL; + + if (parent_end) + *parent_end = 0; + + io_trace("[parent] %s\n", line); + } + + main_register_commit(view, &state->current, line, is_boundary); + if (author) { char *title = io_memchr(buf, author, 0); diff --git a/test/main/no-graph-test b/test/main/graph-argument-test similarity index 66% rename from test/main/no-graph-test rename to test/main/graph-argument-test index 9ad9f32..8643ed2 100755 --- a/test/main/no-graph-test +++ b/test/main/graph-argument-test @@ -50,19 +50,19 @@ test_tig_script 'follow' --follow project/Build.scala <