"git checkout": add "-u" flag to update HEAD conditionally
And fix braino on testing "-f".
This commit is contained in:
parent
303e5f4c32
commit
a79944d76c
@ -6,11 +6,14 @@ new=${new:-$old}
|
|||||||
args=($(git-rev-parse --no-revs "$@"))
|
args=($(git-rev-parse --no-revs "$@"))
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
force=0
|
force=
|
||||||
|
update=
|
||||||
while [ $i -lt ${#args} ]; do
|
while [ $i -lt ${#args} ]; do
|
||||||
case "${args[$i]}" in
|
case "${args[$i]}" in
|
||||||
"-f")
|
"-f")
|
||||||
force=1;;
|
force=1;;
|
||||||
|
"-u")
|
||||||
|
update=1;;
|
||||||
"")
|
"")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -20,11 +23,11 @@ while [ $i -lt ${#args} ]; do
|
|||||||
i=$(($i+1))
|
i=$(($i+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if $force
|
if [ "$force" ]
|
||||||
then
|
then
|
||||||
git-read-tree --reset $new &&
|
git-read-tree --reset $new &&
|
||||||
git-checkout-cache -q -f -u -a &&
|
git-checkout-cache -q -f -u -a
|
||||||
echo $new > "$GIT_DIR/HEAD"
|
|
||||||
else
|
else
|
||||||
git-read-tree -m -u $old $new && echo $new > "$GIT_DIR/HEAD"
|
git-read-tree -m -u $old $new
|
||||||
fi
|
fi && [ "$update" ] && echo $new > "$GIT_DIR/HEAD"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user