t6100: update for Git 2.31+ and hash algorithm sha256
commit6bbe5ad4dec4c77a9aa9a65e4ef62b149f3a291e
authorKyle J. McKay <mackyle@gmail.com>
Sat, 21 Aug 2021 18:21:45 +0000 (21 11:21 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Sat, 21 Aug 2021 18:21:45 +0000 (21 11:21 -0700)
treed9510a8ccbb15eb0a4a38c6b22af891b386a49a2
parent70a3b9e77c96b9dc137b38f5af19f40570092951
t6100: update for Git 2.31+ and hash algorithm sha256

The Git 2.31.0 release completely changed the way reflogs are
handled.  They now behave in a somewhat broken manner when
individual entries are dropped.

Now, when asking for log entry `n` as in HEAD@{n}, if n is greater
than 0, then what gets shown is not from entry `n`, it's from entry
`n-1` and is the value of the "old" hash from that entry.

However, that value will only be correct if every single
`git reflog delete` command that operates on that reflog supplies
the `--rewrite` option.  Since the code that changed the reflog
semantics does not make the `--rewrite` option always on, reflog
contents can no longer be trusted.

TopGit has always been very careful to always include the `--rewrite`
option with `git reflog delete`.

In addition, asking for a HEAD reflog entry when HEAD is a symbolic
ref and HEAD does not have any reflog entries but the ref it points
to does, magically shows the pointed-to-ref's reflog instead of a
"fatal: log for HEAD is empty" error.

While this is not necessarily a horrible thing to do, knowing that
the reflog for HEAD is empty and then seeing reflog entries appear
for HEAD out of thin air can be rather surprising.

The t6100 test checks for all kinds of reflog edge cases and unlikely
situations that TopGit itself should not actually cause if it's
operating correctly, but the `tg tag` command may encounter when
operating on reflog entries.

Those situations must be tested because they could be caused by
commands run outside of TopGit.

The change of reflog semantics starting with Git v2.31.0 wreaks
havoc on the persnickety tests of t6100.

Until t6100 receives a complete overhaul, adjust to the new and
broken reflog semantics by checking the Git version and modifying
or skipping some of the individual tests to compensate while marking
a few `test_tolerate_failure`.

In addition, together with all the changes made for the broken
reflog semantics, add support for the Git sha256 hash algorithm as
well.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
t/t6100-tag-reflog.sh