Repository: arxanas/git-branchless (Rust)

Issue:
`git-branchless query` prints commits in reverse order
### Description of the bug

According to [the documentation](https://github.com/arxanas/git-branchless/wiki/Command:-git-query#usage):

> The output is topologically-sorted, i.e. ancestor commits will appear before descendant commits in the list.

However, I seem to be seeing the opposite:

```sh
➜ git-branchless smartlog
⋮
◇ da757c2 1h (main, remote origin/main) Initial work for smarter `that` marks (#957)
┃
◯ 3104728 1h (foo-bar) A few actions support smarter `that` marks
┃
◯ 9841c5c 1h (pokey/some-smarter-that-marks) Update fixtures
┃
● 404fd54 4m (ᐅ pokey/testing) Kick CI

➜ git-branchless query "stack()"
404fd54 Kick CI
9841c5c Update fixtures
3104728 A few actions support smarter `that` marks
```

Note that I've abbreviated my smartlog here to only show the current stack

### Expected behavior

The commits appear in topological order

### Actual behavior

The commits appear in **reverse** topological order

### Version of `rustc`

rustc 1.62.1 (e092d0b6b 2022-07-16)

### Automated bug report

#### Software version

git-branchless 0.4.0

#### Operating system

macOS 12.4 (Darwin 21.5.0)

#### Command-line

```bash
/Users/pokey/.cargo/bin/git-branchless bug-report 
```

#### Environment variables

```bash
SHELL=/usr/local/bin/zsh
EDITOR=edit-in-vscode
```

#### Git version

```
> git version 
git version 2.33.1
```

#### Hooks


<details>
<summary>Show 6 hooks</summary>

##### Hook `post-commit`

```
#!/bin/sh

## START BRANCHLESS CONFIG

git branchless hook-post-commit "$@"
## END BRANCHLESS CONFIG
```
##### Hook `post-merge`

```
#!/bin/sh

## START BRANCHLESS CONFIG

git branchless hook-post-merge "$@"
## END BRANCHLESS CONFIG
```
##### Hook `post-rewrite`

```
#!/bin/sh

## START BRANCHLESS CONFIG

git branchless hook-post-rewrite "$@"
## END BRANCHLESS CONFIG
```
##### Hook `post-checkout`

```
#!/bin/sh

## START BRANCHLESS CONFIG

git branchless hook-post-checkout "$@"
## END BRANCHLESS CONFIG
```
##### Hook `pre-auto-gc`

```
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-pre-auto-gc "$@"
## END BRANCHLESS CONFIG
```
##### Hook `reference-transaction`

```
#!/bin/sh
## START BRANCHLESS CONFIG

# Avoid canceling the reference transaction in the case that `branchless` fails
# for whatever reason.
git branchless hook-reference-transaction "$@" || (
echo 'branchless: Failed to process reference transaction!'
echo 'branchless: Some events (e.g. branch updates) may have been lost.'
echo 'branchless: This is a bug. Please report it.'
)
## END BRANCHLESS CONFIG
```

</details>

#### Events


<details>
<summary>Show 5 events</summary>

##### Event ID: 22703, transaction ID: 19705 (message: hook-post-checkout)

1. `RefUpdateEvent { timestamp: 1663774877.761121, event_tx_id: EventTransactionId(19705), ref_name: "HEAD", old_oid: 404fd540d4085267c242e4b55c650ee845404a10, new_oid: 404fd540d4085267c242e4b55c650ee845404a10, message: None }`
```
:
O 3d53c87 1y xxxxxxxx xxx xxxxxx xxxxxx
|\
: o 06047b9 1y xxxxxxx xxxx xxxxxx
: |
: o 8e63ce3 1y xxxxxx xxxxx
: |
: o 42308e5 1y (redacted-ref-0) xxxxxx xxxxxxxxxxx xxxxx xxx xxx
:
O cd8258f 1y xxx xxxxx xxxxx xxxxxx xx xxxxxx xxxxxx
|\
: o 5ff6852 1y (redacted-ref-1) xxxxxxxxxxxxxxxx xxxxxxx xxxxx
:
O f014bb6 329d xxxxxxx xxxxxx xxxxxx
|\
: o bfb6357 321d (redacted-ref-2) xxxxxxx xxxx
:
O a6bdb3a 317d xxxxxxx xx xxxxxxxxxxx xxxxxx
|\
: o 0683431 314d (redacted-ref-3) xxxxxxx xxxxxxx xxxx xxxxxx
:
O 39f91b7 142d xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx xxx x xxxxx xxxxxxxxx xxxxxx
|\
| o c8bf7b2 133d (redacted-ref-4) xxxxxxxx xxxxxxx
|\
: o 9672214 126d xxxxxxx xxxxxxxxxx xxxxxx
:
O f9b1bf0 106d xxxxxx xxxxxxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxxxx xxxxxx
|\
: o 6ab32e2 105d xxxxxxx xxxx xxx xxxxxxxxxxx xxxxxxxx
:
O 10c355f 89d xxx xxxxxx xxxx xxxxxxxx xxxxxxx xx xxxx xxxx xxxxxx
|\
| o bf77b8c 89d xxxxxxx xxxxx xxxxxxxxxxx
| |
| o 9529dc3 89d (redacted-ref-5) xxxxx xxxxxxxxxx
|\
: o f931c9a 89d (redacted-ref-6) xxxxxxx xxxxxxxxxx xxxxxx
:
O 3419b74 76d xxx x xxxxxx xxxx xxxxxxxx xxxxxx
|\
: o 0f247a7 75d xxxxxx xxxxxxxxxxxxxxxx
: |
: o afba845 75d xxxxxxxxxx xxxxxxxx
: |
: o 81a6d9b 75d xxxxxxx xxxxxxxx xxxxx
: |
: o b3504a6 75d (redacted-ref-7) xxxx xx xxxxxx xxxx
:
O b639e42 64d xxx xxxxxxxxxxx xxxxxx
|\
: o 92a2cdc 64d xxxx xxxxx xxxx xxxxxxxxxx xxxx xxxxxx
: |
: o 3632e8d 64d xxx x xxxxxxx
: |
: o 5895e4c 14d (redacted-ref-8) xxxxxx xxxxx xx xx
:
O 560a7a1 4h xxxxx xxxxxxxxx xxxxxx xxxx xxxx xxxx xxxxxxxx xxxxxx
|\
| o 9916d85 4h (redacted-ref-9) xxxxxxx xxxxx xx xxxx xx xxxxxx
|\
| o 05e2a95 4h xxxx xx xxxxxxx xxxxxxxxxxx xxx xxxxx xxxxxxx
|\
| o 1b4ce7f 4h xxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxx
| |
| o ee0b97f 4h xxxxx xxxxxx
| |
| o d30d01a 4h (redacted-ref-10) xxx
|\
| o 1f810a2 4h (redacted-ref-11) xxxxxx xxx xxxxxxxxxx
| |
| o ad7f85a 4h xxxxxxxxxxxxxxx xx xxxxxxxxxx
|\
| o 507cab1 4h xxx xxxxx xxxxxxxxxxx
| |
| o 59eb137 4h xxx xxxxx xxxxxxx
| |
| o bd53f94 4h (redacted-ref-12) xxx xxxxxxxx xxxxx
|\
| o 86362e9 4h (redacted-ref-13) xxxxxxx xxxxxx xx xxxxxxxxxxxxxxxx
|\
| o 8f8ed0a 4h xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx
| |
| o ea87d33 3h (redacted-ref-14) xxxxxxx xxxxxxxxxxxxx
|\
| o cf83144 4h xxxxxxxxxxxxxx xx xxxxxx xxx xxxxxx xxxxx
|\
| o d5f3eca 4h (redacted-ref-15) xxxx xxxxxxxx xxxxxxx
|\
| o f0ebe29 4h xxxxxx xxxxx
| |
| o ea5cc71 4h (redacted-ref-16) xxx xxxxxxxxxxxxxxxxxxxxxxx
|
O 6773798 3h xxxxxx xxxxxx xxxx xxxx xxxxxxxxxx xxxxx xxxxxx
|\
| o 6ee3910 2h (redacted-ref-17) xxxxx xxxx xxxxxxxxx
|
O 9195c6a 3h xxxxxxx xxxxxxx xxxxxxxx xxxxxx xxx xxxxxxxxx xxxxxx
|\
| o 0f325c7 2h xxxxxxx xxxxx xxxxxxxx xxxxxxx
| |
| o 185ee46 2h xxxxxxxxxxxxxxx xxxx xxxxx xxxx xxxxxxxxxxxxxx xxxxx
| |
| o bce398b 2h xxxxxxx xxxxxxxx xxxxxxx
| |
| o 397f28a 2h xxx
| |
| o 19b8f0a 2h (redacted-ref-18) xxxxxxx xx xxx xxxxxx xxxxx
|
O da757c2 1h (redacted-ref-19, remote origin/main) xxxxxxx xxxx xxx xxxxxxx xxxxxx xxxxx xxxxxx
|
o 3104728 1h (redacted-ref-20) x xxx xxxxxxx xxxxxxx xxxxxxx xxxxxx xxxxx
|
o 9841c5c 1h (redacted-ref-21) xxxxxx xxxxxxxx
|
@ 404fd54 8m (redacted-ref-22) xxxx xx
```
##### Event ID: 22702, transaction ID: 19704 (message: reference-transaction)

1. `RefUpdateEvent { timestamp: 1663774877.718586, event_tx_id: EventTransactionId(19704), ref_name: "refs/heads/redacted-ref-22", old_oid: 0000000000000000000000000000000000000000, new_oid: 404fd540d4085267c242e4b55c650ee845404a10, message: None }`
```
:
O 3d53c87 1y xxxxxxxx xxx xxxxxx xxxxxx
|\
: o 06047b9 1y xxxxxxx xxxx xxxxxx
: |
: o 8e63ce3 1y xxxxxx xxxxx
: |
: o 42308e5 1y (redacted-ref-0) xxxxxx xxxxxxxxxxx xxxxx xxx xxx
:
O cd8258f 1y xxx xxxxx xxxxx xxxxxx xx xxxxxx xxxxxx
|\
: o 5ff6852 1y (redacted-ref-1) xxxxxxxxxxxxxxxx xxxxxxx xxxxx
:
O f014bb6 329d xxxxxxx xxxxxx xxxxxx
|\
: o bfb6357 321d (redacted-ref-2) xxxxxxx xxxx
:
O a6bdb3a 317d xxxxxxx xx xxxxxxxxxxx xxxxxx
|\
: o 0683431 314d (redacted-ref-3) xxxxxxx xxxxxxx xxxx xxxxxx
:
O 39f91b7 142d xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx xxx x xxxxx xxxxxxxxx xxxxxx
|\
| o c8bf7b2 133d (redacted-ref-4) xxxxxxxx xxxxxxx
|\
: o 9672214 126d xxxxxxx xxxxxxxxxx xxxxxx
:
O f9b1bf0 106d xxxxxx xxxxxxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxxxx xxxxxx
|\
: o 6ab32e2 105d xxxxxxx xxxx xxx xxxxxxxxxxx xxxxxxxx
:
O 10c355f 89d xxx xxxxxx xxxx xxxxxxxx xxxxxxx xx xxxx xxxx xxxxxx
|\
| o bf77b8c 89d xxxxxxx xxxxx xxxxxxxxxxx
| |
| o 9529dc3 89d (redacted-ref-5) xxxxx xxxxxxxxxx
|\
: o f931c9a 89d (redacted-ref-6) xxxxxxx xxxxxxxxxx xxxxxx
:
O 3419b74 76d xxx x xxxxxx xxxx xxxxxxxx xxxxxx
|\
: o 0f247a7 75d xxxxxx xxxxxxxxxxxxxxxx
: |
: o afba845 75d xxxxxxxxxx xxxxxxxx
: |
: o 81a6d9b 75d xxxxxxx xxxxxxxx xxxxx
: |
: o b3504a6 75d (redacted-ref-7) xxxx xx xxxxxx xxxx
:
O b639e42 64d xxx xxxxxxxxxxx xxxxxx
|\
: o 92a2cdc 64d xxxx xxxxx xxxx xxxxxxxxxx xxxx xxxxxx
: |
: o 3632e8d 64d xxx x xxxxxxx
: |
: o 5895e4c 14d (redacted-ref-8) xxxxxx xxxxx xx xx
:
O 560a7a1 4h xxxxx xxxxxxxxx xxxxxx xxxx xxxx xxxx xxxxxxxx xxxxxx
|\
| o 9916d85 4h (redacted-ref-9) xxxxxxx xxxxx xx xxxx xx xxxxxx
|\
| o 05e2a95 4h xxxx xx xxxxxxx xxxxxxxxxxx xxx xxxxx xxxxxxx
|\
| o 1b4ce7f 4h xxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxx
| |
| o ee0b97f 4h xxxxx xxxxxx
| |
| o d30d01a 4h (redacted-ref-10) xxx
|\
| o 1f810a2 4h (redacted-ref-11) xxxxxx xxx xxxxxxxxxx
| |
| o ad7f85a 4h xxxxxxxxxxxxxxx xx xxxxxxxxxx
|\
| o 507cab1 4h xxx xxxxx xxxxxxxxxxx
| |
| o 59eb137 4h xxx xxxxx xxxxxxx
| |
| o bd53f94 4h (redacted-ref-12) xxx xxxxxxxx xxxxx
|\
| o 86362e9 4h (redacted-ref-13) xxxxxxx xxxxxx xx xxxxxxxxxxxxxxxx
|\
| o 8f8ed0a 4h xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx
| |
| o ea87d33 3h (redacted-ref-14) xxxxxxx xxxxxxxxxxxxx
|\
| o cf83144 4h xxxxxxxxxxxxxx xx xxxxxx xxx xxxxxx xxxxx
|\
| o d5f3eca 4h (redacted-ref-15) xxxx xxxxxxxx xxxxxxx
|\
| o f0ebe29 4h xxxxxx xxxxx
| |
| o ea5cc71 4h (redacted-ref-16) xxx xxxxxxxxxxxxxxxxxxxxxxx
|
O 6773798 3h xxxxxx xxxxxx xxxx xxxx xxxxxxxxxx xxxxx xxxxxx
|\
| o 6ee3910 2h (redacted-ref-17) xxxxx xxxx xxxxxxxxx
|
O 9195c6a 3h xxxxxxx xxxxxxx xxxxxxxx xxxxxx xxx xxxxxxxxx xxxxxx
|\
| o 0f325c7 2h xxxxxxx xxxxx xxxxxxxx xxxxxxx
| |
| o 185ee46 2h xxxxxxxxxxxxxxx xxxx xxxxx xxxx xxxxxxxxxxxxxx xxxxx
| |
| o bce398b 2h xxxxxxx xxxxxxxx xxxxxxx
| |
| o 397f28a 2h xxx
| |
| o 19b8f0a 2h (redacted-ref-18) xxxxxxx xx xxx xxxxxx xxxxx
|
O da757c2 1h (redacted-ref-19, remote origin/main) xxxxxxx xxxx xxx xxxxxxx xxxxxx xxxxx xxxxxx
|
o 3104728 1h (redacted-ref-20) x xxx xxxxxxx xxxxxxx xxxxxxx xxxxxx xxxxx
|
o 9841c5c 1h (redacted-ref-21) xxxxxx xxxxxxxx
|
@ 404fd54 8m (redacted-ref-22) xxxx xx
```
##### Event ID: 22701, transaction ID: 19703 (message: post-commit)

1. `CommitEvent { timestamp: 1663774836.0, event_tx_id: EventTransactionId(19703), commit_oid: NonZeroOid(404fd540d4085267c242e4b55c650ee845404a10) }`
```
:
O 3d53c87 1y xxxxxxxx xxx xxxxxx xxxxxx
|\
: o 06047b9 1y xxxxxxx xxxx xxxxxx
: |
: o 8e63ce3 1y xxxxxx xxxxx
: |
: o 42308e5 1y (redacted-ref-0) xxxxxx xxxxxxxxxxx xxxxx xxx xxx
:
O cd8258f 1y xxx xxxxx xxxxx xxxxxx xx xxxxxx xxxxxx
|\
: o 5ff6852 1y (redacted-ref-1) xxxxxxxxxxxxxxxx xxxxxxx xxxxx
:
O f014bb6 329d xxxxxxx xxxxxx xxxxxx
|\
: o bfb6357 321d (redacted-ref-2) xxxxxxx xxxx
:
O a6bdb3a 317d xxxxxxx xx xxxxxxxxxxx xxxxxx
|\
: o 0683431 314d (redacted-ref-3) xxxxxxx xxxxxxx xxxx xxxxxx
:
O 39f91b7 142d xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx xxx x xxxxx xxxxxxxxx xxxxxx
|\
| o c8bf7b2 133d (redacted-ref-4) xxxxxxxx xxxxxxx
|\
: o 9672214 126d xxxxxxx xxxxxxxxxx xxxxxx
:
O f9b1bf0 106d xxxxxx xxxxxxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxxxx xxxxxx
|\
: o 6ab32e2 105d xxxxxxx xxxx xxx xxxxxxxxxxx xxxxxxxx
:
O 10c355f 89d xxx xxxxxx xxxx xxxxxxxx xxxxxxx xx xxxx xxxx xxxxxx
|\
| o bf77b8c 89d xxxxxxx xxxxx xxxxxxxxxxx
| |
| o 9529dc3 89d (redacted-ref-5) xxxxx xxxxxxxxxx
|\
: o f931c9a 89d (redacted-ref-6) xxxxxxx xxxxxxxxxx xxxxxx
:
O 3419b74 76d xxx x xxxxxx xxxx xxxxxxxx xxxxxx
|\
: o 0f247a7 75d xxxxxx xxxxxxxxxxxxxxxx
: |
: o afba845 75d xxxxxxxxxx xxxxxxxx
: |
: o 81a6d9b 75d xxxxxxx xxxxxxxx xxxxx
: |
: o b3504a6 75d (redacted-ref-7) xxxx xx xxxxxx xxxx
:
O b639e42 64d xxx xxxxxxxxxxx xxxxxx
|\
: o 92a2cdc 64d xxxx xxxxx xxxx xxxxxxxxxx xxxx xxxxxx
: |
: o 3632e8d 64d xxx x xxxxxxx
: |
: o 5895e4c 14d (redacted-ref-8) xxxxxx xxxxx xx xx
:
O 560a7a1 4h xxxxx xxxxxxxxx xxxxxx xxxx xxxx xxxx xxxxxxxx xxxxxx
|\
| o 9916d85 4h (redacted-ref-9) xxxxxxx xxxxx xx xxxx xx xxxxxx
|\
| o 05e2a95 4h xxxx xx xxxxxxx xxxxxxxxxxx xxx xxxxx xxxxxxx
|\
| o 1b4ce7f 4h xxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxx
| |
| o ee0b97f 4h xxxxx xxxxxx
| |
| o d30d01a 4h (redacted-ref-10) xxx
|\
| o 1f810a2 4h (redacted-ref-11) xxxxxx xxx xxxxxxxxxx
| |
| o ad7f85a 4h xxxxxxxxxxxxxxx xx xxxxxxxxxx
|\
| o 507cab1 4h xxx xxxxx xxxxxxxxxxx
| |
| o 59eb137 4h xxx xxxxx xxxxxxx
| |
| o bd53f94 4h (redacted-ref-12) xxx xxxxxxxx xxxxx
|\
| o 86362e9 4h (redacted-ref-13) xxxxxxx xxxxxx xx xxxxxxxxxxxxxxxx
|\
| o 8f8ed0a 4h xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx
| |
| o ea87d33 3h (redacted-ref-14) xxxxxxx xxxxxxxxxxxxx
|\
| o cf83144 4h xxxxxxxxxxxxxx xx xxxxxx xxx xxxxxx xxxxx
|\
| o d5f3eca 4h (redacted-ref-15) xxxx xxxxxxxx xxxxxxx
|\
| o f0ebe29 4h xxxxxx xxxxx
| |
| o ea5cc71 4h (redacted-ref-16) xxx xxxxxxxxxxxxxxxxxxxxxxx
|
O 6773798 3h xxxxxx xxxxxx xxxx xxxx xxxxxxxxxx xxxxx xxxxxx
|\
| o 6ee3910 2h (redacted-ref-17) xxxxx xxxx xxxxxxxxx
|
O 9195c6a 3h xxxxxxx xxxxxxx xxxxxxxx xxxxxx xxx xxxxxxxxx xxxxxx
|\
| o 0f325c7 2h xxxxxxx xxxxx xxxxxxxx xxxxxxx
| |
| o 185ee46 2h xxxxxxxxxxxxxxx xxxx xxxxx xxxx xxxxxxxxxxxxxx xxxxx
| |
| o bce398b 2h xxxxxxx xxxxxxxx xxxxxxx
| |
| o 397f28a 2h xxx
| |
| o 19b8f0a 2h (redacted-ref-18) xxxxxxx xx xxx xxxxxx xxxxx
|
O da757c2 1h (redacted-ref-19, remote origin/main) xxxxxxx xxxx xxx xxxxxxx xxxxxx xxxxx xxxxxx
|
o 3104728 1h (redacted-ref-20) x xxx xxxxxxx xxxxxxx xxxxxxx xxxxxx xxxxx
|
o 9841c5c 1h (redacted-ref-21) xxxxxx xxxxxxxx
|
@ 404fd54 8m (redacted-ref-22) xxxx xx
```
##### Event ID: 22700, transaction ID: 19702 (message: reference-transaction)

1. `RefUpdateEvent { timestamp: 1663774836.846817, event_tx_id: EventTransactionId(19702), ref_name: "HEAD", old_oid: 9841c5ce5de461959a5134ee099bc9632baaac1e, new_oid: 404fd540d4085267c242e4b55c650ee845404a10, message: None }`
```
:
O 3d53c87 1y xxxxxxxx xxx xxxxxx xxxxxx
|\
: o 06047b9 1y xxxxxxx xxxx xxxxxx
: |
: o 8e63ce3 1y xxxxxx xxxxx
: |
: o 42308e5 1y (redacted-ref-0) xxxxxx xxxxxxxxxxx xxxxx xxx xxx
:
O cd8258f 1y xxx xxxxx xxxxx xxxxxx xx xxxxxx xxxxxx
|\
: o 5ff6852 1y (redacted-ref-1) xxxxxxxxxxxxxxxx xxxxxxx xxxxx
:
O f014bb6 329d xxxxxxx xxxxxx xxxxxx
|\
: o bfb6357 321d (redacted-ref-2) xxxxxxx xxxx
:
O a6bdb3a 317d xxxxxxx xx xxxxxxxxxxx xxxxxx
|\
: o 0683431 314d (redacted-ref-3) xxxxxxx xxxxxxx xxxx xxxxxx
:
O 39f91b7 142d xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx xxx x xxxxx xxxxxxxxx xxxxxx
|\
| o c8bf7b2 133d (redacted-ref-4) xxxxxxxx xxxxxxx
|\
: o 9672214 126d xxxxxxx xxxxxxxxxx xxxxxx
:
O f9b1bf0 106d xxxxxx xxxxxxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxxxx xxxxxx
|\
: o 6ab32e2 105d xxxxxxx xxxx xxx xxxxxxxxxxx xxxxxxxx
:
O 10c355f 89d xxx xxxxxx xxxx xxxxxxxx xxxxxxx xx xxxx xxxx xxxxxx
|\
| o bf77b8c 89d xxxxxxx xxxxx xxxxxxxxxxx
| |
| o 9529dc3 89d (redacted-ref-5) xxxxx xxxxxxxxxx
|\
: o f931c9a 89d (redacted-ref-6) xxxxxxx xxxxxxxxxx xxxxxx
:
O 3419b74 76d xxx x xxxxxx xxxx xxxxxxxx xxxxxx
|\
: o 0f247a7 75d xxxxxx xxxxxxxxxxxxxxxx
: |
: o afba845 75d xxxxxxxxxx xxxxxxxx
: |
: o 81a6d9b 75d xxxxxxx xxxxxxxx xxxxx
: |
: o b3504a6 75d (redacted-ref-7) xxxx xx xxxxxx xxxx
:
O b639e42 64d xxx xxxxxxxxxxx xxxxxx
|\
: o 92a2cdc 64d xxxx xxxxx xxxx xxxxxxxxxx xxxx xxxxxx
: |
: o 3632e8d 64d xxx x xxxxxxx
: |
: o 5895e4c 14d (redacted-ref-8) xxxxxx xxxxx xx xx
:
O 560a7a1 4h xxxxx xxxxxxxxx xxxxxx xxxx xxxx xxxx xxxxxxxx xxxxxx
|\
| o 9916d85 4h (redacted-ref-9) xxxxxxx xxxxx xx xxxx xx xxxxxx
|\
| o 05e2a95 4h xxxx xx xxxxxxx xxxxxxxxxxx xxx xxxxx xxxxxxx
|\
| o 1b4ce7f 4h xxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxx
| |
| o ee0b97f 4h xxxxx xxxxxx
| |
| o d30d01a 4h (redacted-ref-10) xxx
|\
| o 1f810a2 4h (redacted-ref-11) xxxxxx xxx xxxxxxxxxx
| |
| o ad7f85a 4h xxxxxxxxxxxxxxx xx xxxxxxxxxx
|\
| o 507cab1 4h xxx xxxxx xxxxxxxxxxx
| |
| o 59eb137 4h xxx xxxxx xxxxxxx
| |
| o bd53f94 4h (redacted-ref-12) xxx xxxxxxxx xxxxx
|\
| o 86362e9 4h (redacted-ref-13) xxxxxxx xxxxxx xx xxxxxxxxxxxxxxxx
|\
| o 8f8ed0a 4h xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx
| |
| o ea87d33 3h (redacted-ref-14) xxxxxxx xxxxxxxxxxxxx
|\
| o cf83144 4h xxxxxxxxxxxxxx xx xxxxxx xxx xxxxxx xxxxx
|\
| o d5f3eca 4h (redacted-ref-15) xxxx xxxxxxxx xxxxxxx
|\
| o f0ebe29 4h xxxxxx xxxxx
| |
| o ea5cc71 4h (redacted-ref-16) xxx xxxxxxxxxxxxxxxxxxxxxxx
|
O 6773798 3h xxxxxx xxxxxx xxxx xxxx xxxxxxxxxx xxxxx xxxxxx
|\
| o 6ee3910 2h (redacted-ref-17) xxxxx xxxx xxxxxxxxx
|
O 9195c6a 3h xxxxxxx xxxxxxx xxxxxxxx xxxxxx xxx xxxxxxxxx xxxxxx
|\
| o 0f325c7 2h xxxxxxx xxxxx xxxxxxxx xxxxxxx
| |
| o 185ee46 2h xxxxxxxxxxxxxxx xxxx xxxxx xxxx xxxxxxxxxxxxxx xxxxx
| |
| o bce398b 2h xxxxxxx xxxxxxxx xxxxxxx
| |
| o 397f28a 2h xxx
| |
| o 19b8f0a 2h (redacted-ref-18) xxxxxxx xx xxx xxxxxx xxxxx
|
O da757c2 1h (redacted-ref-19, remote origin/main) xxxxxxx xxxx xxx xxxxxxx xxxxxx xxxxx xxxxxx
|
o 3104728 1h (redacted-ref-20) x xxx xxxxxxx xxxxxxx xxxxxxx xxxxxx xxxxx
|
o 9841c5c 1h (redacted-ref-21) xxxxxx xxxxxxxx
|
@ 404fd54 8m (redacted-ref-22) xxxx xx
```
##### Event ID: 22699, transaction ID: 19701 (message: hook-post-checkout)

1. `RefUpdateEvent { timestamp: 1663774832.338984, event_tx_id: EventTransactionId(19701), ref_name: "HEAD", old_oid: 9841c5ce5de461959a5134ee099bc9632baaac1e, new_oid: 9841c5ce5de461959a5134ee099bc9632baaac1e, message: None }`
```
:
O 3d53c87 1y xxxxxxxx xxx xxxxxx xxxxxx
|\
: o 06047b9 1y xxxxxxx xxxx xxxxxx
: |
: o 8e63ce3 1y xxxxxx xxxxx
: |
: o 42308e5 1y (redacted-ref-0) xxxxxx xxxxxxxxxxx xxxxx xxx xxx
:
O cd8258f 1y xxx xxxxx xxxxx xxxxxx xx xxxxxx xxxxxx
|\
: o 5ff6852 1y (redacted-ref-1) xxxxxxxxxxxxxxxx xxxxxxx xxxxx
:
O f014bb6 329d xxxxxxx xxxxxx xxxxxx
|\
: o bfb6357 321d (redacted-ref-2) xxxxxxx xxxx
:
O a6bdb3a 317d xxxxxxx xx xxxxxxxxxxx xxxxxx
|\
: o 0683431 314d (redacted-ref-3) xxxxxxx xxxxxxx xxxx xxxxxx
:
O 39f91b7 142d xxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxx xxx x xxxxx xxxxxxxxx xxxxxx
|\
| o c8bf7b2 133d (redacted-ref-4) xxxxxxxx xxxxxxx
|\
: o 9672214 126d xxxxxxx xxxxxxxxxx xxxxxx
:
O f9b1bf0 106d xxxxxx xxxxxxxxxxxx xx xxxxxxxx xxxxxxxx xxxxxx xxxxxxxxxxxx xxxxxx
|\
: o 6ab32e2 105d xxxxxxx xxxx xxx xxxxxxxxxxx xxxxxxxx
:
O 10c355f 89d xxx xxxxxx xxxx xxxxxxxx xxxxxxx xx xxxx xxxx xxxxxx
|\
| o bf77b8c 89d xxxxxxx xxxxx xxxxxxxxxxx
| |
| o 9529dc3 89d (redacted-ref-5) xxxxx xxxxxxxxxx
|\
: o f931c9a 89d (redacted-ref-6) xxxxxxx xxxxxxxxxx xxxxxx
:
O 3419b74 76d xxx x xxxxxx xxxx xxxxxxxx xxxxxx
|\
: o 0f247a7 75d xxxxxx xxxxxxxxxxxxxxxx
: |
: o afba845 75d xxxxxxxxxx xxxxxxxx
: |
: o 81a6d9b 75d xxxxxxx xxxxxxxx xxxxx
: |
: o b3504a6 75d (redacted-ref-7) xxxx xx xxxxxx xxxx
:
O b639e42 64d xxx xxxxxxxxxxx xxxxxx
|\
: o 92a2cdc 64d xxxx xxxxx xxxx xxxxxxxxxx xxxx xxxxxx
: |
: o 3632e8d 64d xxx x xxxxxxx
: |
: o 5895e4c 14d (redacted-ref-8) xxxxxx xxxxx xx xx
:
O 560a7a1 4h xxxxx xxxxxxxxx xxxxxx xxxx xxxx xxxx xxxxxxxx xxxxxx
|\
| o 9916d85 4h (redacted-ref-9) xxxxxxx xxxxx xx xxxx xx xxxxxx
|\
| o 05e2a95 4h xxxx xx xxxxxxx xxxxxxxxxxx xxx xxxxx xxxxxxx
|\
| o 1b4ce7f 4h xxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxx
| |
| o ee0b97f 4h xxxxx xxxxxx
| |
| o d30d01a 4h (redacted-ref-10) xxx
|\
| o 1f810a2 4h (redacted-ref-11) xxxxxx xxx xxxxxxxxxx
| |
| o ad7f85a 4h xxxxxxxxxxxxxxx xx xxxxxxxxxx
|\
| o 507cab1 4h xxx xxxxx xxxxxxxxxxx
| |
| o 59eb137 4h xxx xxxxx xxxxxxx
| |
| o bd53f94 4h (redacted-ref-12) xxx xxxxxxxx xxxxx
|\
| o 86362e9 4h (redacted-ref-13) xxxxxxx xxxxxx xx xxxxxxxxxxxxxxxx
|\
| o 8f8ed0a 4h xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxx
| |
| o ea87d33 3h (redacted-ref-14) xxxxxxx xxxxxxxxxxxxx
|\
| o cf83144 4h xxxxxxxxxxxxxx xx xxxxxx xxx xxxxxx xxxxx
|\
| o d5f3eca 4h (redacted-ref-15) xxxx xxxxxxxx xxxxxxx
|\
| o f0ebe29 4h xxxxxx xxxxx
| |
| o ea5cc71 4h (redacted-ref-16) xxx xxxxxxxxxxxxxxxxxxxxxxx
|
O 6773798 3h xxxxxx xxxxxx xxxx xxxx xxxxxxxxxx xxxxx xxxxxx
|\
| o 6ee3910 2h (redacted-ref-17) xxxxx xxxx xxxxxxxxx
|
O 9195c6a 3h xxxxxxx xxxxxxx xxxxxxxx xxxxxx xxx xxxxxxxxx xxxxxx
|\
| o 0f325c7 2h xxxxxxx xxxxx xxxxxxxx xxxxxxx
| |
| o 185ee46 2h xxxxxxxxxxxxxxx xxxx xxxxx xxxx xxxxxxxxxxxxxx xxxxx
| |
| o bce398b 2h xxxxxxx xxxxxxxx xxxxxxx
| |
| o 397f28a 2h xxx
| |
| o 19b8f0a 2h (redacted-ref-18) xxxxxxx xx xxx xxxxxx xxxxx
|
O da757c2 1h (redacted-ref-19, remote origin/main) xxxxxxx xxxx xxx xxxxxxx xxxxxx xxxxx xxxxxx
|
o 3104728 1h (redacted-ref-20) x xxx xxxxxxx xxxxxxx xxxxxxx xxxxxx xxxxx
|
o 9841c5c 1h (redacted-ref-21) xxxxxx xxxxxxxx
|
@ 404fd54 8m (redacted-ref-22) xxxx xx
```

</details>

### Version of `git-branchless`

git-branchless 0.4.0

### Version of `git`

git version 2.33.1


Discussion:
Oops, thanks for catching. I think @h4l ran into this as well, as I recall them piping `git query` into `tac` (which I thought was unusual at the time, but I didn't look into it further). The fix should be as simple as inserting a call to `.rev()` somewhere in `query.rs`, if you want to take a stab at it.
Yep, exactly. I guess either order is fine as long as it's consistent.
Hmm I started looking into it but was a bit confused by this line:

https://github.com/arxanas/git-branchless/blob/3c829f6b8b49f80a7aebf4348cf1226bdef03c35/git-branchless/src/commands/query.rs#L54

Any idea what that's supposed to be doing?  The name indicates to me that it's not preserving order, but then looking at the implementation it looks like it does, but it seems to return something that's not used.  But I don't know any Rust, so I can't say for sure 😅
I had never touched Rust until I started ~~hac~~tinkering on this project either. Be careful: it's addicting! What you're seeing there is that there is that Rust will return the last value from a scope or block, so the value of `commit_set_to_vec_unsorted(...)` is being returned from the block and assigned to `commit_oids` on line 48.

Also, I guess you're correct that that is not explicit about preserving order, but I supposed that in practice it does. Regardless, note that the set *is* being sorted on 52 (and line 74, for the not-branches option). I think that, as @arxanas noted, you can just change lines 65 and 77 to `ref_names.into_iter().rev()` and `commit_oids.into_iter().rev()` to fix this. (I think.) I recall that Rust will implicitly call `into_iter()` for a `for` loop, which is why that's not needed in the current implementation, and why you might need to add it explicitly. Or who knows: maybe Rust will figure it out for you ... I've been repeatedly amazed by what it can infer. 😄 
Cool thanks—sounds easy enough. I can't say I'm in love with sorting it, then passing it to something that explicitly says it makes no guarantee about preserving order 🤔

Should we rename that function, or maybe make a new one?
@pokey The function preserves *order*, it just doesn't sort the input set. This is a bad name, and it's only called this because a previous iteration of the function *did* sort the input set. I would certainly support renaming the function to something less confusing (maybe `commit_set_to_vec_preserve_order`? or just `commit_set_to_vec` and write in the doc-comment that it preserves order?).

There is (now) also a `sorted_commit_set` function which *does* sort the input set, but it also looks up the corresponding `Commit` objects from the `Repo`, which is a lot of disk accesses that we don't need to do in this case, because the DAG is able to topologically sort a given set without referring to the object database.
To me the term "set" itself implies an unordered collection.  So I guess the crux of the problem for me is that the `sort` function returns a set.  Could we not change that function to return a vector?

If that's going to be too painful, maybe we could at least have a function that wraps the topological sort + convert to vector operation. 

It sounds like you already have that function, but it is expensive.  Is there a way we could create a version of that function that is equivalent computationally to what we're doing here?  Maybe add the function to the dag object?  Or have a version that takes a dag arg?

But basically the notion of having a function that sorts something and returns a set is the confusing part for me I think
@pokey A set is often unordered, but it doesn't have to be; see e.g. https://mathworld.wolfram.com/TotallyOrderedSet.html. I think the real criterion of relevance here is that elements are unique, which is still upheld in the places that we use the commit sets.

In any event, the "commit set" terminology comes from the upstream DAG library, so I think it would be confusing to change how we use it just for this project.



Patch:
diff --git a/git-branchless-lib/src/core/dag.rs b/git-branchless-lib/src/core/dag.rs
index bbfafbcb8..432ab840b 100644
--- a/git-branchless-lib/src/core/dag.rs
+++ b/git-branchless-lib/src/core/dag.rs
@@ -69,9 +69,9 @@ impl FromIterator<NonZeroOid> for CommitSet {
     }
 }
 
-/// Eagerly convert a `CommitSet` into a `Vec<NonZeroOid>` by iterating over it.
+/// Eagerly convert a `CommitSet` into a `Vec<NonZeroOid>` by iterating over it, preserving order.
 #[instrument]
-pub fn commit_set_to_vec_unsorted(commit_set: &CommitSet) -> eyre::Result<Vec<NonZeroOid>> {
+pub fn commit_set_to_vec(commit_set: &CommitSet) -> eyre::Result<Vec<NonZeroOid>> {
     let mut result = Vec::new();
     for vertex in commit_set.iter().wrap_err("Iterating commit set")? {
         let vertex = vertex.wrap_err("Evaluating vertex")?;
@@ -313,7 +313,7 @@ impl Dag {
     #[instrument]
     pub fn get_only_parent_oid(&self, oid: NonZeroOid) -> eyre::Result<NonZeroOid> {
         let parents: CommitSet = self.inner.parents(CommitSet::from(oid))?;
-        match commit_set_to_vec_unsorted(&parents)?[..] {
+        match commit_set_to_vec(&parents)?[..] {
             [oid] => Ok(oid),
             [] => Err(eyre::eyre!("Commit {} has no parents.", oid)),
             _ => Err(eyre::eyre!("Commit {} has more than 1 parents.", oid)),
@@ -436,7 +436,7 @@ impl Dag {
 
         // FIXME: O(n^2) algorithm (
         // FMI see https://github.com/arxanas/git-branchless/pull/450#issuecomment-1188391763
-        for commit in commit_set_to_vec_unsorted(commit_set)? {
+        for commit in commit_set_to_vec(commit_set)? {
             if commits_to_connect.is_empty()? {
                 break;
             }
@@ -492,7 +492,7 @@ pub fn sorted_commit_set<'repo>(
     dag: &Dag,
     commit_set: &CommitSet,
 ) -> eyre::Result<Vec<Commit<'repo>>> {
-    let commit_oids = commit_set_to_vec_unsorted(commit_set)?;
+    let commit_oids = commit_set_to_vec(commit_set)?;
     let mut commits: Vec<Commit> = {
         let mut commits = Vec::new();
         for commit_oid in commit_oids {
diff --git a/git-branchless-lib/src/core/rewrite/plan.rs b/git-branchless-lib/src/core/rewrite/plan.rs
index b0fc1560b..a52dcfae7 100644
--- a/git-branchless-lib/src/core/rewrite/plan.rs
+++ b/git-branchless-lib/src/core/rewrite/plan.rs
@@ -11,7 +11,7 @@ use itertools::Itertools;
 use rayon::{prelude::*, ThreadPool};
 use tracing::{instrument, warn};
 
-use crate::core::dag::{commit_set_to_vec_unsorted, union_all, CommitSet, Dag};
+use crate::core::dag::{commit_set_to_vec, union_all, CommitSet, Dag};
 use crate::core::effects::{Effects, OperationType};
 use crate::core::formatting::{printable_styled_string, Pluralize};
 use crate::core::rewrite::{RepoPool, RepoResource};
@@ -277,7 +277,7 @@ impl<'a> ConstraintGraph<'a> {
                         .difference(&self.dag.obsolete_commits)
                         .difference(&commits_to_move);
 
-                    for child_oid in commit_set_to_vec_unsorted(&source_children)? {
+                    for child_oid in commit_set_to_vec(&source_children)? {
                         self.inner.entry(parent_oid).or_default().insert(child_oid);
                     }
                 }
@@ -306,7 +306,7 @@ impl<'a> ConstraintGraph<'a> {
             .query()
             .children(CommitSet::from(current_oid))?
             .intersection(visible_commits);
-        let children_oids = commit_set_to_vec_unsorted(&children_oids)?;
+        let children_oids = commit_set_to_vec(&children_oids)?;
         for child_oid in children_oids {
             if self.commits_to_move().contains(&child_oid) {
                 continue;
@@ -644,7 +644,7 @@ Retry with -f/--force-rewrite to proceed anyways.",
 BUG: The following commits were planned to be moved but not verified:
 {:?}
 This is a bug. Please report it.",
-                    commit_set_to_vec_unsorted(illegal_commits_to_move)
+                    commit_set_to_vec(illegal_commits_to_move)
                 )?;
             }
         }
@@ -1178,7 +1178,7 @@ impl<'a> RebasePlanBuilder<'a> {
         touched_commit_oids: Vec<NonZeroOid>,
     ) -> eyre::Result<Vec<Commit<'a>>> {
         let (effects, _progress) = effects.start_operation(OperationType::FilterCommits);
-        let path = commit_set_to_vec_unsorted(&path)?;
+        let path = commit_set_to_vec(&path)?;
 
         let touched_commits: Vec<Commit> = touched_commit_oids
             .into_iter()
diff --git a/git-branchless/src/commands/move.rs b/git-branchless/src/commands/move.rs
index 75361d4d6..4c08062cb 100644
--- a/git-branchless/src/commands/move.rs
+++ b/git-branchless/src/commands/move.rs
@@ -20,7 +20,7 @@ use crate::revset::resolve_commits;
 use lib::core::config::{
     get_hint_enabled, get_restack_preserve_timestamps, print_hint_suppression_notice, Hint,
 };
-use lib::core::dag::{commit_set_to_vec_unsorted, sorted_commit_set, union_all, CommitSet, Dag};
+use lib::core::dag::{commit_set_to_vec, sorted_commit_set, union_all, CommitSet, Dag};
 use lib::core::effects::Effects;
 use lib::core::eventlog::{EventLogDb, EventReplayer};
 use lib::core::rewrite::{
@@ -121,8 +121,7 @@ pub fn r#move(
 
             for component in dag.get_connected_components(&exact_oids)?.into_iter() {
                 let component_roots = dag.query().roots(component.clone())?;
-                let component_root = match commit_set_to_vec_unsorted(&component_roots)?.as_slice()
-                {
+                let component_root = match commit_set_to_vec(&component_roots)?.as_slice() {
                     [only_commit_oid] => *only_commit_oid,
                     _ => {
                         writeln!(
@@ -160,7 +159,7 @@ pub fn r#move(
     };
 
     let dest_oid: NonZeroOid = match resolve_commits(effects, &repo, &mut dag, vec![dest.clone()]) {
-        Ok(commit_sets) => match commit_set_to_vec_unsorted(&commit_sets[0])?.as_slice() {
+        Ok(commit_sets) => match commit_set_to_vec(&commit_sets[0])?.as_slice() {
             [only_commit_oid] => *only_commit_oid,
             other => {
                 let Revset(expr) = dest;
@@ -192,7 +191,7 @@ pub fn r#move(
     };
     let base_oids = {
         let mut result = Vec::new();
-        for base_oid in commit_set_to_vec_unsorted(&base_oids)? {
+        for base_oid in commit_set_to_vec(&base_oids)? {
             let merge_base_oid = dag.get_one_merge_base_oid(effects, &repo, base_oid, dest_oid)?;
             let base_commit_oid = resolve_base_commit(&dag, merge_base_oid, base_oid)?;
             result.push(CommitSet::from(base_commit_oid))
@@ -274,7 +273,7 @@ pub fn r#move(
         let mut builder = RebasePlanBuilder::new(&dag, permissions);
 
         let source_roots = dag.query().roots(source_oids.clone())?;
-        for source_root in commit_set_to_vec_unsorted(&source_roots)? {
+        for source_root in commit_set_to_vec(&source_roots)? {
             builder.move_subtree(source_root, vec![dest_oid])?;
         }
 
@@ -366,7 +365,7 @@ pub fn r#move(
                 .difference(component)
                 .difference(&dag.obsolete_commits);
 
-            for component_child in commit_set_to_vec_unsorted(&component_children)? {
+            for component_child in commit_set_to_vec(&component_children)? {
                 // If the range being extracted has any child commits, then we
                 // need to move each of those subtrees up to the parent commit
                 // of the range. If, however, we're inserting the range and the
@@ -421,7 +420,7 @@ pub fn r#move(
                     .query()
                     .heads(dag.query().descendants(source_oids.clone())?)?
                     .union(&exact_head);
-                match commit_set_to_vec_unsorted(&source_heads)?.as_slice() {
+                match commit_set_to_vec(&source_heads)?.as_slice() {
                     [oid] => *oid,
                     _ => {
                         writeln!(
@@ -446,7 +445,7 @@ pub fn r#move(
                 .difference(&exact_oids)
                 .difference(&dag.obsolete_commits);
 
-            for dest_child in commit_set_to_vec_unsorted(&dest_children)? {
+            for dest_child in commit_set_to_vec(&dest_children)? {
                 builder.move_subtree(dest_child, vec![source_head])?;
             }
         }
diff --git a/git-branchless/src/commands/query.rs b/git-branchless/src/commands/query.rs
index 172455958..25503f390 100644
--- a/git-branchless/src/commands/query.rs
+++ b/git-branchless/src/commands/query.rs
@@ -2,7 +2,7 @@ use std::fmt::Write;
 
 use eden_dag::DagAlgorithm;
 use itertools::Itertools;
-use lib::core::dag::{commit_set_to_vec_unsorted, Dag};
+use lib::core::dag::{commit_set_to_vec, Dag};
 use lib::core::effects::{Effects, OperationType};
 use lib::core::eventlog::{EventLogDb, EventReplayer};
 use lib::core::formatting::printable_styled_string;
@@ -49,12 +49,13 @@ pub fn query(
             let (effects, _progress) = effects.start_operation(OperationType::SortCommits);
             let _effects = effects;
 
-            let commit_set = dag.query().sort(&commit_set)?;
             let commit_set = commit_set.intersection(&dag.branch_commits);
-            commit_set_to_vec_unsorted(&commit_set)?
+            let commit_set = dag.query().sort(&commit_set)?;
+            commit_set_to_vec(&commit_set)?
         };
         let ref_names = commit_oids
             .into_iter()
+            .rev()
             .flat_map(
                 |oid| match references_snapshot.branch_oid_to_names.get(&oid) {
                     Some(branch_names) => branch_names.iter().sorted().collect_vec(),
@@ -72,9 +73,9 @@ pub fn query(
             let _effects = effects;
 
             let commit_set = dag.query().sort(&commit_set)?;
-            commit_set_to_vec_unsorted(&commit_set)?
+            commit_set_to_vec(&commit_set)?
         };
-        for commit_oid in commit_oids {
+        for commit_oid in commit_oids.into_iter().rev() {
             if raw {
                 writeln!(effects.get_output_stream(), "{}", commit_oid)?;
             } else {
diff --git a/git-branchless/src/commands/restack.rs b/git-branchless/src/commands/restack.rs
index 306d740cc..733c0a396 100644
--- a/git-branchless/src/commands/restack.rs
+++ b/git-branchless/src/commands/restack.rs
@@ -70,7 +70,7 @@ use crate::commands::smartlog::smartlog;
 use crate::opts::{MoveOptions, Revset};
 use crate::revset::resolve_commits;
 use lib::core::config::get_restack_preserve_timestamps;
-use lib::core::dag::{commit_set_to_vec_unsorted, union_all, CommitSet, Dag};
+use lib::core::dag::{commit_set_to_vec, union_all, CommitSet, Dag};
 use lib::core::effects::Effects;
 use lib::core::eventlog::{EventCursor, EventLogDb, EventReplayer};
 use lib::core::rewrite::{
@@ -102,7 +102,7 @@ fn restack_commits(
     };
     // Don't use `sort_commit_set` since the set of obsolete commits may be very
     // large and we'll be throwing away most of them.
-    let commits = commit_set_to_vec_unsorted(&commit_set)?;
+    let commits = commit_set_to_vec(&commit_set)?;
 
     let public_commits = dag.query_public_commits()?;
     let active_heads = dag.query_active_heads(
@@ -308,7 +308,7 @@ pub fn restack(
         None
     } else {
         Some(
-            commit_set_to_vec_unsorted(&union_all(&commit_sets))?
+            commit_set_to_vec(&union_all(&commit_sets))?
                 .into_iter()
                 .collect(),
         )
diff --git a/git-branchless/src/commands/smartlog.rs b/git-branchless/src/commands/smartlog.rs
index 51b8dd2cd..f2ad8bb58 100644
--- a/git-branchless/src/commands/smartlog.rs
+++ b/git-branchless/src/commands/smartlog.rs
@@ -40,7 +40,7 @@ mod graph {
     use lib::core::gc::mark_commit_reachable;
     use tracing::instrument;
 
-    use lib::core::dag::{commit_set_to_vec_unsorted, CommitSet, Dag};
+    use lib::core::dag::{commit_set_to_vec, CommitSet, Dag};
     use lib::core::effects::{Effects, OperationType};
     use lib::core::eventlog::{EventCursor, EventReplayer};
     use lib::core::node_descriptors::NodeObject;
@@ -176,7 +176,7 @@ mod graph {
             let mut links = Vec::new();
             for child_oid in non_main_node_oids {
                 let parent_vertexes = dag.query().parents(CommitSet::from(*child_oid))?;
-                let parent_oids = commit_set_to_vec_unsorted(&parent_vertexes)?;
+                let parent_oids = commit_set_to_vec(&parent_vertexes)?;
                 for parent_oid in parent_oids {
                     if graph.contains_key(&parent_oid) {
                         links.push((*child_oid, parent_oid))
@@ -241,7 +241,7 @@ mod graph {
             };
 
             let active_heads = dag.query_active_heads(&public_commits, &observed_commits)?;
-            for oid in commit_set_to_vec_unsorted(&active_heads)? {
+            for oid in commit_set_to_vec(&active_heads)? {
                 mark_commit_reachable(repo, oid)?;
             }
 
diff --git a/git-branchless/src/commands/submit.rs b/git-branchless/src/commands/submit.rs
index 4c62e78e8..98659d4c2 100644
--- a/git-branchless/src/commands/submit.rs
+++ b/git-branchless/src/commands/submit.rs
@@ -2,7 +2,7 @@ use std::fmt::Write;
 use std::time::SystemTime;
 
 use itertools::{Either, Itertools};
-use lib::core::dag::{commit_set_to_vec_unsorted, Dag};
+use lib::core::dag::{commit_set_to_vec, Dag};
 use lib::core::effects::{Effects, OperationType};
 use lib::core::eventlog::{EventLogDb, EventReplayer};
 use lib::core::formatting::Pluralize;
@@ -43,7 +43,7 @@ pub fn submit(
         }
     };
 
-    let branches: Vec<Branch> = commit_set_to_vec_unsorted(&commit_set)?
+    let branches: Vec<Branch> = commit_set_to_vec(&commit_set)?
         .into_iter()
         .flat_map(|commit_oid| references_snapshot.branch_oid_to_names.get(&commit_oid))
         .flatten()
diff --git a/git-branchless/src/revset/eval.rs b/git-branchless/src/revset/eval.rs
index 776483616..921446f45 100644
--- a/git-branchless/src/revset/eval.rs
+++ b/git-branchless/src/revset/eval.rs
@@ -378,7 +378,7 @@ pub(super) fn eval_number_rhs(
 mod tests {
     use std::borrow::Cow;
 
-    use lib::core::dag::commit_set_to_vec_unsorted;
+    use lib::core::dag::commit_set_to_vec;
     use lib::core::effects::Effects;
     use lib::core::eventlog::{EventLogDb, EventReplayer};
     use lib::core::formatting::Glyphs;
@@ -396,7 +396,7 @@ mod tests {
         expr: &Expr,
     ) -> eyre::Result<Vec<Commit<'a>>> {
         let result = eval(effects, repo, dag, expr)?;
-        let mut commits: Vec<Commit> = commit_set_to_vec_unsorted(&result)?
+        let mut commits: Vec<Commit> = commit_set_to_vec(&result)?
             .into_iter()
             .map(|oid| repo.find_commit_or_fail(oid))
             .try_collect()?;


Test patch:
diff --git a/git-branchless/tests/command/test_query.rs b/git-branchless/tests/command/test_query.rs
index d13860071..3f10fb160 100644
--- a/git-branchless/tests/command/test_query.rs
+++ b/git-branchless/tests/command/test_query.rs
@@ -13,8 +13,8 @@ fn test_query() -> eyre::Result<()> {
         let (stdout, stderr) = git.run(&["query", ".^::"])?;
         insta::assert_snapshot!(stderr, @"");
         insta::assert_snapshot!(stdout, @r###"
-        70deb1e create test3.txt
         96d1c37 create test2.txt
+        70deb1e create test3.txt
         "###);
     }
 
@@ -22,8 +22,8 @@ fn test_query() -> eyre::Result<()> {
         let (stdout, stderr) = git.run(&["query", ".^::", "--raw"])?;
         insta::assert_snapshot!(stderr, @"");
         insta::assert_snapshot!(stdout, @r###"
-        70deb1e28791d8e7dd5a1f0c871a51b91282562f
         96d1c37a3d4363611c49f7e52186e189a04c531f
+        70deb1e28791d8e7dd5a1f0c871a51b91282562f
         "###);
     }
 
@@ -155,16 +155,16 @@ fn test_query_branches() -> eyre::Result<()> {
     {
         let (stdout, _stderr) = git.run(&["query", "-b", "::."])?;
         insta::assert_snapshot!(stdout, @r###"
-        master
         foo
+        master
         "###);
     }
 
     {
         let (stdout, _stderr) = git.run(&["query", "branches()"])?;
         insta::assert_snapshot!(stdout, @r###"
-        70deb1e create test3.txt
         62fc20d create test1.txt
+        70deb1e create test3.txt
         "###);
     }