commit: 221772b8f451e4b2db9d7eabf0c86f7691728191
parent 308ffecc89bce90960bdbbdd2f4cfd4fce8a7367
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 11 Feb 2020 18:03:02 -0500
Remove excess mode parsing from ls-file, write-tree
Diffstat:
3 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/commit-tree b/commit-tree
@@ -11,7 +11,7 @@ while getopts p: opt
do
case $opt in
p)
- parents="$(printf "$s" "$parents" | tr -s , ' ')"
+ parents="$(printf "%s" "$OPTARG" | tr -s , ' ')"
;;
?)
printf "Usage: %s [-p <parents...>]\n" "$0" >&2
diff --git a/ls-files b/ls-files
@@ -50,17 +50,17 @@ do
exit 1
;;
esac
- mode=$((mode & 0x1FF))
- if [ $mode -ne $((0644)) ] && [ $mode -ne $((0755)) ] && [ $mode -ne 0 ]
+ unixmode=$((mode & 0x1FF))
+ if [ $unixmode -ne $((0644)) ] && [ $unixmode -ne $((0755)) ] && [ $unixmode -ne 0 ]
then
- printf "Invalid file mode %o\n" $mode >&2
+ printf "Invalid file mode %o\n" $unixmode >&2
exit 1
fi
pathlen=$((flags & 0xFFF))
path="$(read_text "$index" $((offs+62)) $pathlen)"
- printf "%s %o %s %s\n" "$objtype" "$mode" "$sha" "$path"
+ printf "%o %s %s\n" "$mode" "$sha" "$path"
padding=$((${#path} + 1 + 62))
padding=$((padding % 8))
diff --git a/write-tree b/write-tree
@@ -2,22 +2,9 @@
SHIT_PATH=$(dirname "$0")
. $SHIT_PATH/common.sh
-"$SHIT_PATH"/ls-files | while read -r type mode sha path
+"$SHIT_PATH"/ls-files | while read -r mode sha path
do
- case $type in
- file)
- mode=100$mode
- ;;
- link)
- mode=012$mode
- ;;
- gitlink)
- printf "submodules are unimplemented\n" >&2
- exit 1
- ;;
- esac
# TODO: subtrees
- objtype=blob
printf "%s %s\0" $mode "$path"
write_hex "$sha"
done