Skip to content

Instantly share code, notes, and snippets.

@fernandofig
Created May 23, 2019 22:52
Show Gist options
  • Save fernandofig/539652747da79681647af98dc7e8e248 to your computer and use it in GitHub Desktop.
Save fernandofig/539652747da79681647af98dc7e8e248 to your computer and use it in GitHub Desktop.
Script to be used with SourceTree to create a zip archive of files changed on a given (single) commit
@ECHO OFF
SET "PATH=%PATH%;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin"
cd "%~2"
bash "C:\Program Files\Git\usr\bin\packChanges.sh" %1
EXIT 0
ISMERGE=0
gitismerge () {
local sha="$1"
msha=$(git rev-list -1 --merges ${sha}~1..${sha})
if [ -z "$msha" ]; then
ISMERGE=0
else
ISMERGE=1
fi
}
gitismerge "$1"
if [ "$ISMERGE" = "1" ]; then
GITDIFF=`git diff --no-commit-id --name-only --diff-filter=ACMRT -r $1^ $1`
else
GITDIFF=`git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT -r $1`
fi
#echo $GITDIFF > saida.txt
git archive -o changes.zip $1 $GITDIFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment