{"thread":{"id":"12526","subject":"[fast-import] LF after reset not optional","startedAt":"2008-03-05T21:07:15Z","lastAt":"2008-03-08T02:12:10Z","messageCount":3,"participants":["Adeodato Simó","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"71126","messageId":"20080305210715.GA10686@chistera.yi.org","threadId":"12526","inReplyTo":null,"subject":"[fast-import] LF after reset not optional","fromName":"Adeodato Simó","fromEmail":"dato@net.com.org.es","sentAt":"2008-03-05T21:07:15Z","receivedAt":"2008-03-05T21:07:15Z","isPatch":false,"sender":{"key":"dato@net.com.org.es","avatar":"https://gravatar.com/avatar/952ec7d5d5663eb8baf631b5c37f9c58480a881920dd5f8a2d3a71f969b72b53?d=mp&s=160"},"body":"Hello.\n\nMaybe I'm doing something wrong, but I can't get the \"reset\" command to\nwork as advertised in git-fast-import(1), without an extra LF at the\nend.\n\nThis input:\n\n-8<-\ncommit refs/heads/master\nmark :1\ncommitter Joe R. Developer <joe@random.com> 1204726629 +0100\ndata <<EOF\nFirst commit.\nEOF\nM 644 inline foo.txt\ndata <<EOF\nHello, world!\nEOF\nreset refs/tags/tag1\nfrom :1\nreset refs/tags/tag2\nfrom :1\n-8<-\n\nfails with:\n\n  fatal: Unsupported command: from :1\n\nAdding an extra LF before the second reset fixes the issue. I tested\nthis issue seems to present in the \"next\" branch in addition to 1.5.4.3.\n\nCheers,\n\n-- \nAdeodato Simó                                     dato at net.com.org.es\nDebian Developer                                  adeodato at debian.org\n \n- I couldn't find anything in there for days. I kept reaching in for\n  strawberries and coming up with liver -- that's not pleasant.\n- I promise not to touch the fridge again.\n                -- Sookie and Lorelai\n\n"},{"id":"71375","messageId":"1204921337-5204-1-git-send-email-dato@net.com.org.es","threadId":"12526","inReplyTo":"20080305210715.GA10686@chistera.yi.org","subject":"[PATCH] Really make the LF after reset in fast-import optional","fromName":"Adeodato Simó","fromEmail":"dato@net.com.org.es","sentAt":"2008-03-07T20:22:17Z","receivedAt":"2008-03-07T20:22:17Z","isPatch":true,"sender":{"key":"dato@net.com.org.es","avatar":"https://gravatar.com/avatar/952ec7d5d5663eb8baf631b5c37f9c58480a881920dd5f8a2d3a71f969b72b53?d=mp&s=160"},"body":"cmd_from() ends with a call to read_next_command(), which is needed\nwhen using cmd_from() from commands where from is not the last element.\n\nWith reset, however, \"from\" is the last command, after which the flow\nreturns to the main loop, which calls read_next_command() again.\n\nBecause of this, always set unread_command_buf in cmd_reset_branch(),\neven if cmd_from() was successful.\n\nAdd a test case for this in t9300-fast-import.sh.\n\nSigned-off-by: Adeodato Simó <dato@net.com.org.es>\n---\n fast-import.c          |    3 ++-\n t/t9300-fast-import.sh |    2 ++\n 2 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/fast-import.c b/fast-import.c\nindex 7f197d5..655913d 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -2291,7 +2291,8 @@ static void cmd_reset_branch(void)\n \telse\n \t\tb = new_branch(sp);\n \tread_next_command();\n-\tif (!cmd_from(b) && command_buf.len > 0)\n+\tcmd_from(b);\n+\tif (command_buf.len > 0)\n \t\tunread_command_buf = 1;\n }\n \ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex cceedbb..c4f4465 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -869,6 +869,8 @@ zcommits\n COMMIT\n reset refs/tags/O3-2nd\n from :5\n+reset refs/tags/O3-3rd\n+from :5\n INPUT_END\n \n cat >expect <<INPUT_END\n-- \n1.5.4.3\n\n"},{"id":"71398","messageId":"20080308021210.GX8410@spearce.org","threadId":"12526","inReplyTo":"1204921337-5204-1-git-send-email-dato@net.com.org.es","subject":"Re: [PATCH] Really make the LF after reset in fast-import optional","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-03-08T02:12:10Z","receivedAt":"2008-03-08T02:12:10Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Adeodato Sim <dato@net.com.org.es> wrote:\n> cmd_from() ends with a call to read_next_command(), which is needed\n> when using cmd_from() from commands where from is not the last element.\n> \n> With reset, however, \"from\" is the last command, after which the flow\n> returns to the main loop, which calls read_next_command() again.\n> \n> Because of this, always set unread_command_buf in cmd_reset_branch(),\n> even if cmd_from() was successful.\n> \n> Add a test case for this in t9300-fast-import.sh.\n> \n> Signed-off-by: Adeodato Simó <dato@net.com.org.es>\n\nHeh, this is awesome.  I got busy for a day and someone fixed\nmy bug for me.  Thanks.  :-)\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n>  fast-import.c          |    3 ++-\n>  t/t9300-fast-import.sh |    2 ++\n>  2 files changed, 4 insertions(+), 1 deletions(-)\n\n-- \nShawn.\n"}]}