@matheusbsbs / matheus-bagliano / commits / c899a57c28
Fork 0

for-each-ref: fix setup of option-parsing for --sort

The option value for --sort is already a pointer to a pointer to struct ref_sort, so just use it. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lars Hjemli committed Nov 10, 2007 at 17:47 UTC c899a57c28ee7cf251f856b575128de21b5a9a12
2 files changed +23 -1
builtin-for-each-ref.c
+1 -1
@@ -847,7 +847,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
847 OPT_GROUP(""),
848 OPT_INTEGER( 0 , "count", &maxcount, "show only <n> matched refs"),
849 OPT_STRING( 0 , "format", &format, "format", "format to use for the output"),
850 - OPT_CALLBACK(0 , "sort", &sort_tail, "key",
850 + OPT_CALLBACK(0 , "sort", sort_tail, "key",
851 "field name to sort on", &opt_parse_sort),
852 OPT_END(),
853 };
t/t6300-for-each-ref.sh
+22
@@ -148,4 +148,26 @@ test_expect_success 'Check format "rfc2822" date fields output' '
148 git diff expected actual
149 '
150
151 +cat >expected <<\EOF
152 +refs/heads/master
153 +refs/tags/testtag
154 +EOF
155 +
156 +test_expect_success 'Verify ascending sort' '
157 + git-for-each-ref --format="%(refname)" --sort=refname >actual &&
158 + git diff expected actual
159 +'
160 +
161 +
162 +cat >expected <<\EOF
163 +refs/tags/testtag
164 +refs/heads/master
165 +EOF
166 +
167 +test_expect_success 'Verify descending sort' '
168 + git-for-each-ref --format="%(refname)" --sort=-refname >actual &&
169 + git diff expected actual
170 +'
171 +
172 +
173 test_done