Use git-update-ref in scripts.

This uses the git-update-ref command in scripts for safer updates.
Also places where we used to read HEAD ref by using "cat" were fixed
to use git-rev-parse.  This will matter when we start using symbolic
references.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano
2005-09-27 18:14:27 -07:00
parent a7928f8ec7
commit bf7960eb51
9 changed files with 39 additions and 32 deletions

View File

@ -116,8 +116,9 @@ case "$#,$common" in
# Again the most common case of merging one remote.
echo "Updating from $head to $1."
git-update-index --refresh 2>/dev/null
git-read-tree -u -m $head "$1" || exit 1
git-rev-parse --verify "$1^0" > "$GIT_DIR/HEAD"
git-read-tree -u -m $head "$1" &&
new_head=$(git-rev-parse --verify "$1^0") &&
git-update-ref HEAD "$new_head" "$head" || exit 1
summary "$1"
dropsave
exit 0
@ -215,9 +216,9 @@ then
do
parents="$parents -p $remote"
done
result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents)
result_commit=$(echo "$merge_msg" | git-commit-tree $result_tree $parents) || exit
echo "Committed merge $result_commit, made by $wt_strategy."
echo $result_commit >"$GIT_DIR/HEAD"
git-update-ref HEAD $result_commit $head
summary $result_commit
dropsave
exit 0