git: Checkout to FETCH_HEAD for refspec in "refs/changes" format
REPO_REFSPEC is used for checkout because it is possible to have several
FETCH_HEAD values. For example, when parsing the FETCH_HEAD for
"TF-Mv1.8.0", the commits of "TF-Mv1.8.0-RC1" and "TF-Mv1.8.0-RC2" will
also be added to FETCH_HEAD. So REPO_REFSPEC is used to do the final
checkout to make sure that the commit is exactly expected.
However, when the refspec of unmerged patch is in "refs/changes" format,
REPO_REFSPEC cannot be directly used to checkout. Luckily, the value of
FETCH_HEAD parsed from this kind of refspec is always unique, because
the refspec is consisted of patch number and patchset number. So it is
okay to checkout with FETCH_HEAD when REPO_REFSPEC is in "refs/changes"
format.
Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: I982d9775a9abb5b89c31717a4c85720a0abefe4b
diff --git a/util_git.sh b/util_git.sh
index 9cbf835..4f550b4 100644
--- a/util_git.sh
+++ b/util_git.sh
@@ -46,7 +46,13 @@
fi
# Checkout to specified refspec
- git checkout ${REPO_REFSPEC}
+ if [[ "${REPO_REFSPEC}" =~ "refs/changes" ]]; then
+ # Refspec in "refs/changes" format cannot be directly used to checkout
+ git checkout ${REPO_FETCH_HEAD}
+ else
+ git checkout ${REPO_REFSPEC}
+ fi
+
echo -e "Share Folder ${REPO_PATH} $(git rev-parse --short HEAD)\n"
cd $OLDPWD
fi