Skip to content

Instantly share code, notes, and snippets.

@stestagg
Created August 5, 2013 12:21
Show Gist options
  • Save stestagg/6155515 to your computer and use it in GitHub Desktop.
Save stestagg/6155515 to your computer and use it in GitHub Desktop.
#!/bin/bash
function error {
echo -e ">>>>>>>>>>>>>>>>>>>>>>\n$@\n<<<<<<<<<<<<<<<<<<<<<<"
}
set -e
if [ -e test ]; then
echo "'test/' already exists"
exit 1
fi
mkdir test
(
set -x
cd test
fossil init test.fossil
mkdir test
cd test
fossil open ../test.fossil
echo HI > a.txt
echo HO > b.txt
echo HE > c.txt
fossil addremove
BEFORE_HASH=$(fossil commit -m "initial" | grep "New_Version: " | cut -d" " -f2)
echo MORE >> a.txt
echo EVEN >> b.txt
echo SOME >> c.txt
# <---- If you comment out these lines, then the test passes
fossil commit --private -m "on branch"
fossil checkout trunk
fossil merge private
# <----- End comment region
# Check it's in the diff
if [ -z "$(fossil diff | grep '+MORE')" ]; then
echo "Merge didn't pull from branch"
exit 1
fi
# Stash the changes..
fossil stash save -m "just a and b" a.txt b.txt
#fossil stash save -m "everything else"
if [ ! -z "$(fossil diff)" ]; then
error "Non empty diff"
fi
if [ -z "$(fossil stash show 1 | grep '+MORE')" ]; then
error "MORE not in stash diff"
fi
if [ $(fossil stash show 1 | grep -E 'CHANGED (a.txt|b.txt)' | uniq | wc -l) != 2 ]; then
error "Diff doesn't have a.txt and b.txt"
fi
fossil stash apply 1
if [ -z "$(fossil diff)" ]; then
error "Empty diff after apply"
fi
# Note no --allow-empty here...
AFTER_HASH=$(fossil commit -m "Committing anyway" | grep "New_Version: " | cut -d" " -f2)
fossil diff --from $BEFORE_HASH --to $AFTER_HASH
if [ "$(fossil cat a.txt)" == "HI" ]; then
error "a.txt unchanged after commit"
fi
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment