Skip to content

Commit 415095f

Browse files
committed
Merge branch 'kn/for-each-branch'
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
2 parents 2635c2b + 9e46833 commit 415095f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ref-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
14571457
if (va->ul < vb->ul)
14581458
cmp = -1;
14591459
else if (va->ul == vb->ul)
1460-
cmp = 0;
1460+
cmp = strcmp(a->refname, b->refname);
14611461
else
14621462
cmp = 1;
14631463
}

t/t3203-branch-output.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ EOF
158158

159159
test_expect_success 'git branch `--sort` option' '
160160
cat >expect <<-\EOF &&
161-
branch-two
162161
* (HEAD detached from fromtag)
162+
branch-two
163163
branch-one
164164
master
165165
EOF

0 commit comments

Comments
 (0)