File: git-apply

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (97 lines) | stat: -rw-r--r-- 4,109 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# (C) 2011-2025 magicant

# Completion script for the "git-apply" command.
# Supports Git 2.48.1.

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

function completion/git::apply:arg {

        OPTIONS=( #>#
        "--allow-binary-replacement --binary"
        "--allow-empty; accept patch with no diff"
        "--apply; force to apply patches"
        "--build-fake-ancestor:" # TODO
        "--cached; apply patches to the index without modifying the working tree"
        "--check; check if patches can be applied without errors instead of applying patches"
        "--inaccurate-eof; work around diff errors about missing newlines at end of file"
        "--index; apply patches to the index as well as the working tree"
        "--intent-to-add; add filepaths but not their contents"
        "--no-add; apply deletions but not additions"
        "--ours; resolve conflicts in favor of our version"
        "q --quiet; suppress status and progress output"
        "--recount; ignore line counts in hunk headers"
        "R --reverse; patch in reverse"
        "--stat; print diffstat instead of applying patches"
        "--numstat; print a diffstat in the machine-friendly format instead of applying patches"
        "--summary; print summary instead of applying patches"
        "--theirs; resolve conflicts in favor of their version"
        "--unidiff-zero; accept unified diffs without context lines"
        "--union; resolve conflicts by combining both sides"
        "--unsafe-paths; allow patching outside working tree"
        "v --verbose; report progress in detail"
        "z; print a null byte after each filename"
        ) #<#
        command -f completion/git::apply:getopt apply

        command -f completion//parseoptions -n
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                (''|--exclude|--include)
                        complete -P "$PREFIX" -f
                        ;;
                (*)
                        command -f completion/git::apply:compopt
                        ;;
        esac

}

function completion/git::apply:getopt {
        typeset apply=
        case $1 in (am|apply)
                apply=true
                OPTIONS=("$OPTIONS" #>#
                "3 --3way; try 3-way merge on conflict"
                "--directory:; specify a directory to work in"
                "--exclude:; skip files whose names match the specified pattern"
                "--include:; apply to only files whose names match the specified pattern"
                "p:; specify the number of pathname components to strip from file names"
                "--reject; apply as much as possible and leave rejected hunks in *.rej file"
                ) #<#
        esac
        OPTIONS=("$OPTIONS" #>#
        "C:; specify the number of context lines in each hunk that must match"
        "--ignore-whitespace ${apply:+--ignore-space-change}; ignore whitespaces in context when applying patches"
        "--whitespace:; specify what to do with whitespace errors"
        ) #<#
}

function completion/git::apply:compopt
        case $ARGOPT in
#               ([Cp])
#                       ;;
                (--directory)
                        complete -P "$PREFIX" -S / -T -d
                        command -f completion/git::completepath
                        ;;
                (--whitespace)
                        command -f completion/git::--whitespace:arg
                        ;;
        esac

function completion/git::--whitespace:arg { #>>#
        complete -P "$PREFIX" -D "treat as errors and print some of them" error
        complete -P "$PREFIX" -D "treat as errors and print all of them" error-all
        complete -P "$PREFIX" -D "print warnings and fix errors" fix strip
        complete -P "$PREFIX" -D "don't print warnings about whitespace errors" nowarn
        complete -P "$PREFIX" -D "print warnings but apply the patch as is" warn
} #<#


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