summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorLibravatar Elijah Newren <newren@gmail.com>2019-02-20 14:58:46 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-04-01 11:59:09 +0900
commitcf7b857a77bda6a9a93e2cde2f6ae1764e7a2517 (patch)
tree7e8b94a8f8789f27c9c004d696a604b5b8a714f0 /fast-import.c
parentfast-import: only allow cat-blob requests where it makes sense (diff)
downloadtgif-cf7b857a77bda6a9a93e2cde2f6ae1764e7a2517.tar.xz
fast-import: fix erroneous handling of get-mark with empty orphan commits
When get-mark was introduced in commit 28c7b1f7b7b7 ("fast-import: add a get-mark command", 2015-07-01), it followed the precedent of the cat-blob command to be allowed on any line other than in the middle of a data directive; see commit 777f80d7429b ("fast-import: Allow cat-blob requests at arbitrary points in stream", 2010-11-28). It was useful to allow cat-blob directives in the middle of a commit to get more data that would be used in writing the current commit object. get-mark is not similarly useful since fast-import can already use either object id or mark. Further, trying to allow this command anywhere caused parsing bugs. Fix the parsing problems by only allowing get-mark commands to appear when other commands have completed. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/fast-import.c b/fast-import.c
index 338db61e6e..064c55e8be 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1748,8 +1748,6 @@ static int read_next_command(void)
}
for (;;) {
- const char *p;
-
if (unread_command_buf) {
unread_command_buf = 0;
} else {
@@ -1782,10 +1780,6 @@ static int read_next_command(void)
rc->prev->next = rc;
cmd_tail = rc;
}
- if (skip_prefix(command_buf.buf, "get-mark ", &p)) {
- parse_get_mark(p);
- continue;
- }
if (command_buf.buf[0] == '#')
continue;
return 0;
@@ -3318,6 +3312,8 @@ int cmd_main(int argc, const char **argv)
parse_ls(v, NULL);
else if (skip_prefix(command_buf.buf, "cat-blob ", &v))
parse_cat_blob(v);
+ else if (skip_prefix(command_buf.buf, "get-mark ", &v))
+ parse_get_mark(v);
else if (!strcmp("checkpoint", command_buf.buf))
parse_checkpoint();
else if (!strcmp("done", command_buf.buf))