File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,9 @@ static struct packed_ref_cache *read_packed_refs(const char *packed_refs_file)
230
230
const char * refname ;
231
231
const char * traits ;
232
232
233
+ if (!line .len || line .buf [line .len - 1 ] != '\n' )
234
+ die ("unterminated line in %s: %s" , packed_refs_file , line .buf );
235
+
233
236
if (skip_prefix (line .buf , "# pack-refs with:" , & traits )) {
234
237
if (strstr (traits , " fully-peeled " ))
235
238
peeled = PEELED_FULLY ;
@@ -254,9 +257,7 @@ static struct packed_ref_cache *read_packed_refs(const char *packed_refs_file)
254
257
(peeled == PEELED_TAGS && starts_with (refname , "refs/tags/" )))
255
258
last -> flag |= REF_KNOWS_PEELED ;
256
259
add_ref_entry (dir , last );
257
- continue ;
258
- }
259
- if (last &&
260
+ } else if (last &&
260
261
line .buf [0 ] == '^' &&
261
262
line .len == PEELED_LINE_LENGTH &&
262
263
line .buf [PEELED_LINE_LENGTH - 1 ] == '\n' &&
@@ -268,6 +269,9 @@ static struct packed_ref_cache *read_packed_refs(const char *packed_refs_file)
268
269
* reference:
269
270
*/
270
271
last -> flag |= REF_KNOWS_PEELED ;
272
+ } else {
273
+ strbuf_setlen (& line , line .len - 1 );
274
+ die ("unexpected line in %s: %s" , packed_refs_file , line .buf );
271
275
}
272
276
}
273
277
Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ test_expect_success 'notice d/f conflict with existing ref' '
194
194
test_must_fail git branch foo/bar/baz/lots/of/extra/components
195
195
'
196
196
197
- test_expect_failure ' reject packed-refs with unterminated line' '
197
+ test_expect_success ' reject packed-refs with unterminated line' '
198
198
cp .git/packed-refs .git/packed-refs.bak &&
199
199
test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
200
200
printf "%s" "$HEAD refs/zzzzz" >>.git/packed-refs &&
@@ -203,7 +203,7 @@ test_expect_failure 'reject packed-refs with unterminated line' '
203
203
test_cmp expected_err err
204
204
'
205
205
206
- test_expect_failure ' reject packed-refs containing junk' '
206
+ test_expect_success ' reject packed-refs containing junk' '
207
207
cp .git/packed-refs .git/packed-refs.bak &&
208
208
test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
209
209
printf "%s\n" "bogus content" >>.git/packed-refs &&
@@ -212,7 +212,7 @@ test_expect_failure 'reject packed-refs containing junk' '
212
212
test_cmp expected_err err
213
213
'
214
214
215
- test_expect_failure ' reject packed-refs with a short SHA-1' '
215
+ test_expect_success ' reject packed-refs with a short SHA-1' '
216
216
cp .git/packed-refs .git/packed-refs.bak &&
217
217
test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
218
218
printf "%.7s %s\n" $HEAD refs/zzzzz >>.git/packed-refs &&
You can’t perform that action at this time.
0 commit comments