Skip to content

Commit

Permalink
t9300: demonstrate bug with get-mark and empty orphan commits
Browse files Browse the repository at this point in the history
Signed-off-by: Elijah Newren <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
newren authored and gitster committed Apr 1, 2019
1 parent aeb582a commit 62edbec
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Documentation/git-fast-import.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`
^^^^^^^^
Expand Down
37 changes: 37 additions & 0 deletions t/t9300-fast-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> 1000000000 +0100
committer Full Name <[email protected]> 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

0 comments on commit 62edbec

Please sign in to comment.