Skip to content

Update blank revision checks to handle SHA256 repositories

Overview

In various places around the codebase, we check if a revision has a blank reference (i.e. zero object id) through one of the following ways:

This however works for SHA1-based repositories (in which a reference length is 40), but will not work with SHA256 repositories (for which references are 64 characters/digits long), therefore, we have to update these checks to work for the latter too.

See this thread for more information.

Proposal

Below is the list of steps proposed to resolve this issue.

  • Create a new blank sha constant under lib/gitlab/git.rb. For example: SHA256_BLANK_SHA = ('0' * 64).freeze.
  • Update all aforementioned checks around the codebase to also test against SHA256_BLANK_SHA in addition to BLANK_SHA.
Edited by Ahmed Hemdan