git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
2bb9fb65faa8b020d4a645a11dda75ca364f7be7 blob 2436 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
#!/bin/sh

test_description='rebase should reread the todo file if an exec modifies it'

. ./test-lib.sh

todo=.git/rebase-merge/git-rebase-todo

test_expect_success 'rebase exec modifies rebase-todo' '
	test_commit initial &&
	git rebase HEAD -x "echo exec touch F >>$todo" &&
	test -e F
'

test_expect_success SHA1 'loose object cache vs re-reading todo list' '
	GIT_REBASE_TODO=$todo &&
	export GIT_REBASE_TODO &&
	write_script append-todo.sh <<-\EOS &&
	# For values 5 and 6, this yields SHA-1s with the same first two digits
	echo "pick $(git rev-parse --short \
		$(printf "%s\\n" \
			"tree $EMPTY_TREE" \
			"author A U Thor <author@example.org> $1 +0000" \
			"committer A U Thor <author@example.org> $1 +0000" \
			"" \
			"$1" |
		  git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO

	shift
	test -z "$*" ||
	echo "exec $0 $*" >>$GIT_REBASE_TODO
	EOS

	git rebase HEAD -x "./append-todo.sh 5 6"
'

test_expect_success 'rebase exec respects rebase.missingCommitsCheck = ignore' '
	test_config rebase.missingCommitsCheck ignore &&
	git rebase HEAD~2 --keep-empty -x "echo >$todo" &&
	test 5 = $(git cat-file commit HEAD | sed -ne \$p)
'

cat >expect <<EOF
Warning: some commits may have been dropped accidentally.
Dropped commits (newer to older):
 - $(git rev-list --pretty=oneline --abbrev-commit -1 HEAD@{2})
To avoid this message, use "drop" to explicitly remove a commit.

Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
The possible behaviours are: ignore, warn, error.
EOF

test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = warn' '
	test_config rebase.missingCommitsCheck warn &&
	git reset --hard HEAD@{2} &&
	git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 &&
	head -n8 actual.2 | tail -n7 >actual &&
	test_i18ncmp expect actual &&
	test 5 = $(git cat-file commit HEAD | sed -ne \$p)
'

test_expect_failure 'rebase exec respects rebase.missingCommitsCheck = error' '
	test_config rebase.missingCommitsCheck error &&
	git reset --hard HEAD@{2} &&
	test_must_fail git rebase HEAD~2 --keep-empty -x "echo >$todo" 2>actual.2 &&
	head -n8 actual.2 | tail -n7 >actual &&
	test_i18ncmp expect actual &&
	echo drop $(git rev-list --pretty=oneline -1 HEAD@{1}) >$todo &&
	git rebase --continue 2>actual &&
	test 5 = $(git cat-file commit HEAD | sed -ne \$p) &&
	test_i18ngrep \
		"Successfully rebased and updated refs/heads/master" \
		actual
'

test_done
debug log:

solving 2bb9fb65fa ...
found 2bb9fb65fa in https://public-inbox.org/git/20190717143918.7406-3-alban.gruin@gmail.com/
found 76f6d306ea in git.git.git
preparing index
index prepared:
100755 76f6d306eaf39e9727bfeb3dbb04aa3c3941cf1d	t/t3429-rebase-edit-todo.sh

applying [1/1] https://public-inbox.org/git/20190717143918.7406-3-alban.gruin@gmail.com/
diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh
index 76f6d306ea..2bb9fb65fa 100755

Checking patch t/t3429-rebase-edit-todo.sh...
Applied patch t/t3429-rebase-edit-todo.sh cleanly.

index at:
100755 2bb9fb65faa8b020d4a645a11dda75ca364f7be7	t/t3429-rebase-edit-todo.sh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).