/usr/bin/git-ignore is in git-extras 1.9.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/bash
function show_contents {
test -f "$2" && echo "$1 gitignore: $2" && cat "$2"
}
function show_global {
show_contents Global `git config --global core.excludesfile`
}
function add_global {
add_patterns `git config --global core.excludesfile` "$@"
}
function show_local {
show_contents Local .gitignore
}
function add_local {
add_patterns .gitignore "$@"
}
function add_patterns {
echo "Adding pattern(s) to: $1"
for pattern in "${@:2}"; do
echo "... adding '$pattern'"
(test -f "$1" && test "$pattern" && grep -q "$pattern" "$1") || echo "$pattern" >> "$1"
done
}
if test $# -eq 0; then
show_global
echo "---------------------------------"
show_local
else
case "$1" in
-l|--local)
test $# -gt 1 && add_local "${@:2}" && echo
show_local
;;
-g|--global)
test $# -gt 1 && add_global "${@:2}" && echo
show_global
;;
*)
add_local "$@"
;;
esac
fi
|