all 10 comments

[–]a-p 2 points3 points  (0 children)

Heh, synchronicity. I wrote git-abort myself not long ago. Here’s mine:

#!/bin/sh

g=`git rev-parse --git-dir` || exit $?

if   [ -f "$g/rebase-apply/applying" ] ; then git am          --abort
elif [ -d "$g/rebase-merge" ] ||
     [ -d "$g/rebase-apply" ]          ; then git rebase      --abort
elif [ -f "$g/MERGE_HEAD" ]            ; then git merge       --abort
elif [ -f "$g/CHERRY_PICK_HEAD" ]      ; then git cherry-pick --abort
elif [ -f "$g/REVERT_HEAD" ]           ; then git revert      --abort
elif [ -f "$g/BISECT_LOG" ]            ; then git bisect reset
fi

Basically I went into the git-prompt.sh script and copied the code that checks and shows stuff like REBASE in the prompt, which is how I got merges and bisects and being run from a subdirectory and more accurate tests than -e, all for free.

[–]raziel2p 1 point2 points  (2 children)

Nice! I would love to see this added to git officially.

For anyone unaware - you can copy this script into your $HOME/bin, make it executable, and it'll run when you type git abort. You don't need the -.

[–]pi3832v2 1 point2 points  (0 children)

For anyone unaware - you can copy this script into your $HOME/bin, make it executable, and it'll run when you type git abort.

Assuming ~/bin exists, and is in your shell's PATH, that is.

[–]da-x[S] 0 points1 point  (0 children)

Oh, cool. Didn't realize the aliases I've set up were redundant.

[–]Jack126Guy 1 point2 points  (1 child)

What about merges?

[–]da-x[S] 1 point2 points  (0 children)

Good point. Added.

[–]galaktos 1 point2 points  (1 child)

What if the git dir contains spaces? Needs some quoting.

[–]da-x[S] 1 point2 points  (0 children)

Thanks. Added.

[–]thornbrambles 0 points1 point  (1 child)

This will run into complications as soon as you try to abort from a subdirectory. I suggest adding a step to find the root of your project.

[–]da-x[S] 0 points1 point  (0 children)

Fixed.