git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix "git log --parent -m" from emitting duplicated parent info
@ 2007-07-08 14:37 Marco Costalba
  2007-07-08 18:32 ` Junio C Hamano
  2007-07-09  0:37 ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Marco Costalba @ 2007-07-08 14:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

Without this patch in case of a merge, duplicated parents are
omitted in first line output, but still listed in following
parents information.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---

Following the hint of someone I submit this patch.

Please take it as a wish of not reverting the patch ;-)


 log-tree.c |   25 +++++++++++++++++--------
 revision.h |    1 +
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 24aea6b..e5d40fe 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -6,11 +6,11 @@

  struct decoration name_decoration = { "object names" };

-static void clear_tmp_mark(struct commit_list *p)
+static void clear_flag(struct commit_list *p, unsigned int flag)
 {
 	while (p) {
  		struct commit *c = p->item;
-		c->object.flags &= ~TMP_MARK;
+		c->object.flags &= ~flag;
 		p = p->next;
 	}
 }
@@ -23,7 +23,7 @@ static void show_parents(
 	 * be used locally, but the user should clean
 	 * things up after it is done with them.
 	 */
-	clear_tmp_mark(commit->parents);
+	clear_flag(commit->parents, TMP_MARK);
 	for (p = commit->parents; p ; p = p->next) {
  		struct commit *parent = p->item;
 		if (parent->object.flags & TMP_MARK)
@@ -31,7 +31,7 @@ static void show_parents(struct
  		printf(" %s", diff_unique_abbrev(parent->object.sha1, abbrev));
 		parent->object.flags |= TMP_MARK;
 	}
-	clear_tmp_mark(commit->parents);
+	clear_flag(commit->parents, TMP_MARK);
 }

  static void show_decorations(struct commit *commit)
@@ -391,16 +391,24 @@ static int log_tree_diff(
 		/* If we show individual diffs, show the parent info */
 		log->parent = parents->item;
 	}
-
 	showed_log = 0;
+	clear_flag(parents, TMP_MARK_2);
+
 	for (;;) {
  		struct commit *parent = parents->item;

-		diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);
-		log_tree_diff_flush(opt);
+		/* TMP_MARK_2 is a general purpose flag that can
+		 * be used locally nested with TMP_MARK, but the user
+		 * should clean things up after it is done with them.
+		*/
+		if (!opt->parents || !(parent->object.flags & TMP_MARK_2)) {

-		showed_log |= !opt->loginfo;
+			diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);
+			log_tree_diff_flush(opt); // will use TMP_MARK

+			showed_log |= !opt->loginfo;
+			parent->object.flags |= TMP_MARK_2;
+		}
 		/* Set up the log info for the next parent, if any.. */
 		parents = parents->next;
 		if (!parents)
@@ -408,6 +416,7 @@ static int log_tree_diff(
 		log->parent = parents->item;
  		opt->loginfo = log;
 	}
+	clear_flag(parents, TMP_MARK_2);
 	return showed_log;
 }

diff --git a/revision.h b/revision.h
index f46b4d5..403507f 100644
--- a/revision.h
+++ b/revision.h
@@ -10,6 +10,7 @@
 #define CHILD_SHOWN	(1u<<6)
 #define ADDED		(1u<<7)	/* Parents already parsed and added? */
 #define SYMMETRIC_LEFT	(1u<<8)
+#define TMP_MARK_2	(1u<<9) /* for isolated cases; clean after use */

  struct rev_info;
  struct log_info;
-- 
1.5.3.rc0.65.g39a4d-dirty

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-09  6:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-08 14:37 [PATCH] Fix "git log --parent -m" from emitting duplicated parent info Marco Costalba
2007-07-08 18:32 ` Junio C Hamano
2007-07-09  0:37 ` Junio C Hamano
2007-07-09  1:15   ` Johannes Schindelin
2007-07-09  1:28     ` Junio C Hamano
2007-07-09  1:20   ` Junio C Hamano
2007-07-09  1:22   ` Johannes Schindelin
2007-07-09  1:38     ` Junio C Hamano
2007-07-09  5:46       ` Marco Costalba
2007-07-09  6:19         ` Junio C Hamano

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).