summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-11-14 03:58:00 -0500
committerMike Frysinger <vapier@google.com>2022-01-06 04:08:05 +0000
commitc72bd8486a23e4c4ab94cab2706fc6dfac445cf1 (patch)
tree54bdf23d57c9905db24dc2d00ddae5cd2fb7fb73 /project.py
parentd53cb9549a0c57939b12c5c35a6b581aec2ca36f (diff)
downloadgit-repo-c72bd8486a23e4c4ab94cab2706fc6dfac445cf1.tar.gz
project: clean up now unused code
Now that we symlink worktree .git/ paths to .repo/projects/, we never set share_refs=True anywhere, which means all of this logic is dead code. Throw it all away. Do it as a separate commit to make the parent commit easier to review. Bug: https://crbug.com/gerrit/15273 Change-Id: If496d39029d3d3bd523ba24c603ce47a63ad9b51 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/326817 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jack Neus <jackneus@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py38
1 files changed, 4 insertions, 34 deletions
diff --git a/project.py b/project.py
index e0d645bb..a2b98d83 100644
--- a/project.py
+++ b/project.py
@@ -459,9 +459,6 @@ class Project(object):
459 # These objects can be shared between several working trees. 459 # These objects can be shared between several working trees.
460 shareable_files = ['description', 'info'] 460 shareable_files = ['description', 'info']
461 shareable_dirs = ['hooks', 'objects', 'rr-cache', 'svn'] 461 shareable_dirs = ['hooks', 'objects', 'rr-cache', 'svn']
462 # These objects can only be used by a single working tree.
463 working_tree_files = ['config', 'packed-refs', 'shallow']
464 working_tree_dirs = ['logs', 'refs']
465 462
466 def __init__(self, 463 def __init__(self,
467 manifest, 464 manifest,
@@ -2483,10 +2480,9 @@ class Project(object):
2483 os.makedirs(self.gitdir) 2480 os.makedirs(self.gitdir)
2484 2481
2485 if init_obj_dir or init_git_dir: 2482 if init_obj_dir or init_git_dir:
2486 self._ReferenceGitDir(self.objdir, self.gitdir, share_refs=False, 2483 self._ReferenceGitDir(self.objdir, self.gitdir, copy_all=True)
2487 copy_all=True)
2488 try: 2484 try:
2489 self._CheckDirReference(self.objdir, self.gitdir, share_refs=False) 2485 self._CheckDirReference(self.objdir, self.gitdir)
2490 except GitError as e: 2486 except GitError as e:
2491 if force_sync: 2487 if force_sync:
2492 print("Retrying clone after deleting %s" % 2488 print("Retrying clone after deleting %s" %
@@ -2650,40 +2646,19 @@ class Project(object):
2650 else: 2646 else:
2651 active_git.symbolic_ref('-m', msg, ref, dst) 2647 active_git.symbolic_ref('-m', msg, ref, dst)
2652 2648
2653 def _CheckDirReference(self, srcdir, destdir, share_refs): 2649 def _CheckDirReference(self, srcdir, destdir):
2654 # Git worktrees don't use symlinks to share at all. 2650 # Git worktrees don't use symlinks to share at all.
2655 if self.use_git_worktrees: 2651 if self.use_git_worktrees:
2656 return 2652 return
2657 2653
2658 symlink_files = self.shareable_files[:] 2654 symlink_files = self.shareable_files[:]
2659 symlink_dirs = self.shareable_dirs[:] 2655 symlink_dirs = self.shareable_dirs[:]
2660 if share_refs:
2661 symlink_files += self.working_tree_files
2662 symlink_dirs += self.working_tree_dirs
2663 to_symlink = symlink_files + symlink_dirs 2656 to_symlink = symlink_files + symlink_dirs
2664 for name in set(to_symlink): 2657 for name in set(to_symlink):
2665 # Try to self-heal a bit in simple cases. 2658 # Try to self-heal a bit in simple cases.
2666 dst_path = os.path.join(destdir, name) 2659 dst_path = os.path.join(destdir, name)
2667 src_path = os.path.join(srcdir, name) 2660 src_path = os.path.join(srcdir, name)
2668 2661
2669 if name in self.working_tree_dirs:
2670 # If the dir is missing under .repo/projects/, create it.
2671 if not os.path.exists(src_path):
2672 os.makedirs(src_path)
2673
2674 elif name in self.working_tree_files:
2675 # If it's a file under the checkout .git/ and the .repo/projects/ has
2676 # nothing, move the file under the .repo/projects/ tree.
2677 if not os.path.exists(src_path) and os.path.isfile(dst_path):
2678 platform_utils.rename(dst_path, src_path)
2679
2680 # If the path exists under the .repo/projects/ and there's no symlink
2681 # under the checkout .git/, recreate the symlink.
2682 if name in self.working_tree_dirs or name in self.working_tree_files:
2683 if os.path.exists(src_path) and not os.path.exists(dst_path):
2684 platform_utils.symlink(
2685 os.path.relpath(src_path, os.path.dirname(dst_path)), dst_path)
2686
2687 dst = platform_utils.realpath(dst_path) 2662 dst = platform_utils.realpath(dst_path)
2688 if os.path.lexists(dst): 2663 if os.path.lexists(dst):
2689 src = platform_utils.realpath(src_path) 2664 src = platform_utils.realpath(src_path)
@@ -2696,22 +2671,17 @@ class Project(object):
2696 ' use `repo sync --force-sync {0}` to ' 2671 ' use `repo sync --force-sync {0}` to '
2697 'proceed.'.format(self.relpath)) 2672 'proceed.'.format(self.relpath))
2698 2673
2699 def _ReferenceGitDir(self, gitdir, dotgit, share_refs, copy_all): 2674 def _ReferenceGitDir(self, gitdir, dotgit, copy_all):
2700 """Update |dotgit| to reference |gitdir|, using symlinks where possible. 2675 """Update |dotgit| to reference |gitdir|, using symlinks where possible.
2701 2676
2702 Args: 2677 Args:
2703 gitdir: The bare git repository. Must already be initialized. 2678 gitdir: The bare git repository. Must already be initialized.
2704 dotgit: The repository you would like to initialize. 2679 dotgit: The repository you would like to initialize.
2705 share_refs: If true, |dotgit| will store its refs under |gitdir|.
2706 Only one work tree can store refs under a given |gitdir|.
2707 copy_all: If true, copy all remaining files from |gitdir| -> |dotgit|. 2680 copy_all: If true, copy all remaining files from |gitdir| -> |dotgit|.
2708 This saves you the effort of initializing |dotgit| yourself. 2681 This saves you the effort of initializing |dotgit| yourself.
2709 """ 2682 """
2710 symlink_files = self.shareable_files[:] 2683 symlink_files = self.shareable_files[:]
2711 symlink_dirs = self.shareable_dirs[:] 2684 symlink_dirs = self.shareable_dirs[:]
2712 if share_refs:
2713 symlink_files += self.working_tree_files
2714 symlink_dirs += self.working_tree_dirs
2715 to_symlink = symlink_files + symlink_dirs 2685 to_symlink = symlink_files + symlink_dirs
2716 2686
2717 to_copy = [] 2687 to_copy = []