Skip to content

Commit 8227364

Browse files
committed
checkout to sha and checkout -b
1 parent 8b5796d commit 8227364

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/git/lib.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,21 @@ def branch_delete(branch)
511511
def checkout(branch, opts = {})
512512
arr_opts = []
513513
arr_opts << '-f' if opts[:force]
514-
arr_opts << '-b' << opts[:new_branch] if opts[:new_branch]
514+
515+
# -- implementation of a working -b switch
516+
# for git checkout command
517+
arr_opts << '-b' if opts[:new_branch]
518+
# -- this push is legacy
519+
# i don't understand it and congratulate
520+
# myself not to try to and just leave it here
521+
arr_opts << opts[:new_branch] if opts[:new_branch] && !opts[:new_branch].is_a?(TrueClass)
522+
#
523+
515524
arr_opts << branch
525+
526+
# -- we can 'git checkout `sha`' now
527+
arr_opts << opts[:commit] if opts[:commit]
528+
#
516529

517530
command('checkout', arr_opts)
518531
end

0 commit comments

Comments
 (0)