diff --git a/tools/sfsnapshotgit b/tools/sfsnapshotgit
index 11bf3b9494f8b280d739805d83e2aac3e7ef571d..e79dd5538eac0efa48f049aa0ee2b9460557b3ac 100755 (executable)
--- a/tools/sfsnapshotgit
+++ b/tools/sfsnapshotgit
#!/bin/bash
# sfsnapshotgit - Snapshot script for Git repository
-# Original author: Thomas Gguyot-Sionnest <tguyot@unix.net>
+# Original author: Thomas Guyot-Sionnest <tguyot@gmail.com>
#
# Given an optional branch name (master by default), this script creates
# a snapshot from the tip of the branch and move it to ~/staging/.
# 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 ]
git clean -qfdx
# Any branch used to create snapshots must already exist
git checkout "$HEAD"
-git pull "$SFSNAP_ORIGIN" "$HEAD"
+git fetch "$SFSNAP_ORIGIN"
+git reset --hard "$SFSNAP_ORIGIN"/"$HEAD"
# Tags are important for git-describe
git fetch --tags "$SFSNAP_ORIGIN"