2018-12-18 14:01:38 +00:00
|
|
|
# Given the path to a .git directory this function prints a human-readable name
|
|
|
|
# for the git action in progress (e.g. "merge") or returns 1.
|
|
|
|
function fish_print_git_action --argument-names git_dir
|
|
|
|
if test -z "$git_dir"
|
|
|
|
if not command -sq git
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
if not set git_dir (command git rev-parse --git-dir 2>/dev/null)
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for action_dir in "$git_dir/rebase-apply" "$git_dir/rebase"
|
|
|
|
if test -d "$action_dir"
|
|
|
|
if test -f "$action_dir/rebasing"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n rebase
|
2018-12-18 14:01:38 +00:00
|
|
|
else if test -f "$action_dir/applying"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n apply
|
2018-12-18 14:01:38 +00:00
|
|
|
else
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n rebase/apply
|
2018-12-18 14:01:38 +00:00
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for action_dir in "$git_dir/rebase-merge/interactive" "$git_dir/.dotest-merge/interactive"
|
|
|
|
if test -f "$action_dir"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n rebase-interactive
|
2018-12-18 14:01:38 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for action_dir in "$git_dir/rebase-merge" "$git_dir/.dotest-merge"
|
|
|
|
if test -d "$action_dir"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n rebase-merge
|
2018-12-18 14:01:38 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f "$git_dir/MERGE_HEAD"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n merge
|
2018-12-18 14:01:38 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f "$git_dir/CHERRY_PICK_HEAD"
|
|
|
|
if test -d "$git_dir/sequencer"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n cherry-pick-sequence
|
2018-12-18 14:01:38 +00:00
|
|
|
else
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n cherry-pick
|
2018-12-18 14:01:38 +00:00
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f "$git_dir/REVERT_HEAD"
|
|
|
|
if test -d "$git_dir/sequencer"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n revert-sequence
|
2018-12-18 14:01:38 +00:00
|
|
|
else
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n revert
|
2018-12-18 14:01:38 +00:00
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -f "$git_dir/BISECT_LOG"
|
2020-03-09 18:36:12 +00:00
|
|
|
echo -n bisect
|
2018-12-18 14:01:38 +00:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
return 1
|
|
|
|
end
|