From: Lars Hjemli Date: Sat, 10 Nov 2007 16:47:54 +0000 (+0100) Subject: for-each-ref: fix setup of option-parsing for --sort X-Git-Tag: v1.5.4-rc0~233 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c899a57c28ee7cf251f856b575128de21b5a9a12;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index da8c7948e..e909e66be 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -847,7 +847,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_INTEGER( 0 , "count", &maxcount, "show only matched refs"), OPT_STRING( 0 , "format", &format, "format", "format to use for the output"), - OPT_CALLBACK(0 , "sort", &sort_tail, "key", + OPT_CALLBACK(0 , "sort", sort_tail, "key", "field name to sort on", &opt_parse_sort), OPT_END(), }; diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh index d0809eb65..c72263505 100755 --- a/t/t6300-for-each-ref.sh +++ b/t/t6300-for-each-ref.sh @@ -148,4 +148,26 @@ test_expect_success 'Check format "rfc2822" date fields output' ' git diff expected actual ' +cat >expected <<\EOF +refs/heads/master +refs/tags/testtag +EOF + +test_expect_success 'Verify ascending sort' ' + git-for-each-ref --format="%(refname)" --sort=refname >actual && + git diff expected actual +' + + +cat >expected <<\EOF +refs/tags/testtag +refs/heads/master +EOF + +test_expect_success 'Verify descending sort' ' + git-for-each-ref --format="%(refname)" --sort=-refname >actual && + git diff expected actual +' + + test_done