From d3cadf18569afa3918be4bbc3f502cd70b650d59 Mon Sep 17 00:00:00 2001 From: Sam Saccone Date: Tue, 15 Nov 2022 14:59:39 -0800 Subject: [PATCH] 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 Reviewed-by: LaMont Jones --- git_command.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git_command.py b/git_command.py index 56e18e02..01b9ecb3 100644 --- a/git_command.py +++ b/git_command.py @@ -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: