t / t3505-cherry-pick-empty.shon commit git p4: notice Jobs lines in git commit messages (f19cb0a)
   1#!/bin/sh
   2
   3test_description='test cherry-picking an empty commit'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8
   9        echo first > file1 &&
  10        git add file1 &&
  11        test_tick &&
  12        git commit -m "first" &&
  13
  14        git checkout -b empty-branch &&
  15        test_tick &&
  16        git commit --allow-empty -m "empty" &&
  17
  18        echo third >> file1 &&
  19        git add file1 &&
  20        test_tick &&
  21        git commit --allow-empty-message -m "" &&
  22
  23        git checkout master &&
  24        git checkout -b empty-branch2 &&
  25        test_tick &&
  26        git commit --allow-empty -m "empty"
  27
  28'
  29
  30test_expect_success 'cherry-pick an empty commit' '
  31        git checkout master && {
  32                git cherry-pick empty-branch^
  33                test "$?" = 1
  34        }
  35'
  36
  37test_expect_success 'index lockfile was removed' '
  38
  39        test ! -f .git/index.lock
  40
  41'
  42
  43test_expect_success 'cherry-pick a commit with an empty message' '
  44        git checkout master && {
  45                git cherry-pick empty-branch
  46                test "$?" = 1
  47        }
  48'
  49
  50test_expect_success 'index lockfile was removed' '
  51
  52        test ! -f .git/index.lock
  53
  54'
  55
  56test_expect_success 'cherry pick an empty non-ff commit without --allow-empty' '
  57        git checkout master &&
  58        echo fourth >>file2 &&
  59        git add file2 &&
  60        git commit -m "fourth" &&
  61        test_must_fail git cherry-pick empty-branch2
  62'
  63
  64test_expect_success 'cherry pick an empty non-ff commit with --allow-empty' '
  65        git checkout master &&
  66        git cherry-pick --allow-empty empty-branch2
  67'
  68
  69test_expect_success 'cherry pick with --keep-redundant-commits' '
  70        git checkout master &&
  71        git cherry-pick --keep-redundant-commits HEAD^
  72'
  73
  74test_expect_success 'cherry-pick a commit that becomes no-op (prep)' '
  75        git checkout master &&
  76        git branch fork &&
  77        echo foo >file2 &&
  78        git add file2 &&
  79        test_tick &&
  80        git commit -m "add file2 on master" &&
  81
  82        git checkout fork &&
  83        echo foo >file2 &&
  84        git add file2 &&
  85        test_tick &&
  86        git commit -m "add file2 on the side"
  87'
  88
  89test_expect_success 'cherry-pick a no-op without --keep-redundant' '
  90        git reset --hard &&
  91        git checkout fork^0 &&
  92        test_must_fail git cherry-pick master
  93'
  94
  95test_expect_success 'cherry-pick a no-op with --keep-redundant' '
  96        git reset --hard &&
  97        git checkout fork^0 &&
  98        git cherry-pick --keep-redundant-commits master &&
  99        git show -s --format='%s' >actual &&
 100        echo "add file2 on master" >expect &&
 101        test_cmp expect actual
 102'
 103
 104test_done