refs.h: add a note about sorting order of for_each_ref_*
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Mar 26, 2017 at 09:42 UTC
adac8115a6e7f9841c48e4fe48b74e0ce652ef58
3 files changed
+14
-2
refs.h
+2
-2
@@ -230,7 +230,7 @@ typedef int each_ref_fn(const char *refname,
230
* it is not safe to modify references while an iteration is in
231
* progress, unless the same callback function invocation that
232
* modifies the reference also returns a nonzero value to immediately
233
- * stop the iteration.
233
+ * stop the iteration. Returned references are sorted.
234
*/
235
int refs_for_each_ref(struct ref_store *refs,
236
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
370
371
/*
372
* 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.
374
*/
375
int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data);
376
int for_each_reflog(each_ref_fn fn, void *cb_data);
t/t1405-main-ref-store.sh
+6
@@ -53,6 +53,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
53
test_cmp expected actual
54
'
55
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
+
62
test_expect_success 'resolve_ref(new-master)' '
63
SHA1=`git rev-parse new-master` &&
64
echo "$SHA1 refs/heads/new-master 0x0" >expected &&
t/t1406-submodule-ref-store.sh
+6
@@ -47,6 +47,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
47
test_cmp expected actual
48
'
49
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
+
56
test_expect_success 'resolve_ref(master)' '
57
SHA1=`git -C sub rev-parse master` &&
58
echo "$SHA1 refs/heads/master 0x0" >expected &&