Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion builtin/fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2456,8 +2456,10 @@ static void file_change_m(struct fast_import_state *state,
if (S_ISDIR(mode))
die(_("directories cannot be specified 'inline': %s"),
command_buf.buf);
while (read_next_command(state) != EOF) {
for (;;) {
const char *v;
if (read_next_command(state) == EOF)
die(_("expected 'data n' command, found end of input"));
if (skip_prefix(command_buf.buf, "cat-blob ", &v))
parse_cat_blob(state, v);
else {
Expand Down
34 changes: 34 additions & 0 deletions t/t9300-fast-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,40 @@ test_expect_success 'D: verify file6' '
test_cmp expect actual
'

test_expect_success 'D: fail on inline data cut off at end of input' '
cat >input <<-INPUT_END &&
commit refs/heads/D-inline-eof
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
inline data cut off
COMMIT

M 644 inline file
INPUT_END

test_must_fail git fast-import <input 2>err &&
test_grep "expected ${SQ}data n${SQ} command" err &&
test_must_fail git rev-parse --verify -q refs/heads/D-inline-eof
'

test_expect_success 'D: fail on unterminated cat-blob after inline M at end of input' '
blob=$(echo hello | git hash-object -w --stdin) &&
cat >input <<-INPUT_END &&
commit refs/heads/D-inline-cat-blob-eof
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
inline data cut off after cat-blob
COMMIT

M 644 inline file
INPUT_END
printf "cat-blob %s" "$blob" >>input &&

test_must_fail git fast-import <input >out 2>err &&
test_grep "expected ${SQ}data n${SQ} command" err &&
test_must_fail git rev-parse --verify -q refs/heads/D-inline-cat-blob-eof
'

###
### series E
###
Expand Down
Loading