Merge branch 'kn/for-each-branch'
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 Nov 2015 23:12:55 +0000 (15:12 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Nov 2015 23:12:57 +0000 (15:12 -0800)
Using the timestamp based criteria in "git branch --sort" did not
tiebreak branches that point at commits with the same timestamp (or
the same commit), making the resulting output unstable.

* kn/for-each-branch:
ref-filter: fallback on alphabetical comparison

ref-filter.c
t/t3203-branch-output.sh
index 1194f10ed60f2bb476e1d95d0cc11b4ad4265c7f..e205dd2f689ee5aeafe6ea66343fd01b85d2e354 100644 (file)
@@ -1457,7 +1457,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 = 0;
+                       cmp = strcmp(a->refname, b->refname);
                else
                        cmp = 1;
        }
index 9454423ca02af98ad50a089e0c0dc2bc1e952bd0..d3913f9088950a3ca848b8994abfddfecd3f6706 100755 (executable)
@@ -158,8 +158,8 @@ EOF
 
 test_expect_success 'git branch `--sort` option' '
        cat >expect <<-\EOF &&
-         branch-two
        * (HEAD detached from fromtag)
+         branch-two
          branch-one
          master
        EOF