t / t7105-reset-patch.shon commit configure: Detect linking style for HP aCC on HP-UX (9a1699c)
   1#!/bin/sh
   2
   3test_description='git reset --patch'
   4. ./lib-patch-mode.sh
   5
   6test_expect_success PERL 'setup' '
   7        mkdir dir &&
   8        echo parent > dir/foo &&
   9        echo dummy > bar &&
  10        git add dir &&
  11        git commit -m initial &&
  12        test_tick &&
  13        test_commit second dir/foo head &&
  14        set_and_save_state bar bar_work bar_index &&
  15        save_head
  16'
  17
  18# note: bar sorts before foo, so the first 'n' is always to skip 'bar'
  19
  20test_expect_success PERL 'saying "n" does nothing' '
  21        set_and_save_state dir/foo work work &&
  22        test_write_lines n n | git reset -p &&
  23        verify_saved_state dir/foo &&
  24        verify_saved_state bar
  25'
  26
  27test_expect_success PERL 'git reset -p' '
  28        test_write_lines n y | git reset -p >output &&
  29        verify_state dir/foo work head &&
  30        verify_saved_state bar &&
  31        test_i18ngrep "Unstage" output
  32'
  33
  34test_expect_success PERL 'git reset -p HEAD^' '
  35        test_write_lines n y | git reset -p HEAD^ >output &&
  36        verify_state dir/foo work parent &&
  37        verify_saved_state bar &&
  38        test_i18ngrep "Apply" output
  39'
  40
  41# The idea in the rest is that bar sorts first, so we always say 'y'
  42# first and if the path limiter fails it'll apply to bar instead of
  43# dir/foo.  There's always an extra 'n' to reject edits to dir/foo in
  44# the failure case (and thus get out of the loop).
  45
  46test_expect_success PERL 'git reset -p dir' '
  47        set_state dir/foo work work &&
  48        test_write_lines y n | git reset -p dir &&
  49        verify_state dir/foo work head &&
  50        verify_saved_state bar
  51'
  52
  53test_expect_success PERL 'git reset -p -- foo (inside dir)' '
  54        set_state dir/foo work work &&
  55        test_write_lines y n | (cd dir && git reset -p -- foo) &&
  56        verify_state dir/foo work head &&
  57        verify_saved_state bar
  58'
  59
  60test_expect_success PERL 'git reset -p HEAD^ -- dir' '
  61        test_write_lines y n | git reset -p HEAD^ -- dir &&
  62        verify_state dir/foo work parent &&
  63        verify_saved_state bar
  64'
  65
  66test_expect_success PERL 'none of this moved HEAD' '
  67        verify_saved_head
  68'
  69
  70
  71test_done