Do not look up commit again when it is passed to RelativeLinkFilter
## What does this MR do?
Use `context[:commit]` in RelativeLinkFilter instead of looking up commit using `context[:ref]`.
## Why was this MR needed?
Even though the commit object was already passed, unnecessary I/O is done to retrieve the commit object.
## What are the relevant issue numbers?
Fixes#20026
See merge request !5455
A lot of git operations were being repeated, for example, to build a url
you would ask if the path was a Tree, which would call a recursive routine
in Gitlab::Git::Tree#where, then ask if the path was a Blob, which would
call a recursive routine at Gitlab::Git::Blob#find, making reference to
the same git objects several times. Now we call Rugged::Tree#path, which
allows us to determine the type of the path in one pass.
Some other minor improvement added, like saving commonly used references
instead of calculating them each time.