Skip to content

Branch: fix API use bug in User(Create|Delete)Branch

Change code added in [1] and [2] to use GetReference() instead of GetBranch(). This solves a bug that could theoretically occur, but is mainly a trivial API code cleanup.

The GetBranch() function can take refs/heads/master or heads/master or whatever to resolve "master", but the underlying updateReferenceWithHooks() we're calling will only accept a refs/heads/master.

Since we'd accept a request of "master" which we'd always normalize to "refs/heads/master" this shouldn't change anything in practice.

It does solve an obscure bug though. If you had both a refs/heads/master and a refs/heads/heads/master we'd get the old revision from the latter, but operate on the former.

Thus hooks would get an invalid old revision in such a case, and furthermore we would unexpectedly allow deletion of refs/heads/heads/master in the obscure edge case where we raced between GetReference() and s.updateReferenceWithHooks() while another process updated refs/heads/heads/master.

  1. c3b32722 (Initial go implementation of UserDeleteBranch, 2020-09-29)
  2. c1e3ccca (Initial go implementation of UserCreateBranch, 2020-09-30)

Merge request reports