git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Really make the LF after reset in fast-import optional

From
Adeodato Simó <dato@net.com.org.es>
Date
Mar 7, 2008, 20:22 UTC
Message-ID
<1204921337-5204-1-git-send-email-dato@net.com.org.es>
In-Reply-To
<20080305210715.GA10686@chistera.yi.org>

cmd_from() ends with a call to read_next_command(), which is needed when using cmd_from() from commands where from is not the last element.

With reset, however, "from" is the last command, after which the flow returns to the main loop, which calls read_next_command() again.

Because of this, always set unread_command_buf in cmd_reset_branch(), even if cmd_from() was successful.

Add a test case for this in t9300-fast-import.sh.
Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---
 fast-import.c          |    3 ++-
 t/t9300-fast-import.sh |    2 ++
 2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7f197d5..655913d 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2291,7 +2291,8 @@ static void cmd_reset_branch(void)
 	else
 		b = new_branch(sp);
 	read_next_command();
-	if (!cmd_from(b) && command_buf.len > 0)
+	cmd_from(b);
+	if (command_buf.len > 0)
 		unread_command_buf = 1;
 }
 
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index cceedbb..c4f4465 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -869,6 +869,8 @@ zcommits
 COMMIT
 reset refs/tags/O3-2nd
 from :5
+reset refs/tags/O3-3rd
+from :5
 INPUT_END
 
 cat >expect <<INPUT_END
-- 
1.5.4.3
Previous: Adeodato SimóNext: Shawn O. Pearce
Message 2 of 3 in “[fast-import] LF after reset not optional”
  1. Adeodato SimóMar 5, 2008
  2. Really make the LF after reset in fast-import optionalAdeodato Simó, Mar 7, 2008
  3. Shawn O. PearceMar 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.