[gitg] [PATCH 2/3] Repect the mainline of merges



Normally the 1st parent of a commit is the branch we're merging _into_,
so if you keep this on the left then you can always read a merge as
right-to-left. At the moment it seems to be a bit random.
---
 libgitg/gitg-lanes.vala | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/libgitg/gitg-lanes.vala b/libgitg/gitg-lanes.vala
index da725ad..5e255cd 100644
--- a/libgitg/gitg-lanes.vala
+++ b/libgitg/gitg-lanes.vala
@@ -38,6 +38,7 @@ public class Lanes : Object
                public uint inactive;
                public Ggit.OId? from;
                public Ggit.OId? to;
+               public uint mainline;
 
                public LaneContainer.with_color(Ggit.OId? from,
                                                Ggit.OId? to,
@@ -47,6 +48,7 @@ public class Lanes : Object
                        this.to = to;
                        this.lane = new Lane.with_color(color);
                        this.inactive = 0;
+                       this.mainline = 0;
                }
 
                public LaneContainer(Ggit.OId? from,
@@ -120,7 +122,9 @@ public class Lanes : Object
                if (mylane == null)
                {
                        // there is no lane reserver for this comit, add a new lane
-                       d_lanes.append(new LaneContainer(myoid, null));
+                       LaneContainer newlane = new LaneContainer(myoid, null);
+                       newlane.mainline = 1;
+                       d_lanes.append((owned)newlane);
                        nextpos = (int)d_lanes.length() - 1;
                }
                else
@@ -160,11 +164,18 @@ public class Lanes : Object
                                // we add pos as a merge for the lane, also this means the
                                // color of this lane incluis the merge should change to
                                // one color
-                               container.lane.from.append(pos);
-                               container.lane.color.next_index();
-
-                               container.inactive = 0;
-                               container.from = myoid;
+                               if (i == 0 && mylane.mainline == 1 && container.mainline != 1) {
+                                       mylane.to = poid;
+                                       mylane.from = myoid;
+                                       mylane.inactive = 0;
+                                       mylane.lane.from.append(lnpos);
+                                       mylane.lane.color = Color.next();
+                                       d_lanes.remove(container);
+                               } else {
+                                       container.from = myoid;
+                                       container.inactive = 0;
+                                       container.lane.from.append(pos);
+                               }
 
                                continue;
                        }
-- 
1.8.2.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]