Skip to content

Commit f0c7320

Browse files
Thomas Rastgitster
authored andcommitted
Test 'commit --only' after 'checkout --orphan'
There are some index handling subtleties in 'commit --only' that are best tested when we have an existing index, but an unborn or empty HEAD. These circumstances are easily produced by 'checkout --orphan', but we did not previously have a test for it. The main expected failure mode would be: erroneously loading the existing index contents when building the temporary index that is used for --only. Cf. http://article.gmane.org/gmane.comp.version-control.git/225969 and subsequent discussion. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 239222f commit f0c7320

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

t/t7501-commit.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,17 @@ test_expect_success 'commit a file whose name is a dash' '
524524
test_i18ngrep " changed, 5 insertions" output
525525
'
526526

527+
test_expect_success '--only works on to-be-born branch' '
528+
# This test relies on having something in the index, as it
529+
# would not otherwise actually prove much. So check this.
530+
test -n "$(git ls-files)" &&
531+
git checkout --orphan orphan &&
532+
echo foo >newfile &&
533+
git add newfile &&
534+
git commit --only newfile -m"--only on unborn branch" &&
535+
echo newfile >expected &&
536+
git ls-tree -r --name-only HEAD >actual &&
537+
test_cmp expected actual
538+
'
539+
527540
test_done

0 commit comments

Comments
 (0)