Skip to content

Commit adac811

Browse files
pcloudsgitster
authored andcommitted
refs.h: add a note about sorting order of for_each_ref_*
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2269e2a commit adac811

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

refs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ typedef int each_ref_fn(const char *refname,
230230
* it is not safe to modify references while an iteration is in
231231
* progress, unless the same callback function invocation that
232232
* modifies the reference also returns a nonzero value to immediately
233-
* stop the iteration.
233+
* stop the iteration. Returned references are sorted.
234234
*/
235235
int refs_for_each_ref(struct ref_store *refs,
236236
each_ref_fn fn, void *cb_data);
@@ -370,7 +370,7 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void
370370

371371
/*
372372
* Calls the specified function for each reflog file until it returns nonzero,
373-
* and returns the value
373+
* and returns the value. Reflog file order is unspecified.
374374
*/
375375
int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data);
376376
int for_each_reflog(each_ref_fn fn, void *cb_data);

t/t1405-main-ref-store.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
5353
test_cmp expected actual
5454
'
5555

56+
test_expect_success 'for_each_ref() is sorted' '
57+
$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
58+
sort actual > expected &&
59+
test_cmp expected actual
60+
'
61+
5662
test_expect_success 'resolve_ref(new-master)' '
5763
SHA1=`git rev-parse new-master` &&
5864
echo "$SHA1 refs/heads/new-master 0x0" >expected &&

t/t1406-submodule-ref-store.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
4747
test_cmp expected actual
4848
'
4949

50+
test_expect_success 'for_each_ref() is sorted' '
51+
$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
52+
sort actual > expected &&
53+
test_cmp expected actual
54+
'
55+
5056
test_expect_success 'resolve_ref(master)' '
5157
SHA1=`git -C sub rev-parse master` &&
5258
echo "$SHA1 refs/heads/master 0x0" >expected &&

0 commit comments

Comments
 (0)