refs.h: add a note about sorting order of for_each_ref_*
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 26 Mar 2017 02:42:41 +0000 (09:42 +0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Apr 2017 10:53:25 +0000 (03:53 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.h
t/t1405-main-ref-store.sh
t/t1406-submodule-ref-store.sh
diff --git a/refs.h b/refs.h
index 1a07f9d86fb664191a12aca4f9989734685a2650..49e97d7d5fdf1ce385ea8917bda00a4cce68561f 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -230,7 +230,7 @@ typedef int each_ref_fn(const char *refname,
  * it is not safe to modify references while an iteration is in
  * progress, unless the same callback function invocation that
  * modifies the reference also returns a nonzero value to immediately
- * stop the iteration.
+ * stop the iteration. Returned references are sorted.
  */
 int refs_for_each_ref(struct ref_store *refs,
                      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
 
 /*
  * Calls the specified function for each reflog file until it returns nonzero,
- * and returns the value
+ * and returns the value. Reflog file order is unspecified.
  */
 int refs_for_each_reflog(struct ref_store *refs, each_ref_fn fn, void *cb_data);
 int for_each_reflog(each_ref_fn fn, void *cb_data);
index 77e1c130c2de85d18fadc114e82c7d169e075ab6..490521f8cbd5eb28607b38860fb19a3ee20fdd56 100755 (executable)
@@ -53,6 +53,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
        test_cmp expected actual
 '
 
+test_expect_success 'for_each_ref() is sorted' '
+       $RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
+       sort actual > expected &&
+       test_cmp expected actual
+'
+
 test_expect_success 'resolve_ref(new-master)' '
        SHA1=`git rev-parse new-master` &&
        echo "$SHA1 refs/heads/new-master 0x0" >expected &&
index 22214ebd326145214ea876e1bdd538b2b5158196..13b5454c5642f2f21786bb8bd3d06a2d27f1cf15 100755 (executable)
@@ -47,6 +47,12 @@ test_expect_success 'for_each_ref(refs/heads/)' '
        test_cmp expected actual
 '
 
+test_expect_success 'for_each_ref() is sorted' '
+       $RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
+       sort actual > expected &&
+       test_cmp expected actual
+'
+
 test_expect_success 'resolve_ref(master)' '
        SHA1=`git -C sub rev-parse master` &&
        echo "$SHA1 refs/heads/master 0x0" >expected &&