Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com> |
| 4 | # |
| 5 | |
| 6 | # FIXME: Test the various index usages, -i and -o, test reflog, |
Wincent Colaiuta | 264474f | 2007-12-08 13:29:47 +0100 | [diff] [blame] | 7 | # signoff |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 8 | |
Nanako Shiraishi | 47a528a | 2008-09-03 17:59:33 +0900 | [diff] [blame] | 9 | test_description='git commit' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 10 | . ./test-lib.sh |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 11 | . "$TEST_DIRECTORY/diff-lib.sh" |
| 12 | |
| 13 | author='The Real Author <someguy@his.email.org>' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 14 | |
| 15 | test_tick |
| 16 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 17 | test_expect_success 'initial status' ' |
| 18 | echo bongo bongo >file && |
| 19 | git add file && |
Junio C Hamano | 32177ba | 2011-04-13 16:17:29 -0700 | [diff] [blame] | 20 | git status >actual && |
Kaartic Sivaraam | 4ddb135 | 2017-06-21 23:46:14 +0530 | [diff] [blame] | 21 | test_i18ngrep "No commits yet" actual |
Junio C Hamano | 32177ba | 2011-04-13 16:17:29 -0700 | [diff] [blame] | 22 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 23 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 24 | test_expect_success 'fail initial amend' ' |
| 25 | test_must_fail git commit --amend |
| 26 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 27 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 28 | test_expect_success 'setup: initial commit' ' |
| 29 | git commit -m initial |
| 30 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 31 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 32 | test_expect_success '-m and -F do not mix' ' |
Junio C Hamano | c65dc35 | 2012-03-30 11:04:08 -0700 | [diff] [blame] | 33 | git checkout HEAD file && echo >>file && git add file && |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 34 | test_must_fail git commit -m foo -m bar -F file |
| 35 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 36 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 37 | test_expect_success '-m and -C do not mix' ' |
Junio C Hamano | c65dc35 | 2012-03-30 11:04:08 -0700 | [diff] [blame] | 38 | git checkout HEAD file && echo >>file && git add file && |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 39 | test_must_fail git commit -C HEAD -m illegal |
| 40 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 41 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 42 | test_expect_success 'paths and -a do not mix' ' |
| 43 | echo King of the bongo >file && |
| 44 | test_must_fail git commit -m foo -a file |
| 45 | ' |
Björn Steinbrink | 9d87442 | 2007-11-12 16:15:39 +0100 | [diff] [blame] | 46 | |
Conrad Irwin | e41fcfe | 2011-05-06 23:00:00 -0700 | [diff] [blame] | 47 | test_expect_success PERL 'can use paths with --interactive' ' |
Jeff King | 587ac8c | 2011-05-09 16:53:00 -0700 | [diff] [blame] | 48 | echo bong-o-bong >file && |
| 49 | # 2: update, 1:st path, that is all, 7: quit |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 50 | test_write_lines 2 1 "" 7 | |
Conrad Irwin | e41fcfe | 2011-05-06 23:00:00 -0700 | [diff] [blame] | 51 | git commit -m foo --interactive file && |
| 52 | git reset --hard HEAD^ |
Jeff King | 587ac8c | 2011-05-09 16:53:00 -0700 | [diff] [blame] | 53 | ' |
Björn Steinbrink | 9d87442 | 2007-11-12 16:15:39 +0100 | [diff] [blame] | 54 | |
Brandon Williams | 86238e0 | 2018-04-03 10:57:45 -0700 | [diff] [blame] | 55 | test_expect_success 'removed files and relative paths' ' |
| 56 | test_when_finished "rm -rf foo" && |
| 57 | git init foo && |
| 58 | >foo/foo.txt && |
| 59 | git -C foo add foo.txt && |
| 60 | git -C foo commit -m first && |
| 61 | git -C foo rm foo.txt && |
| 62 | |
| 63 | mkdir -p foo/bar && |
| 64 | git -C foo/bar commit -m second ../foo.txt |
| 65 | ' |
| 66 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 67 | test_expect_success 'using invalid commit with -C' ' |
Kacper Kornet | 0bb0c15 | 2013-08-24 06:01:44 +0200 | [diff] [blame] | 68 | test_must_fail git commit --allow-empty -C bogus |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 69 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 70 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 71 | test_expect_success 'nothing to commit' ' |
Jeff King | 088304b | 2014-01-23 14:54:57 -0500 | [diff] [blame] | 72 | git reset --hard && |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 73 | test_must_fail git commit -m initial |
| 74 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 75 | |
Tay Ray Chuan | 9cbcc2a | 2014-02-22 03:16:54 +0800 | [diff] [blame] | 76 | test_expect_success '--dry-run fails with nothing to commit' ' |
| 77 | test_must_fail git commit -m initial --dry-run |
| 78 | ' |
| 79 | |
| 80 | test_expect_success '--short fails with nothing to commit' ' |
| 81 | test_must_fail git commit -m initial --short |
| 82 | ' |
| 83 | |
| 84 | test_expect_success '--porcelain fails with nothing to commit' ' |
| 85 | test_must_fail git commit -m initial --porcelain |
| 86 | ' |
| 87 | |
| 88 | test_expect_success '--long fails with nothing to commit' ' |
| 89 | test_must_fail git commit -m initial --long |
| 90 | ' |
| 91 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 92 | test_expect_success 'setup: non-initial commit' ' |
| 93 | echo bongo bongo bongo >file && |
| 94 | git commit -m next -a |
| 95 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 96 | |
Tay Ray Chuan | 9cbcc2a | 2014-02-22 03:16:54 +0800 | [diff] [blame] | 97 | test_expect_success '--dry-run with stuff to commit returns ok' ' |
| 98 | echo bongo bongo bongo >>file && |
| 99 | git commit -m next -a --dry-run |
| 100 | ' |
| 101 | |
Stephen P. Smith | f3bd35f | 2018-09-05 17:53:29 -0700 | [diff] [blame] | 102 | test_expect_success '--short with stuff to commit returns ok' ' |
Tay Ray Chuan | 9cbcc2a | 2014-02-22 03:16:54 +0800 | [diff] [blame] | 103 | echo bongo bongo bongo >>file && |
| 104 | git commit -m next -a --short |
| 105 | ' |
| 106 | |
Stephen P. Smith | f3bd35f | 2018-09-05 17:53:29 -0700 | [diff] [blame] | 107 | test_expect_success '--porcelain with stuff to commit returns ok' ' |
Tay Ray Chuan | 9cbcc2a | 2014-02-22 03:16:54 +0800 | [diff] [blame] | 108 | echo bongo bongo bongo >>file && |
| 109 | git commit -m next -a --porcelain |
| 110 | ' |
| 111 | |
| 112 | test_expect_success '--long with stuff to commit returns ok' ' |
| 113 | echo bongo bongo bongo >>file && |
| 114 | git commit -m next -a --long |
| 115 | ' |
| 116 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 117 | test_expect_success 'commit message from non-existing file' ' |
| 118 | echo more bongo: bongo bongo bongo bongo >file && |
| 119 | test_must_fail git commit -F gah -a |
| 120 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 121 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 122 | test_expect_success 'empty commit message' ' |
| 123 | # Empty except stray tabs and spaces on a few lines. |
| 124 | sed -e "s/@//g" >msg <<-\EOF && |
| 125 | @ @ |
| 126 | @@ |
| 127 | @ @ |
| 128 | @Signed-off-by: hula@ |
| 129 | EOF |
| 130 | test_must_fail git commit -F msg -a |
| 131 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 132 | |
Junio C Hamano | 010c7db | 2012-03-30 11:30:59 -0700 | [diff] [blame] | 133 | test_expect_success 'template "emptyness" check does not kick in with -F' ' |
| 134 | git checkout HEAD file && echo >>file && git add file && |
| 135 | git commit -t file -F file |
| 136 | ' |
| 137 | |
Junio C Hamano | b2eda9b | 2012-03-30 12:14:33 -0700 | [diff] [blame] | 138 | test_expect_success 'template "emptyness" check' ' |
| 139 | git checkout HEAD file && echo >>file && git add file && |
| 140 | test_must_fail git commit -t file 2>err && |
| 141 | test_i18ngrep "did not edit" err |
| 142 | ' |
| 143 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 144 | test_expect_success 'setup: commit message from file' ' |
Junio C Hamano | 010c7db | 2012-03-30 11:30:59 -0700 | [diff] [blame] | 145 | git checkout HEAD file && echo >>file && git add file && |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 146 | echo this is the commit message, coming from a file >msg && |
| 147 | git commit -F msg -a |
| 148 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 149 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 150 | test_expect_success 'amend commit' ' |
| 151 | cat >editor <<-\EOF && |
| 152 | #!/bin/sh |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 153 | sed -e "s/a file/an amend commit/g" <"$1" >"$1-" |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 154 | mv "$1-" "$1" |
| 155 | EOF |
| 156 | chmod 755 editor && |
| 157 | EDITOR=./editor git commit --amend |
| 158 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 159 | |
Jeff King | ea2d4ed | 2012-07-10 16:40:29 -0400 | [diff] [blame] | 160 | test_expect_success 'amend --only ignores staged contents' ' |
| 161 | cp file file.expect && |
| 162 | echo changed >file && |
| 163 | git add file && |
| 164 | git commit --no-edit --amend --only && |
| 165 | git cat-file blob HEAD:file >file.actual && |
| 166 | test_cmp file.expect file.actual && |
| 167 | git diff --exit-code |
| 168 | ' |
| 169 | |
Andreas Krey | 319d835 | 2016-12-02 23:15:13 +0100 | [diff] [blame] | 170 | test_expect_success 'allow-empty --only ignores staged contents' ' |
| 171 | echo changed-again >file && |
| 172 | git add file && |
| 173 | git commit --allow-empty --only -m "empty" && |
| 174 | git cat-file blob HEAD:file >file.actual && |
| 175 | test_cmp file.expect file.actual && |
| 176 | git diff --exit-code |
| 177 | ' |
| 178 | |
Jonathan Nieder | bc82189 | 2011-12-07 08:54:14 -0600 | [diff] [blame] | 179 | test_expect_success 'set up editor' ' |
| 180 | cat >editor <<-\EOF && |
| 181 | #!/bin/sh |
| 182 | sed -e "s/unamended/amended/g" <"$1" >"$1-" |
| 183 | mv "$1-" "$1" |
| 184 | EOF |
| 185 | chmod 755 editor |
| 186 | ' |
| 187 | |
| 188 | test_expect_success 'amend without launching editor' ' |
| 189 | echo unamended >expect && |
| 190 | git commit --allow-empty -m "unamended" && |
| 191 | echo needs more bongo >file && |
| 192 | git add file && |
| 193 | EDITOR=./editor git commit --no-edit --amend && |
| 194 | git diff --exit-code HEAD -- file && |
| 195 | git diff-tree -s --format=%s HEAD >msg && |
| 196 | test_cmp expect msg |
| 197 | ' |
| 198 | |
| 199 | test_expect_success '--amend --edit' ' |
| 200 | echo amended >expect && |
| 201 | git commit --allow-empty -m "unamended" && |
| 202 | echo bongo again >file && |
| 203 | git add file && |
| 204 | EDITOR=./editor git commit --edit --amend && |
| 205 | git diff-tree -s --format=%s HEAD >msg && |
| 206 | test_cmp expect msg |
| 207 | ' |
| 208 | |
Chris Webb | d9a9357 | 2012-07-09 19:53:26 +0100 | [diff] [blame] | 209 | test_expect_success '--amend --edit of empty message' ' |
| 210 | cat >replace <<-\EOF && |
| 211 | #!/bin/sh |
| 212 | echo "amended" >"$1" |
| 213 | EOF |
| 214 | chmod 755 replace && |
| 215 | git commit --allow-empty --allow-empty-message -m "" && |
| 216 | echo more bongo >file && |
| 217 | git add file && |
| 218 | EDITOR=./replace git commit --edit --amend && |
| 219 | git diff-tree -s --format=%s HEAD >msg && |
| 220 | ./replace expect && |
| 221 | test_cmp expect msg |
| 222 | ' |
| 223 | |
Jeff King | 27014cb | 2016-04-07 12:56:26 -0700 | [diff] [blame] | 224 | test_expect_success '--amend to set message to empty' ' |
| 225 | echo bata >file && |
Adam Dinwoodie | 178e814 | 2016-04-06 18:15:03 +0100 | [diff] [blame] | 226 | git add file && |
| 227 | git commit -m "unamended" && |
| 228 | git commit --amend --allow-empty-message -m "" && |
| 229 | git diff-tree -s --format=%s HEAD >msg && |
| 230 | echo "" >expect && |
| 231 | test_cmp expect msg |
| 232 | ' |
| 233 | |
Jeff King | 27014cb | 2016-04-07 12:56:26 -0700 | [diff] [blame] | 234 | test_expect_success '--amend to set empty message needs --allow-empty-message' ' |
Adam Dinwoodie | 178e814 | 2016-04-06 18:15:03 +0100 | [diff] [blame] | 235 | echo conga >file && |
| 236 | git add file && |
| 237 | git commit -m "unamended" && |
| 238 | test_must_fail git commit --amend -m "" && |
| 239 | git diff-tree -s --format=%s HEAD >msg && |
| 240 | echo "unamended" >expect && |
| 241 | test_cmp expect msg |
| 242 | ' |
| 243 | |
Jonathan Nieder | bc82189 | 2011-12-07 08:54:14 -0600 | [diff] [blame] | 244 | test_expect_success '-m --edit' ' |
| 245 | echo amended >expect && |
| 246 | git commit --allow-empty -m buffer && |
| 247 | echo bongo bongo >file && |
| 248 | git add file && |
| 249 | EDITOR=./editor git commit -m unamended --edit && |
| 250 | git diff-tree -s --format=%s HEAD >msg && |
| 251 | test_cmp expect msg |
| 252 | ' |
| 253 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 254 | test_expect_success '-m and -F do not mix' ' |
| 255 | echo enough with the bongos >file && |
| 256 | test_must_fail git commit -F msg -m amending . |
| 257 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 258 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 259 | test_expect_success 'using message from other commit' ' |
| 260 | git commit -C HEAD^ . |
| 261 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 262 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 263 | test_expect_success 'editing message from other commit' ' |
| 264 | cat >editor <<-\EOF && |
| 265 | #!/bin/sh |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 266 | sed -e "s/amend/older/g" <"$1" >"$1-" |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 267 | mv "$1-" "$1" |
| 268 | EOF |
| 269 | chmod 755 editor && |
| 270 | echo hula hula >file && |
| 271 | EDITOR=./editor git commit -c HEAD^ -a |
| 272 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 273 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 274 | test_expect_success 'message from stdin' ' |
| 275 | echo silly new contents >file && |
| 276 | echo commit message from stdin | |
| 277 | git commit -F - -a |
| 278 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 279 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 280 | test_expect_success 'overriding author from command line' ' |
| 281 | echo gak >file && |
| 282 | git commit -m author \ |
| 283 | --author "Rubber Duck <rduck@convoy.org>" -a >output 2>&1 && |
| 284 | grep Rubber.Duck output |
| 285 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 286 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 287 | test_expect_success PERL 'interactive add' ' |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 288 | echo 7 | test_must_fail git commit --interactive >out && |
| 289 | grep "What now" out |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 290 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 291 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 292 | test_expect_success PERL "commit --interactive doesn't change index if editor aborts" ' |
| 293 | echo zoo >file && |
Conrad Irwin | 02a481f | 2011-05-10 12:12:31 -0700 | [diff] [blame] | 294 | test_must_fail git diff --exit-code >diff1 && |
Eric Sunshine | 0590ff2 | 2018-07-01 20:23:42 -0400 | [diff] [blame] | 295 | test_write_lines u "*" q | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 296 | ( |
| 297 | EDITOR=: && |
| 298 | export EDITOR && |
| 299 | test_must_fail git commit --interactive |
| 300 | ) && |
Conrad Irwin | 02a481f | 2011-05-10 12:12:31 -0700 | [diff] [blame] | 301 | git diff >diff2 && |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 302 | compare_diff_patch diff1 diff2 |
| 303 | ' |
Conrad Irwin | 02a481f | 2011-05-10 12:12:31 -0700 | [diff] [blame] | 304 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 305 | test_expect_success 'editor not invoked if -F is given' ' |
| 306 | cat >editor <<-\EOF && |
| 307 | #!/bin/sh |
| 308 | sed -e s/good/bad/g <"$1" >"$1-" |
| 309 | mv "$1-" "$1" |
| 310 | EOF |
| 311 | chmod 755 editor && |
Adeodato Simó | 7eb5bbd | 2009-01-09 18:30:05 +0100 | [diff] [blame] | 312 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 313 | echo A good commit message. >msg && |
| 314 | echo moo >file && |
Adeodato Simó | 7eb5bbd | 2009-01-09 18:30:05 +0100 | [diff] [blame] | 315 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 316 | EDITOR=./editor git commit -a -F msg && |
| 317 | git show -s --pretty=format:%s >subject && |
| 318 | grep -q good subject && |
| 319 | |
| 320 | echo quack >file && |
| 321 | echo Another good message. | |
| 322 | EDITOR=./editor git commit -a -F - && |
| 323 | git show -s --pretty=format:%s >subject && |
| 324 | grep -q good subject |
| 325 | ' |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 326 | |
Junio C Hamano | db33af0 | 2007-09-14 16:53:58 -0700 | [diff] [blame] | 327 | test_expect_success 'partial commit that involves removal (1)' ' |
Junio C Hamano | 80bffaf | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 328 | |
| 329 | git rm --cached file && |
| 330 | mv file elif && |
| 331 | git add elif && |
| 332 | git commit -m "Partial: add elif" elif && |
| 333 | git diff-tree --name-status HEAD^ HEAD >current && |
| 334 | echo "A elif" >expected && |
Miklos Vajna | 1e36868 | 2008-09-10 19:32:44 +0200 | [diff] [blame] | 335 | test_cmp expected current |
Junio C Hamano | 80bffaf | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 336 | |
| 337 | ' |
| 338 | |
Junio C Hamano | db33af0 | 2007-09-14 16:53:58 -0700 | [diff] [blame] | 339 | test_expect_success 'partial commit that involves removal (2)' ' |
Junio C Hamano | 80bffaf | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 340 | |
| 341 | git commit -m "Partial: remove file" file && |
| 342 | git diff-tree --name-status HEAD^ HEAD >current && |
| 343 | echo "D file" >expected && |
Miklos Vajna | 1e36868 | 2008-09-10 19:32:44 +0200 | [diff] [blame] | 344 | test_cmp expected current |
Junio C Hamano | 80bffaf | 2007-09-12 16:04:22 -0700 | [diff] [blame] | 345 | |
| 346 | ' |
| 347 | |
Junio C Hamano | db33af0 | 2007-09-14 16:53:58 -0700 | [diff] [blame] | 348 | test_expect_success 'partial commit that involves removal (3)' ' |
| 349 | |
| 350 | git rm --cached elif && |
| 351 | echo elif >elif && |
| 352 | git commit -m "Partial: modify elif" elif && |
| 353 | git diff-tree --name-status HEAD^ HEAD >current && |
| 354 | echo "M elif" >expected && |
Miklos Vajna | 1e36868 | 2008-09-10 19:32:44 +0200 | [diff] [blame] | 355 | test_cmp expected current |
Junio C Hamano | db33af0 | 2007-09-14 16:53:58 -0700 | [diff] [blame] | 356 | |
| 357 | ' |
| 358 | |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 359 | test_expect_success 'amend commit to fix author' ' |
| 360 | |
| 361 | oldtick=$GIT_AUTHOR_DATE && |
| 362 | test_tick && |
| 363 | git reset --hard && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 364 | git cat-file -p HEAD >commit && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 365 | sed -e "s/author.*/author $author $oldtick/" \ |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 366 | -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ |
| 367 | commit >expected && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 368 | git commit --amend --author="$author" && |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 369 | git cat-file -p HEAD >current && |
Miklos Vajna | 1e36868 | 2008-09-10 19:32:44 +0200 | [diff] [blame] | 370 | test_cmp expected current |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 371 | |
| 372 | ' |
| 373 | |
Miklos Vajna | 02b47cd | 2009-12-02 23:16:18 +0100 | [diff] [blame] | 374 | test_expect_success 'amend commit to fix date' ' |
| 375 | |
| 376 | test_tick && |
| 377 | newtick=$GIT_AUTHOR_DATE && |
| 378 | git reset --hard && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 379 | git cat-file -p HEAD >commit && |
Miklos Vajna | 02b47cd | 2009-12-02 23:16:18 +0100 | [diff] [blame] | 380 | sed -e "s/author.*/author $author $newtick/" \ |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 381 | -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ |
| 382 | commit >expected && |
Miklos Vajna | 02b47cd | 2009-12-02 23:16:18 +0100 | [diff] [blame] | 383 | git commit --amend --date="$newtick" && |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 384 | git cat-file -p HEAD >current && |
Miklos Vajna | 02b47cd | 2009-12-02 23:16:18 +0100 | [diff] [blame] | 385 | test_cmp expected current |
| 386 | |
| 387 | ' |
| 388 | |
Jeff King | b7242b8 | 2014-05-01 21:10:01 -0400 | [diff] [blame] | 389 | test_expect_success 'commit mentions forced date in output' ' |
| 390 | git commit --amend --date=2010-01-02T03:04:05 >output && |
| 391 | grep "Date: *Sat Jan 2 03:04:05 2010" output |
| 392 | ' |
| 393 | |
Jeff King | 14ac286 | 2014-05-01 21:12:42 -0400 | [diff] [blame] | 394 | test_expect_success 'commit complains about completely bogus dates' ' |
| 395 | test_must_fail git commit --amend --date=seventeen |
| 396 | ' |
| 397 | |
| 398 | test_expect_success 'commit --date allows approxidate' ' |
| 399 | git commit --amend \ |
| 400 | --date="midnight the 12th of october, anno domini 1979" && |
| 401 | echo "Fri Oct 12 00:00:00 1979 +0000" >expect && |
| 402 | git log -1 --format=%ad >actual && |
| 403 | test_cmp expect actual |
Jeff King | 4579bb4 | 2010-12-13 12:02:25 -0500 | [diff] [blame] | 404 | ' |
| 405 | |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 406 | test_expect_success 'sign off (1)' ' |
| 407 | |
| 408 | echo 1 >positive && |
| 409 | git add positive && |
| 410 | git commit -s -m "thank you" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 411 | git cat-file commit HEAD >commit && |
| 412 | sed -e "1,/^\$/d" commit >actual && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 413 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 414 | echo thank you && |
| 415 | echo && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 416 | git var GIT_COMMITTER_IDENT >ident && |
| 417 | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 418 | ) >expected && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 419 | test_cmp expected actual |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 420 | |
| 421 | ' |
| 422 | |
| 423 | test_expect_success 'sign off (2)' ' |
| 424 | |
| 425 | echo 2 >positive && |
| 426 | git add positive && |
| 427 | existing="Signed-off-by: Watch This <watchthis@example.com>" && |
| 428 | git commit -s -m "thank you |
| 429 | |
| 430 | $existing" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 431 | git cat-file commit HEAD >commit && |
| 432 | sed -e "1,/^\$/d" commit >actual && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 433 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 434 | echo thank you && |
| 435 | echo && |
| 436 | echo $existing && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 437 | git var GIT_COMMITTER_IDENT >ident && |
| 438 | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 439 | ) >expected && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 440 | test_cmp expected actual |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 441 | |
| 442 | ' |
| 443 | |
David Brown | c1e01b0 | 2009-10-28 10:13:44 -0700 | [diff] [blame] | 444 | test_expect_success 'signoff gap' ' |
| 445 | |
| 446 | echo 3 >positive && |
| 447 | git add positive && |
| 448 | alt="Alt-RFC-822-Header: Value" && |
| 449 | git commit -s -m "welcome |
| 450 | |
| 451 | $alt" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 452 | git cat-file commit HEAD >commit && |
| 453 | sed -e "1,/^\$/d" commit >actual && |
David Brown | c1e01b0 | 2009-10-28 10:13:44 -0700 | [diff] [blame] | 454 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 455 | echo welcome && |
| 456 | echo && |
| 457 | echo $alt && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 458 | git var GIT_COMMITTER_IDENT >ident && |
| 459 | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident |
David Brown | c1e01b0 | 2009-10-28 10:13:44 -0700 | [diff] [blame] | 460 | ) >expected && |
| 461 | test_cmp expected actual |
| 462 | ' |
| 463 | |
| 464 | test_expect_success 'signoff gap 2' ' |
| 465 | |
| 466 | echo 4 >positive && |
| 467 | git add positive && |
| 468 | alt="fixed: 34" && |
| 469 | git commit -s -m "welcome |
| 470 | |
| 471 | We have now |
| 472 | $alt" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 473 | git cat-file commit HEAD >commit && |
| 474 | sed -e "1,/^\$/d" commit >actual && |
David Brown | c1e01b0 | 2009-10-28 10:13:44 -0700 | [diff] [blame] | 475 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 476 | echo welcome && |
| 477 | echo && |
| 478 | echo We have now && |
| 479 | echo $alt && |
| 480 | echo && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 481 | git var GIT_COMMITTER_IDENT >ident && |
| 482 | sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident |
David Brown | c1e01b0 | 2009-10-28 10:13:44 -0700 | [diff] [blame] | 483 | ) >expected && |
| 484 | test_cmp expected actual |
| 485 | ' |
| 486 | |
Jonathan Tan | 967dfd4 | 2016-11-02 10:29:20 -0700 | [diff] [blame] | 487 | test_expect_success 'signoff respects trailer config' ' |
| 488 | |
| 489 | echo 5 >positive && |
| 490 | git add positive && |
| 491 | git commit -s -m "subject |
| 492 | |
| 493 | non-trailer line |
| 494 | Myfooter: x" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 495 | git cat-file commit HEAD >commit && |
| 496 | sed -e "1,/^\$/d" commit >actual && |
Jonathan Tan | 967dfd4 | 2016-11-02 10:29:20 -0700 | [diff] [blame] | 497 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 498 | echo subject && |
| 499 | echo && |
| 500 | echo non-trailer line && |
| 501 | echo Myfooter: x && |
| 502 | echo && |
Jonathan Tan | 967dfd4 | 2016-11-02 10:29:20 -0700 | [diff] [blame] | 503 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" |
| 504 | ) >expected && |
| 505 | test_cmp expected actual && |
| 506 | |
| 507 | echo 6 >positive && |
| 508 | git add positive && |
| 509 | git -c "trailer.Myfooter.ifexists=add" commit -s -m "subject |
| 510 | |
| 511 | non-trailer line |
| 512 | Myfooter: x" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 513 | git cat-file commit HEAD >commit && |
| 514 | sed -e "1,/^\$/d" commit >actual && |
Jonathan Tan | 967dfd4 | 2016-11-02 10:29:20 -0700 | [diff] [blame] | 515 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 516 | echo subject && |
| 517 | echo && |
| 518 | echo non-trailer line && |
| 519 | echo Myfooter: x && |
Jonathan Tan | 967dfd4 | 2016-11-02 10:29:20 -0700 | [diff] [blame] | 520 | echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" |
| 521 | ) >expected && |
| 522 | test_cmp expected actual |
| 523 | ' |
| 524 | |
Jeff King | ffce7f5 | 2018-08-22 20:50:37 -0400 | [diff] [blame] | 525 | test_expect_success 'signoff not confused by ---' ' |
| 526 | cat >expected <<-EOF && |
| 527 | subject |
| 528 | |
| 529 | body |
| 530 | --- |
| 531 | these dashes confuse the parser! |
| 532 | |
| 533 | Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> |
| 534 | EOF |
| 535 | # should be a noop, since we already signed |
| 536 | git commit --allow-empty --signoff -F expected && |
| 537 | git log -1 --pretty=format:%B >actual && |
| 538 | test_cmp expected actual |
| 539 | ' |
| 540 | |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 541 | test_expect_success 'multiple -m' ' |
| 542 | |
| 543 | >negative && |
| 544 | git add negative && |
| 545 | git commit -m "one" -m "two" -m "three" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 546 | git cat-file commit HEAD >commit && |
| 547 | sed -e "1,/^\$/d" commit >actual && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 548 | ( |
Eric Sunshine | e974e06 | 2018-07-01 20:24:03 -0400 | [diff] [blame] | 549 | echo one && |
| 550 | echo && |
| 551 | echo two && |
| 552 | echo && |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 553 | echo three |
| 554 | ) >expected && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 555 | test_cmp expected actual |
Junio C Hamano | 5aa5cd4 | 2007-11-10 01:49:34 -0800 | [diff] [blame] | 556 | |
| 557 | ' |
| 558 | |
Kristian Høgsberg | d63c2fd | 2007-11-02 11:33:06 -0400 | [diff] [blame] | 559 | test_expect_success 'amend commit to fix author' ' |
| 560 | |
| 561 | oldtick=$GIT_AUTHOR_DATE && |
| 562 | test_tick && |
| 563 | git reset --hard && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 564 | git cat-file -p HEAD >commit && |
Kristian Høgsberg | d63c2fd | 2007-11-02 11:33:06 -0400 | [diff] [blame] | 565 | sed -e "s/author.*/author $author $oldtick/" \ |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 566 | -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ |
| 567 | commit >expected && |
Kristian Høgsberg | d63c2fd | 2007-11-02 11:33:06 -0400 | [diff] [blame] | 568 | git commit --amend --author="$author" && |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 569 | git cat-file -p HEAD >current && |
Miklos Vajna | 1e36868 | 2008-09-10 19:32:44 +0200 | [diff] [blame] | 570 | test_cmp expected current |
Kristian Høgsberg | d63c2fd | 2007-11-02 11:33:06 -0400 | [diff] [blame] | 571 | |
| 572 | ' |
Kristian Høgsberg | 1200993 | 2007-11-15 09:49:58 -0500 | [diff] [blame] | 573 | |
| 574 | test_expect_success 'git commit <file> with dirty index' ' |
Denton Liu | 38c1aa0 | 2019-11-27 11:53:40 -0800 | [diff] [blame] | 575 | echo tacocat >elif && |
| 576 | echo tehlulz >chz && |
Kristian Høgsberg | 1200993 | 2007-11-15 09:49:58 -0500 | [diff] [blame] | 577 | git add chz && |
| 578 | git commit elif -m "tacocat is a palindrome" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 579 | git show --stat >stat && |
| 580 | grep elif stat && |
| 581 | git diff --cached >diff && |
| 582 | grep chz diff |
Kristian Høgsberg | 1200993 | 2007-11-15 09:49:58 -0500 | [diff] [blame] | 583 | ' |
| 584 | |
Johannes Sixt | 13aba1e | 2007-12-03 08:24:50 +0100 | [diff] [blame] | 585 | test_expect_success 'same tree (single parent)' ' |
| 586 | |
Jonathan Nieder | 1af524e | 2011-12-07 08:50:23 -0600 | [diff] [blame] | 587 | git reset --hard && |
| 588 | test_must_fail git commit -m empty |
Johannes Sixt | 13aba1e | 2007-12-03 08:24:50 +0100 | [diff] [blame] | 589 | |
| 590 | ' |
| 591 | |
Junio C Hamano | 36863af | 2007-12-03 00:03:10 -0800 | [diff] [blame] | 592 | test_expect_success 'same tree (single parent) --allow-empty' ' |
| 593 | |
| 594 | git commit --allow-empty -m "forced empty" && |
Denton Liu | 756ee7f | 2019-11-27 11:53:43 -0800 | [diff] [blame] | 595 | git cat-file commit HEAD >commit && |
| 596 | grep forced commit |
Junio C Hamano | 36863af | 2007-12-03 00:03:10 -0800 | [diff] [blame] | 597 | |
| 598 | ' |
| 599 | |
Johannes Sixt | 13aba1e | 2007-12-03 08:24:50 +0100 | [diff] [blame] | 600 | test_expect_success 'same tree (merge and amend merge)' ' |
| 601 | |
| 602 | git checkout -b side HEAD^ && |
| 603 | echo zero >zero && |
| 604 | git add zero && |
| 605 | git commit -m "add zero" && |
| 606 | git checkout master && |
| 607 | |
| 608 | git merge -s ours side -m "empty ok" && |
| 609 | git diff HEAD^ HEAD >actual && |
SZEDER Gábor | 1c5e94f | 2018-08-19 23:57:25 +0200 | [diff] [blame] | 610 | test_must_be_empty actual && |
Johannes Sixt | 13aba1e | 2007-12-03 08:24:50 +0100 | [diff] [blame] | 611 | |
| 612 | git commit --amend -m "empty really ok" && |
| 613 | git diff HEAD^ HEAD >actual && |
SZEDER Gábor | 1c5e94f | 2018-08-19 23:57:25 +0200 | [diff] [blame] | 614 | test_must_be_empty actual |
Johannes Sixt | 13aba1e | 2007-12-03 08:24:50 +0100 | [diff] [blame] | 615 | |
| 616 | ' |
| 617 | |
Junio C Hamano | 1eb1e9e | 2007-12-14 11:57:22 -0800 | [diff] [blame] | 618 | test_expect_success 'amend using the message from another commit' ' |
| 619 | |
| 620 | git reset --hard && |
| 621 | test_tick && |
| 622 | git commit --allow-empty -m "old commit" && |
| 623 | old=$(git rev-parse --verify HEAD) && |
| 624 | test_tick && |
| 625 | git commit --allow-empty -m "new commit" && |
| 626 | new=$(git rev-parse --verify HEAD) && |
| 627 | test_tick && |
| 628 | git commit --allow-empty --amend -C "$old" && |
| 629 | git show --pretty="format:%ad %s" "$old" >expected && |
| 630 | git show --pretty="format:%ad %s" HEAD >actual && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 631 | test_cmp expected actual |
Junio C Hamano | 1eb1e9e | 2007-12-14 11:57:22 -0800 | [diff] [blame] | 632 | |
| 633 | ' |
| 634 | |
Junio C Hamano | 8a2f873 | 2008-02-03 00:00:09 -0800 | [diff] [blame] | 635 | test_expect_success 'amend using the message from a commit named with tag' ' |
| 636 | |
| 637 | git reset --hard && |
| 638 | test_tick && |
| 639 | git commit --allow-empty -m "old commit" && |
| 640 | old=$(git rev-parse --verify HEAD) && |
| 641 | git tag -a -m "tag on old" tagged-old HEAD && |
| 642 | test_tick && |
| 643 | git commit --allow-empty -m "new commit" && |
| 644 | new=$(git rev-parse --verify HEAD) && |
| 645 | test_tick && |
| 646 | git commit --allow-empty --amend -C tagged-old && |
| 647 | git show --pretty="format:%ad %s" "$old" >expected && |
| 648 | git show --pretty="format:%ad %s" HEAD >actual && |
Jeff King | 82ebb0b | 2008-03-12 17:36:36 -0400 | [diff] [blame] | 649 | test_cmp expected actual |
Junio C Hamano | 8a2f873 | 2008-02-03 00:00:09 -0800 | [diff] [blame] | 650 | |
| 651 | ' |
| 652 | |
Thomas Rast | 6360d34 | 2010-03-12 18:04:34 +0100 | [diff] [blame] | 653 | test_expect_success 'amend can copy notes' ' |
| 654 | |
| 655 | git config notes.rewrite.amend true && |
| 656 | git config notes.rewriteRef "refs/notes/*" && |
| 657 | test_commit foo && |
| 658 | git notes add -m"a note" && |
| 659 | test_tick && |
| 660 | git commit --amend -m"new foo" && |
| 661 | test "$(git notes show)" = "a note" |
| 662 | |
| 663 | ' |
| 664 | |
Junio C Hamano | 4682d85 | 2012-06-27 20:14:47 -0700 | [diff] [blame] | 665 | test_expect_success 'commit a file whose name is a dash' ' |
| 666 | git reset --hard && |
| 667 | for i in 1 2 3 4 5 |
| 668 | do |
| 669 | echo $i |
| 670 | done >./- && |
| 671 | git add ./- && |
| 672 | test_tick && |
| 673 | git commit -m "add dash" >output </dev/null && |
| 674 | test_i18ngrep " changed, 5 insertions" output |
| 675 | ' |
| 676 | |
Thomas Rast | f0c7320 | 2013-06-01 13:02:00 +0200 | [diff] [blame] | 677 | test_expect_success '--only works on to-be-born branch' ' |
| 678 | # This test relies on having something in the index, as it |
| 679 | # would not otherwise actually prove much. So check this. |
| 680 | test -n "$(git ls-files)" && |
| 681 | git checkout --orphan orphan && |
| 682 | echo foo >newfile && |
| 683 | git add newfile && |
| 684 | git commit --only newfile -m"--only on unborn branch" && |
| 685 | echo newfile >expected && |
| 686 | git ls-tree -r --name-only HEAD >actual && |
| 687 | test_cmp expected actual |
| 688 | ' |
| 689 | |
Stephen P. Smith | 8dc874b | 2016-02-15 19:38:25 -0700 | [diff] [blame] | 690 | test_expect_success '--dry-run with conflicts fixed from a merge' ' |
| 691 | # setup two branches with conflicting information |
| 692 | # in the same file, resolve the conflict, |
| 693 | # call commit with --dry-run |
| 694 | echo "Initial contents, unimportant" >test-file && |
| 695 | git add test-file && |
| 696 | git commit -m "Initial commit" && |
| 697 | echo "commit-1-state" >test-file && |
| 698 | git commit -m "commit 1" -i test-file && |
| 699 | git tag commit-1 && |
| 700 | git checkout -b branch-2 HEAD^1 && |
| 701 | echo "commit-2-state" >test-file && |
| 702 | git commit -m "commit 2" -i test-file && |
SZEDER Gábor | 15da753 | 2018-08-22 01:28:11 +0200 | [diff] [blame] | 703 | test_must_fail git merge --no-commit commit-1 && |
Stephen P. Smith | 8dc874b | 2016-02-15 19:38:25 -0700 | [diff] [blame] | 704 | echo "commit-2-state" >test-file && |
| 705 | git add test-file && |
| 706 | git commit --dry-run && |
| 707 | git commit -m "conflicts fixed from merge." |
| 708 | ' |
| 709 | |
Stephen P. Smith | f3bd35f | 2018-09-05 17:53:29 -0700 | [diff] [blame] | 710 | test_expect_success '--dry-run --short' ' |
Stephen P. Smith | 8282f59 | 2018-09-05 17:53:28 -0700 | [diff] [blame] | 711 | >test-file && |
| 712 | git add test-file && |
| 713 | git commit --dry-run --short |
| 714 | ' |
| 715 | |
Kristian Høgsberg | 12ace0b | 2007-07-31 15:37:30 -0400 | [diff] [blame] | 716 | test_done |