blob: ae66ba5babf347f12f2c4cb213b0de72ea980da2 [file] [log] [blame]
Rene Scharfec504aae2005-05-27 01:03:26 +02001#!/bin/sh
2#
3# Copyright (C) 2005 Rene Scharfe
4#
5
Junio C Hamano5be60072007-07-02 22:52:14 -07006test_description='git commit-tree options test
Rene Scharfec504aae2005-05-27 01:03:26 +02007
Junio C Hamano5be60072007-07-02 22:52:14 -07008This test checks that git commit-tree can create a specific commit
Rene Scharfec504aae2005-05-27 01:03:26 +02009object by defining all environment variables that it understands.
Junio C Hamano9aab1b52012-07-17 13:05:13 -070010
11Also make sure that command line parser understands the normal
12"flags first and then non flag arguments" command line.
Rene Scharfec504aae2005-05-27 01:03:26 +020013'
14
15. ./test-lib.sh
16
17cat >expected <<EOF
Nguyễn Thái Ngọc Duyf9e7d9f2016-07-16 07:06:24 +020018tree $EMPTY_TREE
Rene Scharfec504aae2005-05-27 01:03:26 +020019author Author Name <author@email> 1117148400 +0000
20committer Committer Name <committer@email> 1117150200 +0000
21
22comment text
23EOF
24
25test_expect_success \
26 'test preparation: write empty tree' \
Junio C Hamano5be60072007-07-02 22:52:14 -070027 'git write-tree >treeid'
Rene Scharfec504aae2005-05-27 01:03:26 +020028
29test_expect_success \
30 'construct commit' \
31 'echo comment text |
32 GIT_AUTHOR_NAME="Author Name" \
33 GIT_AUTHOR_EMAIL="author@email" \
34 GIT_AUTHOR_DATE="2005-05-26 23:00" \
35 GIT_COMMITTER_NAME="Committer Name" \
36 GIT_COMMITTER_EMAIL="committer@email" \
37 GIT_COMMITTER_DATE="2005-05-26 23:30" \
Elia Pintocbda02f2015-12-22 16:05:46 +010038 TZ=GMT git commit-tree $(cat treeid) >commitid 2>/dev/null'
Rene Scharfec504aae2005-05-27 01:03:26 +020039
40test_expect_success \
41 'read commit' \
Elia Pintocbda02f2015-12-22 16:05:46 +010042 'git cat-file commit $(cat commitid) >commit'
Rene Scharfec504aae2005-05-27 01:03:26 +020043
44test_expect_success \
45 'compare commit' \
Miklos Vajna188c3822009-03-16 21:18:42 +010046 'test_cmp expected commit'
Rene Scharfec504aae2005-05-27 01:03:26 +020047
Junio C Hamano9aab1b52012-07-17 13:05:13 -070048
49test_expect_success 'flags and then non flags' '
Ramsay Jones425b8a22012-07-28 19:48:06 +010050 test_tick &&
Junio C Hamano9aab1b52012-07-17 13:05:13 -070051 echo comment text |
52 git commit-tree $(cat treeid) >commitid &&
53 echo comment text |
54 git commit-tree $(cat treeid) -p $(cat commitid) >childid-1 &&
55 echo comment text |
56 git commit-tree -p $(cat commitid) $(cat treeid) >childid-2 &&
57 test_cmp childid-1 childid-2 &&
58 git commit-tree $(cat treeid) -m foo >childid-3 &&
59 git commit-tree -m foo $(cat treeid) >childid-4 &&
60 test_cmp childid-3 childid-4
61'
62
Rene Scharfec504aae2005-05-27 01:03:26 +020063test_done