summaryrefslogtreecommitdiff
path: root/fuzz/config/git-copy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fuzz/config/git-copy.sh')
-rwxr-xr-xfuzz/config/git-copy.sh13
1 files changed, 6 insertions, 7 deletions
diff --git a/fuzz/config/git-copy.sh b/fuzz/config/git-copy.sh
index 7689abf96..2e57a6999 100755
--- a/fuzz/config/git-copy.sh
+++ b/fuzz/config/git-copy.sh
@@ -12,13 +12,12 @@ COMMIT="$2"
DIR="$3"
echo "Copy '$COMMIT' from '$REPO' to '$DIR'"
-if [ $(echo -n "$COMMIT" | wc -c) != "40" ]; then
- # On the off chance that $COMMIT is a remote head.
- ACTUAL=$(git ls-remote "$REPO" "$COMMIT" | cut -c 1-40 -)
- echo "Using commit hash '$ACTUAL'"
-else
+ACTUAL=$(git ls-remote "$REPO" "$COMMIT" | cut -c 1-40 -)
+if [ -z "$ACTUAL" ]; then
+ # Use this directly on the hope that it works.
ACTUAL="$COMMIT"
fi
+echo "Using commit hash '$ACTUAL'"
if [ -f "$DIR"/.git-copy ]; then
CURRENT=$(cat "$DIR"/.git-copy)
if [ "$CURRENT" = "$ACTUAL" ]; then
@@ -29,7 +28,7 @@ fi
rm -rf "$DIR"
git init -q "$DIR"
-git -C "$DIR" fetch -q --depth=1 "$REPO" "$ACTUAL":git-copy-tmp
-git -C "$DIR" reset --hard git-copy-tmp
+git -C "$DIR" fetch -q --depth=1 "$REPO" "$ACTUAL"
+git -C "$DIR" checkout "$ACTUAL"
git -C "$DIR" rev-parse --verify HEAD > "$DIR"/.git-copy
rm -rf "$DIR"/.git