Browse Source

"git checkout": add "-u" flag to update HEAD conditionally

And fix braino on testing "-f".
maint
Linus Torvalds 20 years ago
parent
commit
a79944d76c
  1. 15
      git-checkout-script

15
git-checkout-script

@ -6,11 +6,14 @@ new=${new:-$old} @@ -6,11 +6,14 @@ new=${new:-$old}
args=($(git-rev-parse --no-revs "$@"))

i=0
force=0
force=
update=
while [ $i -lt ${#args} ]; do
case "${args[$i]}" in
"-f")
force=1;;
"-u")
update=1;;
"")
;;
*)
@ -20,11 +23,11 @@ while [ $i -lt ${#args} ]; do @@ -20,11 +23,11 @@ while [ $i -lt ${#args} ]; do
i=$(($i+1))
done

if $force
if [ "$force" ]
then
git-read-tree --reset $new &&
git-checkout-cache -q -f -u -a &&
echo $new > "$GIT_DIR/HEAD"
git-checkout-cache -q -f -u -a
else
git-read-tree -m -u $old $new && echo $new > "$GIT_DIR/HEAD"
fi
git-read-tree -m -u $old $new
fi && [ "$update" ] && echo $new > "$GIT_DIR/HEAD"


Loading…
Cancel
Save