From 5bdc4b3562a3cd90501fc8184f87e9a28a64c6bd Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 8 Jun 2022 19:25:20 -0700 Subject: [PATCH] upgrade-zulip-from-git: init, then add remote. 30457ecd02b5db0a468dee8dc3953a9af8d82ff5 removed the `--mirror` from initial clones, but did not add back `--bare`, which `--mirror` implies. This leads to `/srv/zulip.git` having a working tree in it, with a `/srv/zulip.git/.git` directory. This is mostly harmless, and since the bug was recent, not worth introducing additional complexity into the upgrade process to handle. Calling `git clone --bare`, however, would clone the refs into `refs/heads/`, not the `refs/remotes/origin/` we want. Instead, use `git init --bare`, followed by `git remote add origin`. The remote will be fetched by the usual `git fetch --all --prune` which is below. --- scripts/lib/upgrade-zulip-from-git | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/lib/upgrade-zulip-from-git b/scripts/lib/upgrade-zulip-from-git index 4f3addd9bd..c9b91f836d 100755 --- a/scripts/lib/upgrade-zulip-from-git +++ b/scripts/lib/upgrade-zulip-from-git @@ -60,11 +60,15 @@ try: # Populate LOCAL_GIT_CACHE_DIR with both the requested remote and zulip/zulip. if not os.path.exists(LOCAL_GIT_CACHE_DIR): - logging.info("Cloning the repository") + logging.info("Making local repository cache") subprocess.check_call( - ["git", "clone", "-q", remote_url, LOCAL_GIT_CACHE_DIR], + ["git", "init", "--bare", "-q", LOCAL_GIT_CACHE_DIR], stdout=subprocess.DEVNULL, ) + subprocess.check_call( + ["git", "remote", "add", "origin", remote_url], + cwd=LOCAL_GIT_CACHE_DIR, + ) if os.stat(LOCAL_GIT_CACHE_DIR).st_uid == 0: subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])