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>
diff --git a/git_command.py b/git_command.py
index 56e18e0..01b9ecb 100644
--- a/git_command.py
+++ b/git_command.py
@@ -207,10 +207,12 @@
     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: