On Mon, 25 Jul 2005, Linus Torvalds wrote:
> 
> And they are in the wrong order, so "cvsimport" ends up committing the 
> last one, which is the _empty_ one.
> 
> Notice? We'll end up committing "COPYING 1.1" (the empty initial create)
> even though we _should_ have committed "COPYING 1.2" (the actual thing
> that BK committed).

David, how about a patch like this to cvsps? My very very limited testing
seems to say that it does the right thing..

It's very simple: if we are adding the same file twice to the same 
PatchSet, we just look at the ordering of the revisions. If the revision 
we're adding is older than the revision we already have, we just drop that 
revision entirely. If it's the same, something is really wrong, and we add 
it to the "collisions" list. And if it's newer, then we remove the old 
revision for that file, and add the new one instead.

As far as I can tell, the old code really was broken, since it would
happen to list different revisions in a random order when you had multiple
changes to the same file in the same patchset. This one always selects the
last one, which would seem to be the sane behaviour.

And this all seem to make "git cvsimport -p --bkcvs" do the right thing. 

                Linus

---
diff --git a/cvsps.c b/cvsps.c
--- a/cvsps.c
+++ b/cvsps.c
@@ -2384,8 +2384,31 @@ void patch_set_add_member(PatchSet * ps,
     for (next = ps->members.next; next != &ps->members; next = next->next) 
     {
        PatchSetMember * m = list_entry(next, PatchSetMember, link);
-       if (m->file == psm->file && ps->collision_link.next == NULL) 
-               list_add(&ps->collision_link, &collisions);
+       if (m->file == psm->file) {
+               int order = compare_rev_strings(psm->post_rev->rev, 
m->post_rev->rev);
+
+               /*
+                * Same revision too? Add it to the collision list
+                * if it isn't already.
+                */
+               if (!order) {
+                       if (ps->collision_link.next == NULL)
+                               list_add(&ps->collision_link, &collisions);
+                       return;
+               }
+                       
+               /*
+                * If this is an older revision than the one we already have
+                * in this patchset, just ignore it
+                */
+               if (order < 0)
+                       return;
+
+               /*
+                * This is a newer one, remove the old one
+                */
+               list_del(&m->link);
+       }
     }
 
     psm->ps = ps;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to