-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit, update-ref, rev-parse, symbolic-ref
- Loading branch information
Joe Mou
committed
Apr 17, 2019
1 parent
ee58d42
commit 51ca764
Showing
5 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash -e | ||
|
||
# TODO unless this is the initial commit | ||
parents='-p HEAD' | ||
echo '# write a commit message' > .zit/COMMIT_EDITMSG | ||
vi .zit/COMMIT_EDITMSG | ||
tree=$(./write-tree) | ||
commit=$(grep -v '^#' .zit/COMMIT_EDITMSG | ./commit-tree $tree $parents) | ||
./update-ref HEAD $commit | ||
rm -f .zit/COMMIT_EDITMSG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
echo tree $1 > .zit/commit.tmp | ||
shift | ||
while [[ $1 == -p ]]; do | ||
echo parent $2 >> .zit/commit.tmp | ||
parent=$(./rev-parse $2) | ||
echo parent $parent >> .zit/commit.tmp | ||
shift; shift | ||
done | ||
echo author "Joe Mou <[email protected]> $(date +'%s %z')" >> .zit/commit.tmp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -e | ||
# only implements --verify | ||
|
||
# sha1_name.c:get_sha1 | ||
|
||
if [[ ${#1} -eq 40 ]]; then | ||
echo $1 | ||
else | ||
cat .zit/$(./symbolic-ref $1) 2> /dev/null || \ | ||
cat .zit/$(./symbolic-ref refs/$1) 2> /dev/null || \ | ||
cat .zit/$(./symbolic-ref refs/tags/$1) 2> /dev/null || \ | ||
cat .zit/$(./symbolic-ref refs/heads/$1) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -e | ||
|
||
# refs.c:resolve_ref | ||
path=.zit/$1 | ||
while grep -q '^ref: ' $path 2> /dev/null; do | ||
path=.zit/$(cut -d' ' -f2 < $path) | ||
done | ||
echo $path | cut -d/ -f2- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash -e | ||
|
||
path=.zit/$(./symbolic-ref $1) | ||
sha1=$(./rev-parse $2) | ||
# TODO initialize directory structure instead? | ||
mkdir -p $(dirname $path) | ||
echo $sha1 > $path |