From: Elijah Newren <newren@gmail.com>
To: <git@vger.kernel.org>
Cc: Michael Haggerty <mhagger@alum.mit.edu>,
Jonathan Nieder <jrnieder@gmail.com>, Jeff King <peff@peff.net>,
David Barr <david.barr@cordelta.com>,
Elijah Newren <newren@gmail.com>
Subject: [RFC PATCH 5/5] fast-import: fix erroneous handling of get-mark with empty orphan commits
Date: Wed, 20 Feb 2019 14:58:46 -0800 [thread overview]
Message-ID: <20190220225846.10658-6-newren@gmail.com> (raw)
In-Reply-To: <20190220225846.10658-1-newren@gmail.com>
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>
---
Documentation/git-fast-import.txt | 4 ----
fast-import.c | 8 ++------
t/t9300-fast-import.sh | 4 ++--
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 982f82b0b3..33cce1e150 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -971,10 +971,6 @@ might want to refer to in their commit messages.
'get-mark' SP ':' <idnum> LF
....
-This command can be used anywhere in the stream that comments are
-accepted. In particular, the `get-mark` command can be used in the
-middle of a commit but not in the middle of a `data` command.
-
See ``Responses To Commands'' below for details about how to read
this output safely.
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))
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index c304c8c47c..3668263c40 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3276,11 +3276,11 @@ cat >>W-input <<-W_INPUT_END
LFsget-mark :1
W_INPUT_END
-test_expect_failure !MINGW 'W: get-mark & empty orphan commit with no newlines' '
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with no newlines' '
sed -e s/LFs// W-input | tr L "\n" | git fast-import
'
-test_expect_failure !MINGW 'W: get-mark & empty orphan commit with one newline' '
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with one newline' '
sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
'
--
2.21.0.rc2.5.g8f70af2367
next prev parent reply other threads:[~2019-02-20 22:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 22:58 [RFC PATCH 0/5] Fix some fast-import parsing issues Elijah Newren
2019-02-20 22:58 ` [RFC PATCH 1/5] t9300: demonstrate bug with get-mark and empty orphan commits Elijah Newren
2019-02-20 22:58 ` [RFC PATCH 2/5] git-fast-import.txt: fix wording about where ls command can appear Elijah Newren
2019-02-20 22:58 ` [RFC PATCH 3/5] fast-import: check most prominent commands first Elijah Newren
2019-02-20 22:58 ` [RFC PATCH 4/5] fast-import: only allow cat-blob requests where it makes sense Elijah Newren
2019-02-20 22:58 ` Elijah Newren [this message]
2019-03-08 16:53 ` [RFC PATCH 0/5] Fix some fast-import parsing issues Elijah Newren
2019-04-01 10:44 ` Junio C Hamano
2019-04-01 15:52 ` Elijah Newren
2019-04-01 16:00 ` [PATCH v2 " Elijah Newren
2019-04-01 16:00 ` [PATCH v2 1/5] t9300: demonstrate bug with get-mark and empty orphan commits Elijah Newren
2019-04-01 16:00 ` [PATCH v2 2/5] git-fast-import.txt: fix wording about where ls command can appear Elijah Newren
2019-04-01 16:00 ` [PATCH v2 3/5] fast-import: check most prominent commands first Elijah Newren
2019-04-01 16:00 ` [PATCH v2 4/5] fast-import: only allow cat-blob requests where it makes sense Elijah Newren
2019-04-01 16:00 ` [PATCH v2 5/5] fast-import: fix erroneous handling of get-mark with empty orphan commits Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190220225846.10658-6-newren@gmail.com \
--to=newren@gmail.com \
--cc=david.barr@cordelta.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=mhagger@alum.mit.edu \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).