mirror of
https://github.com/tj/git-extras.git
synced 2026-09-15 09:56:19 -04:00
Merge pull request #949 from tfendin/git-ignore-ensure-newline
This commit is contained in:
commit
b772251074
|
|
@ -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 the content of $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