# (C) 2011-2013 magicant

# Completion script for the "git-rebase" command.
# Supports Git 1.8.1.4.

function completion/git-rebase {
	WORDS=(git rebase "${WORDS[2,-1]}")
	command -f completion//reexecute
}

function completion/git::rebase:arg {

	OPTIONS=()
	command -f completion/git::rebase:getopt

	command -f completion//parseoptions -n
	case $ARGOPT in
		(-)
			command -f completion//completeoptions
			;;
		('')
			command -f completion/git::completeref
			;;
		(*)
			command -f completion/git::rebase:compopt
			;;
	esac

}

function completion/git::rebase:getopt {
	OPTIONS=("$OPTIONS" #>#
	"--abort; abort the current rebasing and reset to the original"
	"--autosquash; find commits to be squashed (with -i)"
	"--committer-date-is-author-date; use author date for committer date"
	"--continue; continue the current rebasing"
	"--edit-todo; re-edit the to-do list of the current rebasing"
	"f --force-rebase; rebase even if the branch is up-to-date"
	"--ignore-date; use committer date for author date"
	"i --interactive; interactively reedit commits that are rebased"
	"--keep-empty; don't omit commits that make no change"
	"m --merge; use merging strategies to rebase"
	"--no-autosquash; cancel the --autosquash option"
	"--no-ff; don't fast-forward even if possible"
	"n --no-stat; don't print a diffstat"
	"--no-verify; don't run the pre-rebase hook"
	"--onto; specify a branch to rebase onto"
	"p --preserve-merges; don't ignore merge commits"
	"q --quiet; don't print anything"
	"--root; rebase all ancestor commits"
	"--skip; skip the current patch and continue rebasing"
	"--stat; print a diffstat from the last rebase"
	"s: --strategy:; specify the merge strategy"
	"x: --exec:; insert an \"exec\" line with the specified command after each commit (with -i)"
	"X: --strategy-option:; specify a strategy-specific option"
	"v --verbose" # TODO description
	"--verify; run the pre-rebase hook"
	) #<#
	if command -vf completion/git::apply:getopt >/dev/null 2>&1 ||
			. -AL completion/git-apply; then
		command -f completion/git::apply:getopt rebase
	fi
}

function completion/git::rebase:compopt
	case $ARGOPT in
		(*)
			if command -vf completion/git::apply:compopt >/dev/null 2>&1 ||
					. -AL completion/git-apply; then
				command -f completion/git::apply:compopt
			fi
			if command -vf completion/git::merge:compopt >/dev/null 2>&1 ||
					. -AL completion/git-merge; then
				command -f completion/git::merge:compopt
			fi
			;;
	esac


# vim: set ft=sh ts=8 sts=8 sw=8 noet:
