mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-ignore: ensure new patterns comes after a newline
This commit is contained in:
parent
2370a4e27b
commit
11640196b2
|
|
@ -57,6 +57,10 @@ function add_private {
|
|||
function add_patterns {
|
||||
echo "Adding pattern(s) to: $1"
|
||||
local file="${1/#~/$HOME}"
|
||||
if [ -s "$file" ]; then
|
||||
# If $file doesn't end with a newline, add one
|
||||
test "$(tail -c 1 "$file")" != "" && echo "" >> "$file"
|
||||
fi
|
||||
for pattern in "${@:2}"; do
|
||||
echo "... adding '$pattern'"
|
||||
(test -f "$file" && test "$pattern" && grep -q -F -x -- "$pattern" "$file") || echo "$pattern" >> "$file"
|
||||
|
|
|
|||
Loading…
Reference in a new issue