t / t3428-rebase-signoff.shon commit Merge branch 'sb/more-repo-in-api' into md/list-objects-filter-by-depth (b9fbc04)
   1#!/bin/sh
   2
   3test_description='git rebase --signoff
   4
   5This test runs git rebase --signoff and make sure that it works.
   6'
   7
   8. ./test-lib.sh
   9
  10# A simple file to commit
  11cat >file <<EOF
  12a
  13EOF
  14
  15# Expected commit message for initial commit after rebase --signoff
  16cat >expected-initial-signed <<EOF
  17Initial empty commit
  18
  19Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
  20EOF
  21
  22# Expected commit message after rebase --signoff
  23cat >expected-signed <<EOF
  24first
  25
  26Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
  27EOF
  28
  29# Expected commit message after rebase without --signoff (or with --no-signoff)
  30cat >expected-unsigned <<EOF
  31first
  32EOF
  33
  34
  35# We configure an alias to do the rebase --signoff so that
  36# on the next subtest we can show that --no-signoff overrides the alias
  37test_expect_success 'rebase --signoff adds a sign-off line' '
  38        git commit --allow-empty -m "Initial empty commit" &&
  39        git add file && git commit -m first &&
  40        git config alias.rbs "rebase --signoff" &&
  41        git rbs HEAD^ &&
  42        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
  43        test_cmp expected-signed actual
  44'
  45
  46test_expect_success 'rebase --no-signoff does not add a sign-off line' '
  47        git commit --amend -m "first" &&
  48        git rbs --no-signoff HEAD^ &&
  49        git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
  50        test_cmp expected-unsigned actual
  51'
  52
  53test_expect_success 'rebase --exec --signoff adds a sign-off line' '
  54        test_when_finished "rm exec" &&
  55        git commit --amend -m "first" &&
  56        git rebase --exec "touch exec" --signoff HEAD^ &&
  57        test_path_is_file exec &&
  58        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
  59        test_cmp expected-signed actual
  60'
  61
  62test_expect_success 'rebase --root --signoff adds a sign-off line' '
  63        git commit --amend -m "first" &&
  64        git rebase --root --keep-empty --signoff &&
  65        git cat-file commit HEAD^ | sed -e "1,/^\$/d" >actual &&
  66        test_cmp expected-initial-signed actual &&
  67        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
  68        test_cmp expected-signed actual
  69'
  70
  71test_expect_success 'rebase -i --signoff fails' '
  72        git commit --amend -m "first" &&
  73        git rebase -i --signoff HEAD^ &&
  74        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
  75        test_cmp expected-signed actual
  76'
  77
  78test_expect_success 'rebase -m --signoff fails' '
  79        git commit --amend -m "first" &&
  80        git rebase -m --signoff HEAD^ &&
  81        git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
  82        test_cmp expected-signed actual
  83'
  84test_done