{"thread":{"id":"4713","subject":"[PATCH 2/4] make filepairs detachable","startedAt":"2006-06-30T00:27:36Z","lastAt":"2006-06-30T08:21:15Z","messageCount":5,"participants":["Alex Riesen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"22862","messageId":"20060630002736.GB22618@steel.home","threadId":"4713","inReplyTo":null,"subject":"[PATCH 2/4] make filepairs detachable","fromName":"Alex Riesen","fromEmail":"fork0@t-online.de","sentAt":"2006-06-30T00:27:36Z","receivedAt":"2006-06-30T00:27:36Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Actually, just make sure diff_flush does not crash for diff queue\nentries which were cleared.\n\n---\n diff.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5a71489..b3480f6 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2281,6 +2281,8 @@ void diff_flush(struct diff_options *opt\n \t}\n \tfor (i = 0; i < q->nr; i++) {\n \t\tstruct diff_filepair *p = q->queue[i];\n+\t\tif (!p)\n+\t\t\tcontinue;\n \t\tflush_one_pair(p, diff_output_format, options, diffstat);\n \t}\n \n@@ -2290,6 +2292,8 @@ void diff_flush(struct diff_options *opt\n \t}\n \n \tfor (i = 0; i < q->nr; i++) {\n+\t\tif (!q->queue[i])\n+\t\t    continue;\n \t\tif (diffstat && options->summary)\n \t\t\tdiff_summary(q->queue[i]);\n \t\tdiff_free_filepair(q->queue[i]);\n-- \n1.4.1.rc1.g17dc\n"},{"id":"22871","messageId":"7vy7vfmoit.fsf@assigned-by-dhcp.cox.net","threadId":"4713","inReplyTo":"20060630002736.GB22618@steel.home","subject":"Re: [PATCH 2/4] make filepairs detachable","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-30T01:16:10Z","receivedAt":"2006-06-30T01:16:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"fork0@t-online.de (Alex Riesen) writes:\n\n> Actually, just make sure diff_flush does not crash for diff queue\n> entries which were cleared.\n\nSomehow I really feel uneasy about this one.  I think it is the\nresponsibility of the one who mangles the queue to adjust the\nentries and count consistent.\n"},{"id":"22897","messageId":"81b0412b0606300042r24931d9i5fad0e849b8de84c@mail.gmail.com","threadId":"4713","inReplyTo":"7vy7vfmoit.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/4] make filepairs detachable","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-06-30T07:42:01Z","receivedAt":"2006-06-30T07:42:01Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/30/06, Junio C Hamano <junkio@cox.net> wrote:\n>\n> > Actually, just make sure diff_flush does not crash for diff queue\n> > entries which were cleared.\n>\n> Somehow I really feel uneasy about this one.  I think it is the\n> responsibility of the one who mangles the queue to adjust the\n> entries and count consistent.\n>\n\nThat's what I get after being exposed to double-linked lists for\ntoo long: I begin to think it's fine to take whatever I want.\nThe pairs are actually exactly what I need, so I take them.\nI think I just have to encapsulate it nicely, i.e.:\n\n    struct diff_filepair *diff_queued_detach(int pos)\n    {\n        struct diff_filepair *pair = NULL;\n        if (pos < diff_queued_diff.nr) {\n            diff_queued_diff.queue[pos];\n            if (diff_queued_diff.nr - pos > 1)\n                memmove(pair->queue + pos, pair->queue + pos + 1,\n                        diff_queued_diff.nr - pos - 1);\n            diff_queued_diff.nr--;\n        }\n        return pair;\n    }\n\nBTW, is there any chance we get the struct diff_filepair's\ndouble-linked? They don't seem to be sorted. Will increase\nthe memory footprint, though.\n"},{"id":"22900","messageId":"7v7j2zkrod.fsf@assigned-by-dhcp.cox.net","threadId":"4713","inReplyTo":"81b0412b0606300042r24931d9i5fad0e849b8de84c@mail.gmail.com","subject":"Re: [PATCH 2/4] make filepairs detachable","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-30T07:50:58Z","receivedAt":"2006-06-30T07:50:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> BTW, is there any chance we get the struct diff_filepair's\n> double-linked? They don't seem to be sorted. Will increase\n> the memory footprint, though.\n\nYou do not necessarily have to do things in place.  In fact, all\nof the standard diffcore transformers create a new queue, read\nfrom the old queue and place the filtered or munged result in\nthe new queue, swap the global queued_diff variable to point at\nthe new one and discard the old queue.\n\nSee diff.c::diffcore_apply_filter() for the simplest example.\n"},{"id":"22902","messageId":"81b0412b0606300121q4148dfb0qb5915bd029d72f44@mail.gmail.com","threadId":"4713","inReplyTo":"7v7j2zkrod.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/4] make filepairs detachable","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-06-30T08:21:15Z","receivedAt":"2006-06-30T08:21:15Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/30/06, Junio C Hamano <junkio@cox.net> wrote:\n>\n> > BTW, is there any chance we get the struct diff_filepair's\n> > double-linked? They don't seem to be sorted. Will increase\n> > the memory footprint, though.\n>\n> You do not necessarily have to do things in place.  In fact, all\n> of the standard diffcore transformers create a new queue, read\n> from the old queue and place the filtered or munged result in\n> the new queue, swap the global queued_diff variable to point at\n> the new one and discard the old queue.\n>\n> See diff.c::diffcore_apply_filter() for the simplest example.\n>\n\nI see. Looks dangerous outside of diff.c though.\n"}]}