diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit
index ec2a4dade6e12aecbaa5ab97e4bee0f0e8b2994f..8bc19fce803c1f19af4688b84def5c73951ae664 100755 (executable)
--- a/tools/sfsnapshotgit
+++ b/tools/sfsnapshotgit
# Handle command errors (-e) and coder sleep deprivation issues (-u)
set -eu
-trap 'echo "An error occurred at line $LINENO"; exit 1' EXIT
+trap 'echo "An error occurred in sfsnapshotgit at line $LINENO"; exit 1' EXIT
# Send all command output to STDERR while allowing us to write to STDOUT
# using fd 3
# caller The defaults are:
SFSNAP_REPO=${SFSNAP_REPO-~/staging/nagiosplugins}
SFSNAP_ORIGIN=${SFSNAP_ORIGIN-origin}
-SFSNAP_DEST=${SFSNAP_DEST-~/staging}
+SFSNAP_DEST=${SFSNAP_DEST-~/staging/snapshot}
# If one argument is given, this is the branch to create the snapshot from
if [ $# -eq 0 ]
# Sometimes "make dist" can modify versioned files so we must reset first
git reset --hard
git clean -qfdx
-# Any branch used to create snapshots must already exist
+
+# Any branch used to create snapshots must already exist and be properly configured
git checkout "$HEAD"
-git pull "$SFSNAP_ORIGIN" "$HEAD"
-# Tags are important for git-describe
+
+# Get the remote tracking branch from config
+origin=$(git config branch.$HEAD.remote)
+ref=$(git config branch.$HEAD.merge |sed -e 's|^refs/heads/||')
+git fetch "$origin"
+git reset --hard "$origin/$ref"
+
+# Tags are important for git-describe, but take only the ones from the hard-coded origin
git fetch --tags "$SFSNAP_ORIGIN"
# Write our snapshot version string (similar to NP-VERSION-GEN) to "release"