Byron / gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Apache License 2.0
8.84k stars 301 forks source link

gitoxide is still less lenient than git when parsing signatures, in particular in tags #1542

Closed pierrechevalier83 closed 1 month ago

pierrechevalier83 commented 1 month ago

Current behavior 😯

In the wild, some tags exist that don't have a timestamp on the tagger line. For instance this one: https://kernel.googlesource.com/pub/scm/network/bridge/bridge-utils/+/refs/tags/ChangeLog

Expected behavior 🤔

gitoxide should be as lenient as git when parsing tags so it can be used on the exotic git objects that one can find. If the timestamp is garbage or missing, it should set it to zero instead of failing.

Git behavior

git is very lenient when parsing signatures: on any sort of malformed timestamp, it simply sets the timestamp to 0. See implementation here

Steps to reproduce 🕹

To observe that this behaviour exists in the wild:

> git clone https://kernel.googlesource.com/pub/scm/network/bridge/bridge-utils
Cloning into 'bridge-utils'...
remote: Counting objects: 16, done
remote: Total 712 (delta 487), reused 712 (delta 487)
Receiving objects: 100% (712/712), 142.50 KiB | 2.30 MiB/s, done.
Resolving deltas: 100% (487/487), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout
> cd bridge-utils
> git show-ref ChangeLog
e601dc1094107999de050b7104bf01ce865fe60f refs/tags/ChangeLog
> git cat-file -p e601dc1094107999de050b7104bf01ce865fe60f
object 4fcd840c4935e4c7a5ea3552710a0f26b9178c24
type commit
tag ChangeLog
tagger shemminger <shemminger>

To repro the behaviour with gitoxide

I will share a couple of new unit tests that show that gitoxide fails to parse.