From 593a6b575b137c42c91ef2439dbf6c526e5c5980 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Mon, 15 Mar 2021 21:35:13 +0000 Subject: [PATCH] Fetch all refs/heads/* on depot_tools update If user downloaded depot_tools.zip before 2021-03-11, it contained only fetch for refs/heads/master. As main branch is a new default branch, users need to update fetch ref in order to fetch chanes from main branch. R=ehmaldonado@google.com Bug: 1187238 Change-Id: I78041fc74f1bb505db375b9c1dced38cdfc9b144 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2753834 Reviewed-by: Edward Lesmes Commit-Queue: Josip Sokcevic --- update_depot_tools | 7 ++++++- update_depot_tools.bat | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/update_depot_tools b/update_depot_tools index 417b15d5a4..d15ca563cc 100755 --- a/update_depot_tools +++ b/update_depot_tools @@ -99,9 +99,14 @@ function update_git_repo { fi fi + # depot_tools.zip archives generated before 2021-03-12 have instruction to + # fetch only from old default git branch. Such branch won't be available + # evenutally, so fetch config needs to be updated. + git config --unset-all remote.origin.fetch + git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* git fetch -q origin &> /dev/null local CHECKOUT_TXT STATUS - CHECKOUT_TXT=$(git checkout -q origin/master 2>&1) + CHECKOUT_TXT=$(git checkout -q origin/main 2>&1) STATUS=$? if [[ $STATUS -ne 0 ]]; then echo "depot_tools update failed. Conflict in $base_dir" >&2 diff --git a/update_depot_tools.bat b/update_depot_tools.bat index 4df4d44d80..14eaa815dd 100644 --- a/update_depot_tools.bat +++ b/update_depot_tools.bat @@ -51,8 +51,13 @@ for /F %%x in ('git config --get remote.origin.url') DO ( ) ) ) +:: depot_tools.zip archives generated before 2021-03-12 have instruction to +:: fetch only from old default git branch. Such branch won't be available +:: evenutally, so fetch config needs to be updated. +call git config --unset-all remote.origin.fetch +call git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* call git fetch -q origin > NUL -call git checkout -q origin/master > NUL +call git checkout -q origin/main > NUL if errorlevel 1 ( echo Failed to update depot_tools. goto :EOF