Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/git-jump/README
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ To use it, just drop git-jump in your PATH, and then invoke it like
this:

--------------------------------------------------
# pick a mode automatically: "merge" if there are unmerged paths,
# "diff" if the worktree has unstaged changes, otherwise show usage
git jump

# jump to changes not yet staged for commit
git jump diff

Expand Down
16 changes: 13 additions & 3 deletions contrib/git-jump/git-jump
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

usage() {
cat <<\EOF
usage: git jump [--stdout] <mode> [<args>]
usage: git jump [--stdout] [<mode>] [<args>]

Jump to interesting elements in an editor.
The <mode> parameter is one of:
Expand Down Expand Up @@ -99,8 +99,18 @@ while test $# -gt 0; do
shift
done
if test $# -lt 1; then
usage >&2
exit 1
if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true"; then
usage >&2
exit 1
fi
if test -n "$(git ls-files -u)"; then
set -- merge
elif ! git diff --quiet; then
set -- diff
else
usage >&2
exit 1
fi
fi
mode=$1; shift
type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
Expand Down
Loading