Do not set ALT object dirs when said path resolves to the same dir.

Due to symlink resolution git was treating this as two different directories even if the paths were the same. This mitigates the git core bug inside of repo (while the git core fix is being worked on).

Bug: b/255376186
Bug: https://crbug.com/gerrit/16247
Change-Id: I12458ee04c307be916851dddd36231997bc8839e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351836
Tested-by: Sam Saccone <samccone@google.com>
Reviewed-by: LaMont Jones <lamontjones@google.com>
This commit is contained in:
Sam Saccone 2022-11-15 14:59:39 -08:00
parent fa90f7a36f
commit d3cadf1856

View File

@ -207,10 +207,12 @@ class GitCommand(object):
if objdir:
# Set to the place we want to save the objects.
env['GIT_OBJECT_DIRECTORY'] = objdir
if gitdir:
alt_objects = os.path.join(gitdir, 'objects') if gitdir else None
if alt_objects and os.path.realpath(alt_objects) != os.path.realpath(objdir):
# Allow git to search the original place in case of local or unique refs
# that git will attempt to resolve even if we aren't fetching them.
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = gitdir + '/objects'
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects
command = [GIT]
if bare: