зеркало из https://github.com/github/msysgit.git
95 строки
2.3 KiB
Bash
95 строки
2.3 KiB
Bash
#!/bin/sh
|
|
|
|
force=
|
|
while test $# -gt 0
|
|
do
|
|
case "$1" in
|
|
-f|--force)
|
|
force=t
|
|
shift
|
|
;;
|
|
*)
|
|
break
|
|
esac
|
|
done
|
|
|
|
test -z "$force" && {
|
|
die () {
|
|
echo "$*" >&2
|
|
echo "If that is okay, please call '$0 -f'" >&2
|
|
exit 1
|
|
}
|
|
|
|
(cd git &&
|
|
git update-index --refresh &&
|
|
git diff-files --quiet &&
|
|
git diff-index --cached HEAD --) ||
|
|
die "Git submodule has dirty files"
|
|
(git update-index --refresh &&
|
|
git diff-files --quiet &&
|
|
git diff-index --cached HEAD --) ||
|
|
die "msysGit super project not up-to-date"
|
|
}
|
|
|
|
die () {
|
|
echo $* >&2
|
|
exit 1
|
|
}
|
|
|
|
git show-ref --verify --quiet refs/heads/PortableGit ||
|
|
git branch PortableGit origin/PortableGit ||
|
|
die "Couldn't find or create PortableGit branch"
|
|
|
|
PORTABLEGIT_REF=$(git rev-parse PortableGit)
|
|
test "$PORTABLEGIT_REF" == $(git rev-parse origin/PortableGit) ||
|
|
die "Local PortableGit branch doesn't match origin/PortableGit"
|
|
|
|
echo "Building git..."
|
|
cd /git &&
|
|
make install >/dev/null &&
|
|
(cd ./contrib/subtree && make install INSTALL=/bin/install prefix=) ||
|
|
die "Failed to build git"
|
|
|
|
echo "Building Portable Git..."
|
|
# This puts the Portable Git release into /tmp/WinGit
|
|
cd / &&
|
|
NO_SFX=1 sh ./share/WinGit/portable-release.sh ghfw >/dev/null &&
|
|
mv "$HOME/PortableGit-ghfw.7z" /tmp/WinGit/PortableGit.7z ||
|
|
die "Couldn't build PortableGit"
|
|
|
|
echo "Committing to the PortableGit branch..."
|
|
GIT_DIR=/.git
|
|
GIT_INDEX_FILE=/tmp/ghfw.index
|
|
export GIT_DIR GIT_INDEX_FILE
|
|
rm -f $GIT_INDEX_FILE
|
|
|
|
cd /tmp/WinGit &&
|
|
mv /.git/hooks/post-checkout /.git/hooks/post-checkout.nope &&
|
|
git add . >/dev/null &&
|
|
for file in .gitattributes .gitignore
|
|
do
|
|
git checkout PortableGit $file ||
|
|
die "Couldn't check out $file from the PortableGit branch"
|
|
done &&
|
|
mv /.git/hooks/post-checkout.nope /.git/hooks/post-checkout ||
|
|
die "Failed to add files to index"
|
|
|
|
DEVEL_COMMIT=$(git rev-parse HEAD)
|
|
test $? ||
|
|
die "Couldn't determine HEAD commit"
|
|
|
|
NEW_TREE=$(git write-tree)
|
|
test $? ||
|
|
die "Couldn't write tree"
|
|
|
|
NEW_COMMIT=$(echo "Autogenerated PortableGit for $DEVEL_COMMIT" | git commit-tree $NEW_TREE -p $PORTABLEGIT_REF)
|
|
test $? ||
|
|
die "Couldn't create new commit"
|
|
|
|
git update-ref refs/heads/PortableGit $NEW_COMMIT $PORTABLEGIT_REF ||
|
|
die "Couldn't update the PortableGit branch"
|
|
|
|
echo
|
|
echo "Created commit $NEW_COMMIT on the PortableGit branch"
|
|
git log -1 PortableGit
|