Skip to content

Commit

Permalink
Merge pull request #61 from nalin-singh/feature
Browse files Browse the repository at this point in the history
Added empty list check
  • Loading branch information
Bhupesh-V authored May 27, 2023
2 parents 8ae4578 + b959579 commit 6db2f6b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions ugit
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,21 @@ undo_git_merge() {
}

recover_lost_stash() {
LOST_STASH=$(git fsck --no-progress --unreachable | \
awk '/commit/ {print $3}' | \
xargs git log --color --oneline --merges --no-walk | \
fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}'
LOST_STASH=$(git fsck --no-progress --unreachable |
awk '/commit/ {print $3}' |
xargs git log --color --oneline --merges --no-walk
)

[[ "$LOST_STASH" ]] && read -p "Enter Stash Description: " -r STASH_MSG || exit
if [ -z "$LOST_STASH" ]; then
printf "%s\n" "No unreachable commits found. Exiting..."
exit
fi

STASH=$(echo "$LOST_STASH" | fzf --ansi --height 20% --reverse --header="Choose commit associated with stash" | awk '{print $1}')

read -p "Enter Stash Description: " -r STASH_MSG

if git update-ref refs/stash "$LOST_STASH" --create-reflog -m "$STASH_MSG"; then
if git update-ref refs/stash "$STASH" --create-reflog -m "$STASH_MSG"; then
printf "%s\n" "Stash Successfully Recovered 👍️"
else
perror "Unable to recover stash"
Expand Down

0 comments on commit 6db2f6b

Please sign in to comment.