提交 c899a57c 编写于 作者: L Lars Hjemli 提交者: Junio C Hamano

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: NLars Hjemli <hjemli@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 a130976b
......@@ -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 <n> 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(),
};
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册