Commit 7200a629 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot

Merge topic 'update_common_latest_version'

80e5f274 Update update-common.sh to the SHA1: b094fcba
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1669
parents 1ce9c309 80e5f274
......@@ -56,7 +56,7 @@ disable_custom_gitattributes() {
pushd "${extractdir}/${name}-reduced"
# Git does not allow custom attributes in a subdirectory where we
# are about to merge the `.gitattributes` file, so disable them.
sed -i '/^\[attr\]/ {s/^/#/}' .gitattributes
sed -i '/^\[attr\]/ {s/^/#/;}' .gitattributes
popd
}
......@@ -71,8 +71,9 @@ warn () {
readonly regex_date='20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
readonly basehash_regex="$name $regex_date ([0-9a-f]*)"
readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p}' | egrep '^[0-9a-f]+$' )"
readonly toplevel_dir="$( git rev-parse --show-toplevel )"
cd "$toplevel_dir"
########################################################################
# Sanity checking
......@@ -87,6 +88,18 @@ readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$ba
die "'repo' is empty"
[ -n "$tag" ] || \
die "'tag' is empty"
# Check for an empty destination directory on disk. By checking on disk and
# not in the repo it allows a library to be freshly re-inialized in a single
# commit rather than first deleting the old copy in one commit and adding the
# new copy in a seperate commit.
if [ ! -d "$(git rev-parse --show-toplevel)/$subtree" ]; then
readonly basehash=""
else
readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
fi
readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p;}' | egrep '^[0-9a-f]+$' )"
[ -n "$basehash" ] || \
warn "'basehash' is empty; performing initial import"
readonly do_shortlog="${shortlog-false}"
......@@ -104,6 +117,8 @@ trap "rm -rf '$workdir'" EXIT
git clone "$repo" "$upstreamdir"
if [ -n "$basehash" ]; then
# Remove old worktrees
git worktree prune
# Use the existing package's history
git worktree add "$extractdir" "$basehash"
# Clear out the working tree
......@@ -163,8 +178,8 @@ popd
if [ -n "$basehash" ]; then
git merge --log -s recursive "-Xsubtree=$subtree/" --no-commit "upstream-$name"
else
# Note: on Windows 'git merge' will open a browser, and the check will fail,
# so use the flag by default.
# Note: on Windows 'git merge --help' will open a browser, and the check
# will fail, so use the flag by default.
unrelated_histories_flag=""
if git --version | grep -q windows; then
unrelated_histories_flag="--allow-unrelated-histories "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment