jmou/zit
git clone https://github.com/jmou/zit.git
git clone git@github.com:jmou/zit.git
Loading…
(top)/commit-tree
language: Shell
746 Bytes / 21 lines / 18 loc
History
View raw
#!/bin/bash -e

# for non-hardcoded commit
export ZIT_AUTHOR_NAME="${ZIT_AUTHOR_NAME-Frank N. Stein}"
export ZIT_AUTHOR_EMAIL="${ZIT_AUTHOR_EMAIL-eat@brains.com}"
export ZIT_COMMITTER_NAME="${ZIT_COMMITTER_NAME-$ZIT_AUTHOR_NAME}"
export ZIT_COMMITTER_EMAIL="${ZIT_COMMITTER_EMAIL-$ZIT_AUTHOR_EMAIL}"

echo tree $1 > .zit/commit.tmp
shift
while [[ $1 == -p ]]; do # for non-initial commit
    parent=$(rev-parse $2)
    echo parent $parent >> .zit/commit.tmp
    shift; shift
done
echo author "$ZIT_AUTHOR_NAME <$ZIT_AUTHOR_EMAIL> $(date +'%s %z')" >> .zit/commit.tmp
echo committer "$ZIT_COMMITTER_NAME <$ZIT_COMMITTER_EMAIL> $(date +'%s %z')" >> .zit/commit.tmp
echo >> .zit/commit.tmp
cat >> .zit/commit.tmp

hash-object commit .zit/commit.tmp