Skip to content

Commit 678a0c2

Browse files
committed
git-ignore: the directory of target file may not exist
Signed-off-by: spacewander <[email protected]>
1 parent 42458d8 commit 678a0c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bin/git-ignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ function add_private {
5757
function add_patterns {
5858
echo "Adding pattern(s) to: $1"
5959
local file="${1/#~/$HOME}"
60+
dir_name=$(dirname "$file")
61+
if [ ! -d "$dir_name" ]; then
62+
mkdir -p "$dir_name"
63+
fi
6064
if [ -s "$file" ]; then
6165
# If the content of $file doesn't end with a newline, add one
6266
test "$(tail -c 1 "$file")" != "" && echo "" >> "$file"

0 commit comments

Comments
 (0)