{"thread":{"id":"47333","subject":"Feature request: Reduce amount of diff in patch","startedAt":"2017-11-28T16:16:54Z","lastAt":"2017-12-07T20:28:52Z","messageCount":4,"participants":["KES","Kaartic Sivaraam","Stefan Beller","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"333697","messageId":"372261511885370@web21o.yandex.ru","threadId":"47333","inReplyTo":null,"subject":"Feature request: Reduce amount of diff in patch","fromName":"KES","fromEmail":"kes-kes@yandex.ru","sentAt":"2017-11-28T16:09:30Z","receivedAt":"2017-11-28T16:16:54Z","isPatch":false,"sender":{"key":"kes-kes@yandex.ru","avatar":null},"body":"Hi.\n\nI get often patches which can be minimized:\n\n@@ -60,11 +64,8 @@ sub _get_filter {\n         address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n-    ]);\n \n-    $users =  $users->search( $filter, {\n-        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n-    });\n+    ]);\n \n \n     return $users;\n\nThis patch can be minimized to:\n\n@@ -60,11 +64,8 @@ sub _get_filter {\n         address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n     ]);\n \n-    $users =  $users->search( $filter, {\n-        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n-    });\n\n \n     return $users;\n\nMay you please fix the git to generate minimized patches?\n\nThank you\n"},{"id":"333701","messageId":"1511889885.16420.3.camel@gmail.com","threadId":"47333","inReplyTo":"372261511885370@web21o.yandex.ru","subject":"Re: Feature request: Reduce amount of diff in patch","fromName":"Kaartic Sivaraam","fromEmail":"kaartic.sivaraam@gmail.com","sentAt":"2017-11-28T17:24:45Z","receivedAt":"2017-11-28T17:24:55Z","isPatch":false,"sender":{"key":"kaartic.sivaraam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12448084?v=4"},"body":"On Tue, 2017-11-28 at 18:09 +0200, KES wrote:\n> Hi.\n> \n> I get often patches which can be minimized:\n> \n\nI guess the one below can't be (see below).\n\n\n> @@ -60,11 +64,8 @@ sub _get_filter {\n>          address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n> -    ]);\n>  \n> -    $users =  $users->search( $filter, {\n> -        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n> -    });\n> +    ]);\n>  \n>  \n>      return $users;\n> \n> This patch can be minimized to:\n> \n> @@ -60,11 +64,8 @@ sub _get_filter {\n>          address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n>      ]);\n>  \n> -    $users =  $users->search( $filter, {\n> -        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n> -    });\n> \n>  \n>      return $users;\n> \n> May you please fix the git to generate minimized patches?\n> \n\nYou seemed to have overlooked the empty line above the ']);' in the\noriginal patch. So, your minimized version isn't actually equivalent to\nthe original one. Further, when trying to recreate your patch I get the\nfollowing,\n\ndiff --git a/diff-test b/diff-test\nindex 1d5dc1b..f3ec38f 100644\n--- a/diff-test\n+++ b/diff-test\n@@ -1,10 +1,8 @@\n         address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n         country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n+\n     ]);\n \n-    $users =  $users->search( $filter, {\n-        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n-    });\n \n     return $users;\n\nI use git built from the source (2.15.0.531.g2ccb3012c)\n\n-- \nKaartic\n"},{"id":"334358","messageId":"CAGZ79kZt7hysp9Yzj8==nz9FAu3V4KduG9kH2KxhdEK5CTBiqA@mail.gmail.com","threadId":"47333","inReplyTo":"372261511885370@web21o.yandex.ru","subject":"Re: Feature request: Reduce amount of diff in patch","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-12-07T20:13:47Z","receivedAt":"2017-12-07T20:14:05Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Nov 28, 2017 at 8:09 AM, KES <kes-kes@yandex.ru> wrote:\n> Hi.\n>\n> I get often patches which can be minimized:\n>\n> @@ -60,11 +64,8 @@ sub _get_filter {\n>          address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n> -    ]);\n>\n> -    $users =  $users->search( $filter, {\n> -        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n> -    });\n> +    ]);\n>\n>\n>      return $users;\n>\n> This patch can be minimized to:\n>\n> @@ -60,11 +64,8 @@ sub _get_filter {\n>          address    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          company    =>  { -like => \\[ '?',  \"%$search%\" ] },\n>          country_code =>  { '=' => \\[ 'UPPER(?)' => $search ] },\n>      ]);\n>\n> -    $users =  $users->search( $filter, {\n> -        prefetch => { Packages => { Ips => { Subnet => { Server => 'Locality' }}}},\n> -    });\n>\n>\n>      return $users;\n>\n> May you please fix the git to generate minimized patches?\n\nYou can use a different diff algorithm.\n\n       --diff-algorithm={patience|minimal|histogram|myers}\n           Choose a diff algorithm. The variants are as follows:\n\n           default, myers\n               The basic greedy diff algorithm. Currently, this is the\n               default.\n\n           minimal\n               Spend extra time to make sure the smallest possible diff is\n               produced.\n\n           patience\n               Use \"patience diff\" algorithm when generating patches.\n\n           histogram\n               This algorithm extends the patience algorithm to \"support\n               low-occurrence common elements\".\n\n           For instance, if you configured diff.algorithm variable to a\n           non-default value and want to use the default one, then you have to\n           use --diff-algorithm=default option.\n\nSoon we'll have another diff algorithm \"anchor\" that tries to\nkeep a given line out of the +/- but rather move other lines around\nthe line to give equal results.\n"},{"id":"334362","messageId":"xmqqtvx2cmf9.fsf@gitster.mtv.corp.google.com","threadId":"47333","inReplyTo":"CAGZ79kZt7hysp9Yzj8==nz9FAu3V4KduG9kH2KxhdEK5CTBiqA@mail.gmail.com","subject":"Re: Feature request: Reduce amount of diff in patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-07T20:28:42Z","receivedAt":"2017-12-07T20:28:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Tue, Nov 28, 2017 at 8:09 AM, KES <kes-kes@yandex.ru> wrote:\n> ...\n>> May you please fix the git to generate minimized patches?\n>\n> You can use a different diff algorithm.\n> ...\n> Soon we'll have another diff algorithm \"anchor\" that tries to\n> keep a given line out of the +/- but rather move other lines around\n> the line to give equal results.\n\nWhile all of the above is correct, my understanding is that none of\nthem would produce a patch that KES wants to see.\n\nAnd we shouldn't ;-)  The two changes KES shows in the message are\nnot equivalent.\n"}]}