| 2224 | depth_arg = f' --depth {depth}' if depth else '' |
| 2225 | |
| 2226 | def do_update(): |
| 2227 | # This seems to pull in the entire repository. |
| 2228 | log0(f'do_update(): attempting to update {local=}.') |
| 2229 | # Remove any local changes. |
| 2230 | run(f'cd {local} && git reset --hard', env_extra=env_extra) |
| 2231 | if tag: |
| 2232 | # `-u` avoids `fatal: Refusing to fetch into current branch`. |
| 2233 | # Using '+' and `revs/tags/` prefix seems to avoid errors like: |
| 2234 | # error: cannot update ref 'refs/heads/v3.16.44': |
| 2235 | # trying to write non-commit object |
| 2236 | # 06c4ae5fe39a03b37a25a8b95214d9f8f8a867b8 to branch |
| 2237 | # 'refs/heads/v3.16.44' |
| 2238 | # |
| 2239 | run(f'cd {local} && git fetch -fuv{depth_arg} {remote} +refs/tags/{tag}:refs/tags/{tag}', env_extra=env_extra) |
| 2240 | run(f'cd {local} && git checkout {tag}', env_extra=env_extra) |
| 2241 | if branch: |
| 2242 | # `-u` avoids `fatal: Refusing to fetch into current branch`. |
| 2243 | run(f'cd {local} && git fetch -fuv{depth_arg} {remote} {branch}:{branch}', env_extra=env_extra) |
| 2244 | run(f'cd {local} && git checkout {branch}', env_extra=env_extra) |
| 2245 | |
| 2246 | do_clone = True |
| 2247 | if os.path.isdir(f'{local}/.git'): |