All of lore.kernel.org
 help / color / mirror / Atom feed
* for-each-ref output order change in 2.7.0
@ 2016-01-09  1:07 Bryan Turner
  2016-01-09 15:40 ` Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Bryan Turner @ 2016-01-09  1:07 UTC (permalink / raw)
  To: Git Users

In one of our tests, we have a set of branches whose names are all
special characters (%, @, etc). Most of them branches have identical
tip commits and just have different names. In 2.7.0, when ordering by
-committerdate, the branches are now returned in a different order. I
don't think this is a bug, based on the commit it bisects to, but I'm
wondering if someone can confirm.

2.6.5 and prior (tested all the way back to 1.7.6, so this was
consistent for a long time):

refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100

2.7.0:

refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100

I've bisected this back to:

bturner@ubuntu:~/Development/oss/git/git$ git bisect bad
9e468334b41c1d1fc715de177ef1f61a36c1cf01 is the first bad commit
commit 9e468334b41c1d1fc715de177ef1f61a36c1cf01
Author: Karthik Nayak <karthik.188@gmail.com>
Date:   Fri Oct 30 14:15:28 2015 +0530

    ref-filter: fallback on alphabetical comparison

The message for that commit indicates that sorting numerics (which I
assume is the implementation for committerdate) now falls back on
alphabetical for identical values, suggesting this order change is
actually intentional and correct. Is that right?

(Note: The alphabetical-ness of the branch names is reversed, which
seems logical given my original sort was -committerdate. A
--sort=refname looks like this.

refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100

That's probably more correct too.)

Best regards,
Bryan Turner

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: for-each-ref output order change in 2.7.0
  2016-01-09  1:07 for-each-ref output order change in 2.7.0 Bryan Turner
@ 2016-01-09 15:40 ` Matthieu Moy
  2016-01-09 17:21   ` Karthik Nayak
  0 siblings, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2016-01-09 15:40 UTC (permalink / raw)
  To: Bryan Turner, Karthik Nayak; +Cc: Git Users

Hi,

Cc-ing Karthik to draw his attention on the message.

----- Original Message -----
> In one of our tests, we have a set of branches whose names are all
> special characters (%, @, etc). Most of them branches have identical
> tip commits and just have different names. In 2.7.0, when ordering by
> -committerdate, the branches are now returned in a different order. I
> don't think this is a bug, based on the commit it bisects to, but I'm
> wondering if someone can confirm.
> 
> 2.6.5 and prior (tested all the way back to 1.7.6, so this was
> consistent for a long time):
> 
> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
> 
> 2.7.0:
> 
> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
> 
> I've bisected this back to:
> 
> bturner@ubuntu:~/Development/oss/git/git$ git bisect bad
> 9e468334b41c1d1fc715de177ef1f61a36c1cf01 is the first bad commit
> commit 9e468334b41c1d1fc715de177ef1f61a36c1cf01
> Author: Karthik Nayak <karthik.188@gmail.com>
> Date:   Fri Oct 30 14:15:28 2015 +0530
> 
>     ref-filter: fallback on alphabetical comparison
> 
> The message for that commit indicates that sorting numerics (which I
> assume is the implementation for committerdate) now falls back on
> alphabetical for identical values, suggesting this order change is
> actually intentional and correct.

And also that the previous order was arbitrary (just letting the sort
algorithm chose which one to put first in case of equality on the main
sorting criterion), so the fact that it was stable previously is more
or less just luck. Now it should be stable.

> Is that right?
> 
> (Note: The alphabetical-ness of the branch names is reversed, which
> seems logical given my original sort was -committerdate. A
> --sort=refname looks like this.
> 
> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
> refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
> 
> That's probably more correct too.)
> 
> Best regards,
> Bryan Turner

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: for-each-ref output order change in 2.7.0
  2016-01-09 15:40 ` Matthieu Moy
@ 2016-01-09 17:21   ` Karthik Nayak
  2016-01-09 18:00     ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Karthik Nayak @ 2016-01-09 17:21 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Bryan Turner, Git Users

Hello,

On Sat, Jan 9, 2016 at 9:10 PM, Matthieu Moy
<matthieu.moy@grenoble-inp.fr> wrote:
> Hi,
>
> Cc-ing Karthik to draw his attention on the message.
>

Thanks, I didn't really notice it.

> ----- Original Message -----
>> In one of our tests, we have a set of branches whose names are all
>> special characters (%, @, etc). Most of them branches have identical
>> tip commits and just have different names. In 2.7.0, when ordering by
>> -committerdate, the branches are now returned in a different order. I
>> don't think this is a bug, based on the commit it bisects to, but I'm
>> wondering if someone can confirm.
>>
>> 2.6.5 and prior (tested all the way back to 1.7.6, so this was
>> consistent for a long time):
>>
>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>>
>> 2.7.0:
>>
>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>>
>> I've bisected this back to:
>>
>> bturner@ubuntu:~/Development/oss/git/git$ git bisect bad
>> 9e468334b41c1d1fc715de177ef1f61a36c1cf01 is the first bad commit
>> commit 9e468334b41c1d1fc715de177ef1f61a36c1cf01
>> Author: Karthik Nayak <karthik.188@gmail.com>
>> Date:   Fri Oct 30 14:15:28 2015 +0530
>>
>>     ref-filter: fallback on alphabetical comparison
>>
>> The message for that commit indicates that sorting numerics (which I
>> assume is the implementation for committerdate) now falls back on
>> alphabetical for identical values, suggesting this order change is
>> actually intentional and correct.
>
> And also that the previous order was arbitrary (just letting the sort
> algorithm chose which one to put first in case of equality on the main
> sorting criterion), so the fact that it was stable previously is more
> or less just luck. Now it should be stable.
>
>> Is that right?
>>

Yup, absolutely.

>> (Note: The alphabetical-ness of the branch names is reversed, which
>> seems logical given my original sort was -committerdate. A
>> --sort=refname looks like this.
>>
>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>>
>> That's probably more correct too.)
>>
>> Best regards,
>> Bryan Turner

This is correct as per the patch, But I'm wondering if this is desired.
I.E when sorting in reverse order should the fallback (alphabetical sort)
also be in reverse order?

-- 
Regards,
Karthik Nayak

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: for-each-ref output order change in 2.7.0
  2016-01-09 17:21   ` Karthik Nayak
@ 2016-01-09 18:00     ` Johannes Sixt
  2016-01-09 21:29       ` Karthik Nayak
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-01-09 18:00 UTC (permalink / raw)
  To: Karthik Nayak; +Cc: Matthieu Moy, Bryan Turner, Git Users

Am 09.01.2016 um 18:21 schrieb Karthik Nayak:
>>> (Note: The alphabetical-ness of the branch names is reversed, which
>>> seems logical given my original sort was -committerdate. A
>>> --sort=refname looks like this.
>>>
>>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>>> refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
>>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>>>
>>> That's probably more correct too.)
>>>
>>> Best regards,
>>> Bryan Turner
>
> This is correct as per the patch, But I'm wondering if this is desired.
> I.E when sorting in reverse order should the fallback (alphabetical sort)
> also be in reverse order?

IMO, the fallback sorting should be in reverse order only when the user 
explicitley asked for reverse order. Just because committer date implies 
some "reverse" ordering should not imply that refs with the same 
committer date should also be listed in reverse alphabetical order.

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: for-each-ref output order change in 2.7.0
  2016-01-09 18:00     ` Johannes Sixt
@ 2016-01-09 21:29       ` Karthik Nayak
  2016-01-10  9:51         ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Karthik Nayak @ 2016-01-09 21:29 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Matthieu Moy, Bryan Turner, Git Users

On Sat, Jan 9, 2016 at 11:30 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> Am 09.01.2016 um 18:21 schrieb Karthik Nayak:
>>>>
>>>> (Note: The alphabetical-ness of the branch names is reversed, which
>>>> seems logical given my original sort was -committerdate. A
>>>> --sort=refname looks like this.
>>>>
>>>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>>>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>>>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>>>> refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
>>>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>>>>
>>>> That's probably more correct too.)
>>>>
>>>> Best regards,
>>>> Bryan Turner
>>
>>
>> This is correct as per the patch, But I'm wondering if this is desired.
>> I.E when sorting in reverse order should the fallback (alphabetical sort)
>> also be in reverse order?
>
>
> IMO, the fallback sorting should be in reverse order only when the user
> explicitley asked for reverse order. Just because committer date implies
> some "reverse" ordering should not imply that refs with the same committer
> date should also be listed in reverse alphabetical order.
>
> -- Hannes
>

I was thinking along the same lines. But do we want to expose the fallback to
the user (i.e let them choose if its reversible or not)? If not Its only a small
change required:

diff --git a/ref-filter.c b/ref-filter.c
index cc850b0..59d43d7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1554,7 +1554,7 @@ static int cmp_ref_sorting(struct ref_sorting
*s, struct ref_array_item *a, stru
                if (va->ul < vb->ul)
                        cmp = -1;
                else if (va->ul == vb->ul)
-                       cmp = strcmp(a->refname, b->refname);
+                       return strcmp(a->refname, b->refname);
                else
                        cmp = 1;
        }

I could send a patch, as soon as we decide if we want to stick something
simple like this or expose the fallback sort to the user.

-- 
Regards,
Karthik Nayak

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: for-each-ref output order change in 2.7.0
  2016-01-09 21:29       ` Karthik Nayak
@ 2016-01-10  9:51         ` Johannes Sixt
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2016-01-10  9:51 UTC (permalink / raw)
  To: Karthik Nayak; +Cc: Matthieu Moy, Bryan Turner, Git Users

Am 09.01.2016 um 22:29 schrieb Karthik Nayak:
> On Sat, Jan 9, 2016 at 11:30 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> Am 09.01.2016 um 18:21 schrieb Karthik Nayak:
>>>>>
>>>>> (Note: The alphabetical-ness of the branch names is reversed, which
>>>>> seems logical given my original sort was -committerdate. A
>>>>> --sort=refname looks like this.

After reading up on branch sorting, I notice that the single dash in 
front of committerdate is not a typo, but a request to sort in reverse. 
Therefore, the resulting sort order, which was

refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/@#$% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100

is totally correct.

>>>>>
>>>>> refs/heads/!@#$% -> Tue Jan 3 17:00:51 2012 +1100
>>>>> refs/heads/!@#% -> Tue Jan 3 17:04:06 2012 +1100
>>>>> refs/heads/% -> Tue Jan 3 17:00:51 2012 +1100
>>>>> refs/heads/@#$% - >Tue Jan 3 17:00:51 2012 +1100
>>>>> refs/heads/@#% -> Tue Jan 3 17:00:51 2012 +1100
>>>>>
>>>>> That's probably more correct too.)

But I don't know what would be "more" correct here. It's simply correct.

>>> This is correct as per the patch, But I'm wondering if this is desired.
>>> I.E when sorting in reverse order should the fallback (alphabetical sort)
>>> also be in reverse order?
>>
>>
>> IMO, the fallback sorting should be in reverse order only when the user
>> explicitley asked for reverse order. Just because committer date implies
>> some "reverse" ordering should not imply that refs with the same committer
>> date should also be listed in reverse alphabetical order.

I was wrong here. Sorting by committerdate does not imply reverse-ness. 
I just did not know enough about the --sort options when I wrote this 
paragraph.

>
> I was thinking along the same lines. But do we want to expose the fallback to
> the user (i.e let them choose if its reversible or not)?

No, we do not want to expose the fallback to the user. And as far as I 
can see, no further change is required.

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-10  9:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-09  1:07 for-each-ref output order change in 2.7.0 Bryan Turner
2016-01-09 15:40 ` Matthieu Moy
2016-01-09 17:21   ` Karthik Nayak
2016-01-09 18:00     ` Johannes Sixt
2016-01-09 21:29       ` Karthik Nayak
2016-01-10  9:51         ` Johannes Sixt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.