Skip to content

Commit b877c2e

Browse files
committed
[git-attributes] Clarify trailing raw row handling (#179)
1 parent 1facc93 commit b877c2e

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/GitAttributes/Writer.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,14 @@ private function format(string $content): string
116116
];
117117
}
118118

119-
if ([] !== $rows && 'raw' === $rows[array_key_last($rows)]['type'] && '' === $rows[array_key_last(
120-
$rows
121-
)]['line']) {
122-
array_pop($rows);
119+
$lastRowKey = array_key_last($rows);
120+
121+
if (null !== $lastRowKey) {
122+
$lastRow = $rows[$lastRowKey];
123+
124+
if ('raw' === $lastRow['type'] && '' === $lastRow['line']) {
125+
array_pop($rows);
126+
}
123127
}
124128

125129
$formattedLines = [];

0 commit comments

Comments
 (0)