-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkout: Don't crash when switching away from an invalid branch.
When using alternates, it is possible for HEAD to end up pointing to an invalid commit. git checkout should be able to recover from that situation without crashing. Signed-off-by: Alexandre Julliard <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
- Loading branch information
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
test_description='checkout switching away from an invalid branch' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'setup' ' | ||
echo hello >world && | ||
git add world && | ||
git commit -m initial | ||
' | ||
|
||
test_expect_success 'checkout master from invalid HEAD' ' | ||
echo 0000000000000000000000000000000000000000 >.git/HEAD && | ||
git checkout master -- | ||
' | ||
|
||
test_done |