Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Brian Foster <brian.foster@innova-card.com>,
	Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 4/4] Add support for 'namespace' history simplification
Date: Mon, 3 Nov 2008 11:43:00 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0811031139520.3419@nehalem.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.2.00.0811031135410.3419@nehalem.linux-foundation.org>


From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon, 3 Nov 2008 11:25:46 -0800
Subject: [PATCH 4/4] Add support for 'namespace' history simplification

Maybe this is mis-named, but what it does is to simplify history not by
the contents of the tree, but whether a commit has been named (ie it's
referred to by some branch or tag) or not.

This makes it possible to see the relationship between different named
commits, without actually seeing any of the details.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

This is the actual real meat of the logic, and it's really trivial. The 
actual code is really just a simple

    if (simplify-by-namespace)
        return lookup_decoration(..) ? REV_TREE_DIFFERENT : REV_TREE_SAME;

but it's a few more lines of addition than that because of parsing the 
argument and setting the appropriate flags, and writing the above 
two-liner as five lines with a comment in order to make it more readable.

No docs. I don't do docs. But you can use it like so:

	gitk --simplify-namespace

and you're all done. 

Ta-daa!


 revision.c |   20 ++++++++++++++++++++
 revision.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/revision.c b/revision.c
index 56b09eb..b48e626 100644
--- a/revision.c
+++ b/revision.c
@@ -11,6 +11,7 @@
 #include "reflog-walk.h"
 #include "patch-ids.h"
 #include "decorate.h"
+#include "log-tree.h"
 
 volatile show_early_output_fn_t show_early_output;
 
@@ -301,6 +302,17 @@ static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct
 
 	if (!t1)
 		return REV_TREE_NEW;
+
+	/*
+	 * If we do history simplification by _name_, ignore the
+	 * actual tree contents, and just check if we have a
+	 * decoration
+	 */
+	if (revs->simplify_namespace) {
+		struct name_decoration *name;
+		name = lookup_decoration(&name_decoration, &commit->object);
+		return name ? REV_TREE_DIFFERENT : REV_TREE_SAME;
+	}
 	if (!t2)
 		return REV_TREE_DIFFERENT;
 	tree_difference = REV_TREE_SAME;
@@ -1041,6 +1053,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->rewrite_parents = 1;
 		revs->simplify_history = 0;
 		revs->limited = 1;
+	} else if (!strcmp(arg, "--simplify-namespace")) {
+		revs->simplify_merges = 1;
+		revs->rewrite_parents = 1;
+		revs->simplify_history = 0;
+		revs->simplify_namespace = 1;
+		revs->limited = 1;
+		revs->prune = 1;
+		load_ref_decorations();
 	} else if (!strcmp(arg, "--date-order")) {
 		revs->lifo = 0;
 		revs->topo_order = 1;
diff --git a/revision.h b/revision.h
index 0a1806a..bd1ec0d 100644
--- a/revision.h
+++ b/revision.h
@@ -43,6 +43,7 @@ struct rev_info {
 			lifo:1,
 			topo_order:1,
 			simplify_merges:1,
+			simplify_namespace:1,
 			tag_objects:1,
 			tree_objects:1,
 			blob_objects:1,
-- 
1.6.0.3.616.gf1239d6.dirty

  reply	other threads:[~2008-11-03 19:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03 13:39 [Q] Abbreviated history graph? Brian Foster
2008-11-03 14:20 ` Santi Béjar
2008-11-03 14:55   ` Santi Béjar
2008-11-03 15:46   ` Brian Foster
2008-11-03 16:08     ` Santi Béjar
2008-11-03 19:32 ` Linus Torvalds
2008-11-03 19:33   ` [PATCH 1/4] Add a 'source' decorator for commits Linus Torvalds
2008-11-03 19:35     ` [PATCH 2/4] revision: make tree comparison functions take commits rather than trees Linus Torvalds
2008-11-03 19:39       ` [PATCH 3/4] Make '--decorate' set an explicit 'show_decorations' flag Linus Torvalds
2008-11-03 19:43         ` Linus Torvalds [this message]
2008-11-03 21:45           ` [PATCH 4/4] Add support for 'namespace' history simplification Santi Béjar
2008-11-03 22:05             ` Linus Torvalds
2008-11-03 22:34               ` Santi Béjar
2008-11-03 22:28           ` Robin Rosenberg
2008-11-04 21:33           ` Clemens Buchacher
2008-11-03 20:15   ` [Q] Abbreviated history graph? Linus Torvalds
2008-11-03 20:34     ` Linus Torvalds
2008-11-04  8:45     ` Junio C Hamano

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=alpine.LFD.2.00.0811031139520.3419@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=brian.foster@innova-card.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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