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

[RFC PATCH 1/5] t9300: demonstrate bug with get-mark and empty orphan commits

From
Elijah Newren <newren@gmail.com>
Date
Feb 20, 2019, 22:58 UTC
Message-ID
<20190220225846.10658-2-newren@gmail.com>
In-Reply-To
<20190220225846.10658-1-newren@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 Documentation/git-fast-import.txt |  7 +++++-
 t/t9300-fast-import.sh            | 37 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 43ab3b1637..339b6e7e98 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -422,7 +422,12 @@ However it is recommended that a `filedeleteall` command precede
 all `filemodify`, `filecopy`, `filerename` and `notemodify` commands in
 the same commit, as `filedeleteall` wipes the branch clean (see below).
 
-The `LF` after the command is optional (it used to be required).
+The `LF` after the command is optional (it used to be required).  Note
+that for reasons of backward compatibility, if the commit ends with a
+`data` command (i.e. it has has no `from`, `merge`, `filemodify`,
+`filedelete`, `filecopy`, `filerename`, `filedeleteall` or
+`notemodify` commands) then two `LF` commands may appear at the end of
+the command instead of just one.
 
 `author`
 ^^^^^^^^
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 59a13b6a77..c304c8c47c 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3262,4 +3262,41 @@ test_expect_success PIPE 'V: checkpoint updates tags after tag' '
 	background_import_still_running
 '
 
+###
+### series W (get-mark and empty orphan commits)
+###
+
+cat >>W-input <<-W_INPUT_END
+	commit refs/heads/W-branch
+	mark :1
+	author Full Name <user@company.tld> 1000000000 +0100
+	committer Full Name <user@company.tld> 1000000000 +0100
+	data 27
+	Intentionally empty commit
+	LFsget-mark :1
+	W_INPUT_END
+
+test_expect_failure !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' '
+	sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
+'
+
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
+	# Technically, this should fail as it has too many linefeeds
+	# according to the grammar in fast-import.txt.  But, for whatever
+	# reason, it works.  Since using the correct number of newlines
+	# does not work with older (pre-2.22) versions of git, allow apps
+	# that used this second-newline workaround to keep working by
+	# checking it with this test...
+	sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
+'
+
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
+	# ...but do NOT allow more empty lines than that (see previous test).
+	sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
+'
+
 test_done
-- 
2.21.0.rc2.5.g8f70af2367
Previous: Elijah NewrenNext: Elijah Newren
Message 6 of 15 in “Fix some fast-import parsing issues”
  1. 0/5 Fix some fast-import parsing issuesElijah Newren, Feb 20, 2019
  2. 5/5 fast-import: fix erroneous handling of get-mark with empty orphan commitsElijah Newren, Feb 20, 2019
  3. 2/5 git-fast-import.txt: fix wording about where ls command can appearElijah Newren, Feb 20, 2019
  4. 3/5 fast-import: check most prominent commands firstElijah Newren, Feb 20, 2019
  5. 4/5 fast-import: only allow cat-blob requests where it makes senseElijah Newren, Feb 20, 2019
  6. 1/5 t9300: demonstrate bug with get-mark and empty orphan commitsElijah Newren, Feb 20, 2019
  7. Elijah NewrenMar 8, 2019
  8. Junio C HamanoApr 1, 2019
  9. Elijah NewrenApr 1, 2019
  10. 0/5 Fix some fast-import parsing issuesElijah Newren, Apr 1, 2019
  11. 1/5 t9300: demonstrate bug with get-mark and empty orphan commitsElijah Newren, Apr 1, 2019
  12. 5/5 fast-import: fix erroneous handling of get-mark with empty orphan commitsElijah Newren, Apr 1, 2019
  13. 3/5 fast-import: check most prominent commands firstElijah Newren, Apr 1, 2019
  14. 4/5 fast-import: only allow cat-blob requests where it makes senseElijah Newren, Apr 1, 2019
  15. 2/5 git-fast-import.txt: fix wording about where ls command can appearElijah Newren, Apr 1, 2019

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.