git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Simpkins <adam@adamsimpkins.net>
To: git@vger.kernel.org
Cc: Adam Simpkins <adam@adamsimpkins.net>
Subject: [PATCH 4/4] log and rev-list: Improve --graph output when commits have been pruned
Date: Mon,  7 Apr 2008 01:01:21 -0700	[thread overview]
Message-ID: <1207555281-9362-4-git-send-email-adam@adamsimpkins.net> (raw)
In-Reply-To: <1207555281-9362-3-git-send-email-adam@adamsimpkins.net>

This change automatically enables parent rewriting when --graph is
specified.  This makes the graph output look much nicer when commit
pruning is enabled.

The existing rev_info "parents" flag has been split into
two flags: "rewrite_parents" causes the parents to be rewritten, while
"print_parents" causes the log and rev-list commands to print the
parents.  The --parents option now enables both rewrite_parents and
print_parents, while --graph enables only rewrite_parents.

Signed-off-by: Adam Simpkins <adam@adamsimpkins.net>
---
 builtin-rev-list.c |    2 +-
 log-tree.c         |    4 ++--
 revision.c         |    8 +++++---
 revision.h         |    3 ++-
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index ac6a6f9..f8103bd 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -79,7 +79,7 @@ static void show_commit(struct commit *commit)
 		      stdout);
 	else
 		fputs(sha1_to_hex(commit->object.sha1), stdout);
-	if (revs.parents) {
+	if (revs.print_parents) {
 		struct commit_list *parents = commit->parents;
 		while (parents) {
 			printf(" %s", sha1_to_hex(parents->item->object.sha1));
diff --git a/log-tree.c b/log-tree.c
index d2cb26a..4ad10af 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -240,7 +240,7 @@ void show_log(struct rev_info *opt, const char *sep)
 				putchar('>');
 		}
 		fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
-		if (opt->parents)
+		if (opt->print_parents)
 			show_parents(commit, abbrev_commit);
 		show_decorations(commit);
 		if (opt->graph && !graph_is_commit_finished(opt->graph)) {
@@ -305,7 +305,7 @@ void show_log(struct rev_info *opt, const char *sep)
 		}
 		fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
 		      stdout);
-		if (opt->parents)
+		if (opt->print_parents)
 			show_parents(commit, abbrev_commit);
 		if (parent)
 			printf(" (from %s)",
diff --git a/revision.c b/revision.c
index 6a1f513..7d9d333 100644
--- a/revision.c
+++ b/revision.c
@@ -1105,7 +1105,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 				}
 			}
 			if (!strcmp(arg, "--parents")) {
-				revs->parents = 1;
+				revs->rewrite_parents = 1;
+				revs->print_parents = 1;
 				continue;
 			}
 			if (!strcmp(arg, "--dense")) {
@@ -1204,6 +1205,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 			}
 			if (!prefixcmp(arg, "--graph")) {
 				revs->topo_order = 1;
+				revs->rewrite_parents = 1;
 				revs->graph = graph_init();
 				continue;
 			}
@@ -1538,13 +1540,13 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
 		/* Commit without changes? */
 		if (commit->object.flags & TREESAME) {
 			/* drop merges unless we want parenthood */
-			if (!revs->parents)
+			if (!revs->rewrite_parents)
 				return commit_ignore;
 			/* non-merge - always ignore it */
 			if (!commit->parents || !commit->parents->next)
 				return commit_ignore;
 		}
-		if (revs->parents && rewrite_parents(revs, commit) < 0)
+		if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0)
 			return commit_error;
 	}
 	return commit_show;
diff --git a/revision.h b/revision.h
index d06b991..170543d 100644
--- a/revision.h
+++ b/revision.h
@@ -46,7 +46,8 @@ struct rev_info {
 			unpacked:1, /* see also ignore_packed below */
 			boundary:2,
 			left_right:1,
-			parents:1,
+			rewrite_parents:1,
+			print_parents:1,
 			reverse:1,
 			cherry_pick:1,
 			first_parent_only:1;
-- 
1.5.3.6

  reply	other threads:[~2008-04-07  8:02 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-06 18:42 [PATCH 1/4] Add history graph API Adam Simpkins
2008-04-06 18:42 ` [PATCH 2/4] graph API: Added additional utility functions to the " Adam Simpkins
2008-04-06 18:42   ` [PATCH 3/4] git log and git rev-list: Add --graph option Adam Simpkins
2008-04-06 18:42     ` [PATCH 4/4] git log: Updated --graph to work even when the commit list is pruned Adam Simpkins
2008-04-06 21:47       ` [PATCH 5/5] Document the new --graph option for log and rev-list Adam Simpkins
2008-04-07  8:01         ` [PATCH 1/4] graph API: Fixed coding style problems Adam Simpkins
2008-04-07  8:01           ` [PATCH 2/4] log and rev-list: Fixed newline termination issues with --graph Adam Simpkins
2008-04-07  8:01             ` [PATCH 3/4] log and rev-list: Fix --graph output with --pretty=email Adam Simpkins
2008-04-07  8:01               ` Adam Simpkins [this message]
2008-04-07  8:21             ` [PATCH 2/4] log and rev-list: Fixed newline termination issues with --graph Junio C Hamano
2008-04-07  8:52               ` Junio C Hamano
2008-04-07 13:17                 ` Jeff King
2008-04-07 17:43                   ` Junio C Hamano
2008-04-07 19:01                     ` Adam Simpkins
2008-04-07 13:19                 ` Jakub Narebski
2008-04-08  0:11                 ` Junio C Hamano
2008-04-08  0:25                   ` Govind Salinas
2008-04-08  0:58                     ` Junio C Hamano
2008-04-06 21:15     ` [PATCH 3/4] git log and git rev-list: Add --graph option Teemu Likonen
2008-04-06 22:51       ` Adam Simpkins
2008-04-06 20:30 ` [PATCH 1/4] Add history graph API Teemu Likonen
2008-04-06 21:44   ` Adam Simpkins
2008-04-06 20:42 ` Johannes Schindelin
2008-04-06 22:47   ` Adam Simpkins
2008-04-07  5:24     ` Teemu Likonen
2008-04-07  8:34       ` Adam Simpkins
2008-04-07  8:56         ` Teemu Likonen
2008-04-06 21:06 ` Johannes Schindelin
2008-04-06 22:04   ` Adam Simpkins
2008-04-06 22:15     ` Johannes Schindelin
2008-04-06 22:58       ` Adam Simpkins
2008-04-07 16:15       ` Linus Torvalds
2008-04-07  3:12     ` Junio C Hamano
2008-04-06 21:25 ` [PATCH] bash: Add command line completion of --graph (git log) Teemu Likonen
2008-04-07 12:25   ` [PATCH v2] bash: Add more command line option completions for 'git log' Teemu Likonen
2008-04-07  7:26 ` [PATCH 1/4] Add history graph API Teemu Likonen
2008-04-07  8:06   ` Adam Simpkins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1207555281-9362-4-git-send-email-adam@adamsimpkins.net \
    --to=adam@adamsimpkins.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).