In the case that git bisect is being used on a repo with damaged trees, git checkout may not succeed. This function allows checkout to succeed even if the current commit references a damaged tree. This will be useful for git bisect reset, for example. Signed-off-by: Jon Seymour <jon.seymour@xxxxxxxxx> --- git-bisect.sh | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/git-bisect.sh b/git-bisect.sh index b2186a8..486a860 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -34,6 +34,8 @@ require_work_tree _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" +IGNORE_CHECKOUT_FAILURE=$(test -f "${GIT_DIR}/BISECT_IGNORE_CHECKOUT_FAILURE" && cat "${GIT_DIR}/BISECT_IGNORE_CHECKOUT_FAILURE") + bisect_autostart() { test -s "$GIT_DIR/BISECT_START" || { ( @@ -325,6 +327,23 @@ bisect_visualize() { eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") } +bisect_checkout_with_ignore() +{ + ref=$1 + if test -z "$IGNORE_CHECKOUT_FAILURE"; then + git checkout "$ref" -- || exit + else + if git checkout "$ref" -- 2>/dev/null; then + # If the current tree contains missing objects + # git checkout will fail. It might be + # possible to recover from this if we update + # the HEAD first. + git update-ref --no-deref HEAD "$ref" && + git checkout "$ref" -- || exit + fi + fi +} + bisect_reset() { test -s "$GIT_DIR/BISECT_START" || { gettext "We are not bisecting."; echo -- 1.7.6.347.g96e0b.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html