aboutsummaryrefslogtreecommitdiff
path: root/git-checkout-script
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 09:59:26 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 09:59:26 -0700
commita79944d76cf4098e42d13e5743a3dccb61ebaca6 (patch)
treee3f66f537c4962052f296e42864b9591b4f567b0 /git-checkout-script
parent303e5f4c325d008c68e5e70e901ab68b289ade2e (diff)
downloadgit-a79944d76cf4098e42d13e5743a3dccb61ebaca6.tar.gz
git-a79944d76cf4098e42d13e5743a3dccb61ebaca6.tar.xz
"git checkout": add "-u" flag to update HEAD conditionally
And fix braino on testing "-f".
Diffstat (limited to 'git-checkout-script')
-rwxr-xr-xgit-checkout-script15
1 files changed, 9 insertions, 6 deletions
diff --git a/git-checkout-script b/git-checkout-script
index e8e777f1f..dc1cffde0 100755
--- a/git-checkout-script
+++ b/git-checkout-script
@@ -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
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"
+