fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian HomborgReindent functions to remove useless quotes9367d4ff7

master
1.7 KiB69 linesraw
1# Given the path to a .git directory this function prints a human-readable name
2# for the git action in progress (e.g. "merge") or returns 1.
3function fish_print_git_action --argument-names git_dir
4    if test -z "$git_dir"
5        if not command -sq git
6            return 1
7        end
8        if not set git_dir (command git rev-parse --git-dir 2>/dev/null)
9            return 1
10        end
11    end
12
13    for action_dir in "$git_dir/rebase-apply" "$git_dir/rebase"
14        if test -d "$action_dir"
15            if test -f "$action_dir/rebasing"
16                echo -n rebase
17            else if test -f "$action_dir/applying"
18                echo -n apply
19            else
20                echo -n rebase/apply
21            end
22            return 0
23        end
24    end
25
26    for action_dir in "$git_dir/rebase-merge/interactive" "$git_dir/.dotest-merge/interactive"
27        if test -f "$action_dir"
28            echo -n rebase-interactive
29            return 0
30        end
31    end
32
33    for action_dir in "$git_dir/rebase-merge" "$git_dir/.dotest-merge"
34        if test -d "$action_dir"
35            echo -n rebase-merge
36            return 0
37        end
38    end
39
40    if test -f "$git_dir/MERGE_HEAD"
41        echo -n merge
42        return 0
43    end
44
45    if test -f "$git_dir/CHERRY_PICK_HEAD"
46        if test -d "$git_dir/sequencer"
47            echo -n cherry-pick-sequence
48        else
49            echo -n cherry-pick
50        end
51        return 0
52    end
53
54    if test -f "$git_dir/REVERT_HEAD"
55        if test -d "$git_dir/sequencer"
56            echo -n revert-sequence
57        else
58            echo -n revert
59        end
60        return 0
61    end
62
63    if test -f "$git_dir/BISECT_LOG"
64        echo -n bisect
65        return 0
66    end
67
68    return 1
69end