git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/4] Add support for 'namespace' history simplification

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Nov 3, 2008, 19:43 UTC
Message-ID
<alpine.LFD.2.00.0811031139520.3419@nehalem.linux-foundation.org>
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
Previous: Linus TorvaldsNext: Santi Béjar
Message 10 of 18 in “[Q] Abbreviated history graph?”
  1. Brian FosterNov 3, 2008
  2. Santi BéjarNov 3, 2008
  3. Santi BéjarNov 3, 2008
  4. Brian FosterNov 3, 2008
  5. Santi BéjarNov 3, 2008
  6. Linus TorvaldsNov 3, 2008
  7. 1/4 Add a 'source' decorator for commitsLinus Torvalds, Nov 3, 2008
  8. 2/4 revision: make tree comparison functions take commits rather than treesLinus Torvalds, Nov 3, 2008
  9. 3/4 Make '--decorate' set an explicit 'show_decorations' flagLinus Torvalds, Nov 3, 2008
  10. 4/4 Add support for 'namespace' history simplificationLinus Torvalds, Nov 3, 2008
  11. Santi BéjarNov 3, 2008
  12. Linus TorvaldsNov 3, 2008
  13. Santi BéjarNov 3, 2008
  14. Robin RosenbergNov 3, 2008
  15. Clemens BuchacherNov 4, 2008
  16. Linus TorvaldsNov 3, 2008
  17. Linus TorvaldsNov 3, 2008
  18. Junio C HamanoNov 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.