git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Wolfgang Denk <wd@denx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Teach parse_commit_buffer about grafting.
Date: Wed, 17 Aug 2005 19:13:31 -0700	[thread overview]
Message-ID: <7vd5ocouus.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 20050818003036.C53FD353BF9@atlas.denx.de

Wolfgang Denk <wd@denx.de> writes:

> The display in gitk --all gets changed a bit (before the  branch  was
> the  leftmost  line,  now  it's  the rightmost one), but it's still a
> dangling head, and the selected  "merge  point"  (commit  24ee89)  is
> still  displayed  with  just  one parent (de180e) - I would expect to
> also see d9af3c listed as parent, and the branch merging in here?
>
> Am I missing something?

The graft info is not used by anything other than those that use
parse_commit() to figure out the commit ancestry information.

The list of commits that appear in the top pane of the gitk is
generated by git-rev-list which knows how to do it, but the
parent and child links, and the lines between nodes are drawn by
gitk using the information it reads directly from the commit
objects.

My Tcl/Tk is really rusty, and I do not like this patch, but
here is my stab at teaching the code that reads commit objects
how to use grafts as well.

------------
[PATCH] Teach gitk to use grafts info

Finding commits to draw is done by git-rev-list which knows how
to do the grafts, but the lines between commits and the
parent / child links needs to be drawn by reading from the
commit objects.  Teach that part of the code how to grok grafts
info so that "fake" ancestry is shown sensibly in gitk.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 gitk |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -155,7 +155,7 @@ proc readcommit {id} {
 }
 
 proc parsecommit {id contents listed} {
-    global commitinfo children nchildren parents nparents cdate ncleft
+    global commitinfo children nchildren parents nparents cdate ncleft grafts
 
     set inhdr 1
     set comment {}
@@ -171,6 +171,23 @@ proc parsecommit {id contents listed} {
     }
     set parents($id) {}
     set nparents($id) 0
+    set has_graft [array get grafts $id]
+    if {"" != $has_graft} {
+	set parents($id) $grafts($id)
+	set nparents($id) [llength $parents($id)]
+	foreach p $parents($id) {
+	    if {![info exists nchildren($p)]} {
+		set children($p) {}
+		set nchildren($p) 0
+		set ncleft($p) 0
+	    }
+	    if {$listed && [lsearch -exact $children($p) $id] < 0} {
+		lappend children($p) $id
+		incr nchildren($p)
+		incr ncleft($p)
+	    }
+	}
+    }
     foreach line [split $contents "\n"] {
 	if {$inhdr} {
 	    if {$line == {}} {
@@ -178,6 +195,9 @@ proc parsecommit {id contents listed} {
 	    } else {
 		set tag [lindex $line 0]
 		if {$tag == "parent"} {
+		    if {"" != $has_graft} {
+			continue
+		    }
 		    set p [lindex $line 1]
 		    if {![info exists nchildren($p)]} {
 			set children($p) {}
@@ -3194,6 +3214,20 @@ foreach arg $argv {
 
 set history {}
 set historyindex 0
+set grafts('') nothing
+array unset grafts ''
+if {![catch { set graft [exec cat [gitdir]/info/grafts] }]} {
+    global grafts
+    foreach line [split $graft "\n"] {
+	set commit [lindex $line 0]
+	set llen [llength $line]
+	set pp {}
+	for {set i 1} {$i < $llen} {incr i} {
+	    lappend pp [lindex $line $i]
+	}
+	set grafts($commit) $pp
+    }
+}
 
 set stopped 0
 set redisplaying 0

  reply	other threads:[~2005-08-18  2:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-26 18:57 Linux BKCVS kernel history git import Linus Torvalds
2005-07-26 19:36 ` Diego Calleja
2005-07-26 22:01   ` A Large Angry SCM
2005-07-27  9:40 ` David Woodhouse
2005-07-27 15:29   ` Linus Torvalds
2005-07-27 15:41     ` David Woodhouse
2005-07-27 15:50       ` Linus Torvalds
2005-07-30  8:00         ` [PATCH] Teach parse_commit_buffer about grafting Junio C Hamano
2005-07-30  8:40           ` Matthias Urlichs
2005-07-30 10:53           ` Johannes Schindelin
2005-08-18  0:30           ` Wolfgang Denk
2005-08-18  2:13             ` Junio C Hamano [this message]
2005-08-18  3:02               ` Paul Mackerras
2005-08-18  5:16                 ` Linus Torvalds
2005-08-19  0:29                   ` Paul Mackerras
2005-08-19  0:46                     ` Johannes Schindelin
2005-08-19  0:50                     ` Linus Torvalds

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=7vd5ocouus.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=paulus@samba.org \
    --cc=wd@denx.de \
    /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).