t9300: demonstrate bug with get-mark and empty orphan commits
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 20, 2019 at 14:58 UTC
62edbec7dee0bc9788d60823ca074d7dfbb5a486
2 files changed
+43
-1
Documentation/git-fast-import.txt
+6
-1
@@ -422,7 +422,12 @@ However it is recommended that a `filedeleteall` command precede
422
all `filemodify`, `filecopy`, `filerename` and `notemodify` commands in
423
the same commit, as `filedeleteall` wipes the branch clean (see below).
424
425
-The `LF` after the command is optional (it used to be required).
425
+The `LF` after the command is optional (it used to be required). Note
426
+that for reasons of backward compatibility, if the commit ends with a
427
+`data` command (i.e. it has has no `from`, `merge`, `filemodify`,
428
+`filedelete`, `filecopy`, `filerename`, `filedeleteall` or
429
+`notemodify` commands) then two `LF` commands may appear at the end of
430
+the command instead of just one.
431
432
`author`
433
^^^^^^^^
t/t9300-fast-import.sh
+37
@@ -3262,4 +3262,41 @@ test_expect_success PIPE 'V: checkpoint updates tags after tag' '
3262
background_import_still_running
3263
'
3264
3265
+###
3266
+### series W (get-mark and empty orphan commits)
3267
+###
3268
+
3269
+cat >>W-input <<-W_INPUT_END
3270
+ commit refs/heads/W-branch
3271
+ mark :1
3272
+ author Full Name <user@company.tld> 1000000000 +0100
3273
+ committer Full Name <user@company.tld> 1000000000 +0100
3274
+ data 27
3275
+ Intentionally empty commit
3276
+ LFsget-mark :1
3277
+ W_INPUT_END
3278
+
3279
+test_expect_failure !MINGW 'W: get-mark & empty orphan commit with no newlines' '
3280
+ sed -e s/LFs// W-input | tr L "\n" | git fast-import
3281
+'
3282
+
3283
+test_expect_failure !MINGW 'W: get-mark & empty orphan commit with one newline' '
3284
+ sed -e s/LFs/L/ W-input | tr L "\n" | git fast-import
3285
+'
3286
+
3287
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with ugly second newline' '
3288
+ # Technically, this should fail as it has too many linefeeds
3289
+ # according to the grammar in fast-import.txt. But, for whatever
3290
+ # reason, it works. Since using the correct number of newlines
3291
+ # does not work with older (pre-2.22) versions of git, allow apps
3292
+ # that used this second-newline workaround to keep working by
3293
+ # checking it with this test...
3294
+ sed -e s/LFs/LL/ W-input | tr L "\n" | git fast-import
3295
+'
3296
+
3297
+test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous third newline' '
3298
+ # ...but do NOT allow more empty lines than that (see previous test).
3299
+ sed -e s/LFs/LLL/ W-input | tr L "\n" | test_must_fail git fast-import
3300
+'
3301
+
3302
test_done