Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 656cc1ef6d
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 92 lines (76 sloc) 2.132 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#!/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 ||
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 &&
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 ||
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
Something went wrong with that request. Please try again.