git for-each-ref - sorting by multiple keys
- From
clime <clime7@gmail.com>
- Date
- May 2, 2020, 20:31 UTC
- Message-ID
- <CAGqZTUvuJgZH-YUxDTYunng3QD4-wwPgquZX1P=1P1R=Ku0s2g@mail.gmail.com>
Hello,
I have the following command:
/usr/bin/git for-each-ref --merged="${GIT_HEAD-HEAD}" --sort='-taggerdate' --sort='-*committerdate' --format="%(*committerdate)|%(taggerdate)|%(tag)" refs/tags
I thought this will use: -*commiterdate as a primary key and -taggerdate as a secondary. According to man page for --sort: "You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key."
But that doesn't seem to be the case. I created a repo with a single commit and created annotated tags on the commit in the following order:
$ git tag -a -m "foo" B $ git tag -a -m "foo" C $ git tag -a -m "foo" A
Yet the order I am getting after running the command is:
Sat May 2 22:10:30 2020 +0200|Sat May 2 22:14:49 2020 +0200|C Sat May 2 22:10:30 2020 +0200|Sat May 2 22:14:45 2020 +0200|B Sat May 2 22:10:30 2020 +0200|Sat May 2 22:14:51 2020 +0200|A
Is it a mistake in man pages? Is there any way to sort by multiple keys?
Thank you clime