diff --git a/helper/git_query.sh b/helper/git_query.sh index b2a58c3..3fb92f9 100644 --- a/helper/git_query.sh +++ b/helper/git_query.sh @@ -21,7 +21,7 @@ function get_commit() { if [[ "${#files[@]}" -eq 0 ]]; then git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ log --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr' \ - | fzf --no-multi --header="${header}" \ + | fzf --header="${header}" --no-multi \ --preview "echo {} \ | awk '{print \$1}' \ | xargs -I __ git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \ @@ -31,7 +31,7 @@ function get_commit() { else git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ log --oneline --color=always --decorate=short \ - | fzf --no-multi --header="${header}" --preview "echo {} \ + | fzf --header="${header}" --no-multi --preview "echo {} \ | awk '{print \$1}' \ | xargs -I __ git --git-dir=${DOTBARE_DIR} --work-tree=${DOTBARE_TREE} \ diff --color=always __ ${files[*]} \ diff --git a/scripts/fcheckout b/scripts/fcheckout index 018ae9f..62a4458 100755 --- a/scripts/fcheckout +++ b/scripts/fcheckout @@ -79,12 +79,12 @@ if [[ "${action_type}" == "branch" ]]; then # checkout branch selected_branch=$(get_branch 'select a branch to checkout') [[ -z "${selected_branch}" ]] && exit 1 - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_branch}" + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_branch}" elif [[ "${action_type}" == "commit" ]]; then # checkout commit selected_commit=$(get_commit 'select a commit to checkout') [[ -z "${selected_commit}" ]] && exit 1 - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_commit}" + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_commit}" elif [[ "${action_type}" == "modified" ]]; then # checkout modified file back to version in HEAD while IFS= read -r line; do @@ -94,7 +94,7 @@ elif [[ "${action_type}" == "modified" ]]; then [[ -z "${confirm}" ]] && echo "(dryrun) dotbare checkout --" "${selected_files[@]}" [[ -z "${confirm}" ]] && confirm=$(get_confirmation "Confirm?") [[ "${confirm}" != 'y' ]] && exit 1 - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout -- "${selected_files[@]}" + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout -- "${selected_files[@]}" elif [[ "${action_type}" == "select" ]]; then # checkout selected files to a selected commit while IFS= read -r line; do @@ -107,5 +107,5 @@ elif [[ "${action_type}" == "select" ]]; then [[ -z "${confirm}" ]] && echo "(dryrun) dotbare checkout ${selected_commit} --" "${selected_files[@]}" [[ -z "${confirm}" ]] && confirm=$(get_confirmation "Confirm?") [[ "${confirm}" != 'y' ]] && exit 0 - /usr/bin/git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_commit}" "${selected_files[@]}" + git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" checkout "${selected_commit}" "${selected_files[@]}" fi diff --git a/tests/fcheckout.bats b/tests/fcheckout.bats index 329bf6b..4955de3 100755 --- a/tests/fcheckout.bats +++ b/tests/fcheckout.bats @@ -41,38 +41,26 @@ checkout_selected_file() { } @test "fcheckout branch" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi run checkout_branch - [ "${status}" -eq 129 ] - [[ "${output}" =~ "fcheckout_branch" ]] + [[ "${output}" =~ "checkout" ]] + [[ "${output}" =~ "--no-multi --header=select a branch to checkout" ]] } @test "fcheckout commit" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi run checkout_commit - [ "${status}" -eq 129 ] - [[ "${output}" =~ "fcheckout_commit" ]] + [[ "${output}" =~ "checkout --header=select" ]] } @test "fcheckout modified" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi run checkout_modified_file - [ "${status}" -eq 1 ] - [[ "${output}" =~ "fcheckout_modified" ]] + [[ "${output}" =~ "checkout" ]] + [[ "${output}" =~ "file to checkout version in HEAD" ]] + [[ "${output}" =~ "diff HEAD --color=always" ]] } @test "fcheckout select" { - if ! "${BATS_TEST_DIRNAME}"/../dotbare log &>/dev/null; then - skip - fi run checkout_selected_file - [[ "${lines[0]}" =~ "fcheckout_select_commitdiff" ]] - [[ "${lines[1]}" =~ "fcheckout_select_gitfile" ]] - [ "${status}" -eq 1 ] + [[ "${output}" =~ "checkout" ]] + [[ "${output}" =~ "--header=select a file to checkout" ]] + [[ "${output}" =~ "preview.sh" ]] }