Skip to content

Commit

Permalink
for-each-ref: fix setup of option-parsing for --sort
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars Hjemli authored and Junio C Hamano committed Nov 10, 2007
1 parent a130976 commit c899a57
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion builtin-for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
22 changes: 22 additions & 0 deletions t/t6300-for-each-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c899a57

Please sign in to comment.