Use --force when checking out commits

The clone_repo script clones the repo if needed and then checks out the
commit, branch, or master. If a previous checkout has left untracked
files, this will fail to protect those files from being overwritten.

In our automation we do not need to care about untracked files and need
to make sure we have the right point in the tree, so force the checkout
to make sure these untracked files are ignored.

Change-Id: Ia1ec2869aa7a899e987ef43a11f0af627efeea65
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis
2018-07-25 09:17:15 -05:00
parent 60a9d2e714
commit 4ac5e3f89a

View File

@@ -177,12 +177,12 @@ fi
if [ ! -z "$REF" ]; then
# Check out the specified reference.
(cd $local_dir && git checkout "$REF")
(cd $local_dir && git checkout -f "$REF")
else
# Check out the expected branch (master is the default, but if the
# directory already existed we might have checked out something else
# directory already exists we might have checked out something else
# before so just do it again).
(cd $local_dir &&
(git checkout $BRANCH || git checkout master) &&
(git checkout -f $BRANCH || git checkout -f master) &&
git pull --ff-only)
fi