git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
8ca3823f23712256a94ee0cfde86e1d7599278ba blob 3706 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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 
#!/bin/sh

test_description='
Test pruning of repositories with minor corruptions. The goal
here is that we should always be erring on the side of safety. So
if we see, for example, a ref with a bogus name, it is OK either to
bail out or to proceed using it as a reachable tip, but it is _not_
OK to proceed as if it did not exist. Otherwise we might silently
delete objects that cannot be recovered.
'
. ./test-lib.sh

test_expect_success 'disable reflogs' '
	git config core.logallrefupdates false &&
	git reflog expire --expire=all --all
'

test_expect_success 'create history reachable only from a bogus-named ref' '
	test_tick && git commit --allow-empty -m main &&
	base=$(git rev-parse HEAD) &&
	test_tick && git commit --allow-empty -m bogus &&
	bogus=$(git rev-parse HEAD) &&
	git cat-file commit $bogus >saved &&
	echo $bogus >.git/refs/heads/bogus..name &&
	git reset --hard HEAD^
'

test_expect_success 'pruning does not drop bogus object' '
	test_when_finished "git hash-object -w -t commit saved" &&
	test_might_fail git prune --expire=now &&
	verbose git cat-file -e $bogus
'

test_expect_success 'put bogus object into pack' '
	git tag reachable $bogus &&
	git repack -ad &&
	git tag -d reachable &&
	verbose git cat-file -e $bogus
'

test_expect_success 'destructive repack keeps packed object' '
	test_might_fail git repack -Ad --unpack-unreachable=now &&
	verbose git cat-file -e $bogus &&
	test_might_fail git repack -ad &&
	verbose git cat-file -e $bogus
'

# subsequent tests will have different corruptions
test_expect_success 'clean up bogus ref' '
	rm .git/refs/heads/bogus..name
'

# We create two new objects here, "one" and "two". Our
# main branch points to "two", which is deleted,
# corrupting the repository. But we'd like to make sure
# that the otherwise unreachable "one" is not pruned
# (since it is the user's best bet for recovering
# from the corruption).
#
# Note that we also point HEAD somewhere besides "two",
# as we want to make sure we test the case where we
# pick up the reference to "two" by iterating the refs,
# not by resolving HEAD.
test_expect_success 'create history with missing tip commit' '
	test_tick && git commit --allow-empty -m one &&
	recoverable=$(git rev-parse HEAD) &&
	git cat-file commit $recoverable >saved &&
	test_tick && git commit --allow-empty -m two &&
	missing=$(git rev-parse HEAD) &&
	git checkout --detach $base &&
	rm .git/objects/$(echo $missing | sed "s,..,&/,") &&
	test_must_fail git cat-file -e $missing
'

test_expect_success 'pruning with a corrupted tip does not drop history' '
	test_when_finished "git hash-object -w -t commit saved" &&
	test_might_fail git prune --expire=now &&
	verbose git cat-file -e $recoverable
'

test_expect_success 'pack-refs does not silently delete broken loose ref' '
	git pack-refs --all --prune &&
	echo $missing >expect &&
	git rev-parse refs/heads/main >actual &&
	test_cmp expect actual
'

# we do not want to count on running pack-refs to
# actually pack it, as it is perfectly reasonable to
# skip processing a broken ref
test_expect_success 'create packed-refs file with broken ref' '
	rm -f .git/refs/heads/main &&
	cat >.git/packed-refs <<-EOF &&
	$missing refs/heads/main
	$recoverable refs/heads/other
	EOF
	echo $missing >expect &&
	git rev-parse refs/heads/main >actual &&
	test_cmp expect actual
'

test_expect_success 'pack-refs does not silently delete broken packed ref' '
	git pack-refs --all --prune &&
	git rev-parse refs/heads/main >actual &&
	test_cmp expect actual
'

test_expect_success 'pack-refs does not drop broken refs during deletion' '
	git update-ref -d refs/heads/other &&
	git rev-parse refs/heads/main >actual &&
	test_cmp expect actual
'

test_done
debug log:

solving 8ca3823f23 ...
found 8ca3823f23 in https://public-inbox.org/git/55b6c04fc0ed3bbdf7e94b955d94227260fe1330.1605221039.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/be29e0789259b6b4ac51bdd7432fce5cf7204bbd.1605629548.git.gitgitgadget@gmail.com/
found da9d59940d in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 da9d59940d5aa72a059a36f4187775b093eb5a58	t/t5312-prune-corruption.sh

applying [1/2] https://public-inbox.org/git/55b6c04fc0ed3bbdf7e94b955d94227260fe1330.1605221039.git.gitgitgadget@gmail.com/
diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh
index da9d59940d..8ca3823f23 100755

Checking patch t/t5312-prune-corruption.sh...
Applied patch t/t5312-prune-corruption.sh cleanly.

skipping https://public-inbox.org/git/be29e0789259b6b4ac51bdd7432fce5cf7204bbd.1605629548.git.gitgitgadget@gmail.com/ for 8ca3823f23
index at:
100755 8ca3823f23712256a94ee0cfde86e1d7599278ba	t/t5312-prune-corruption.sh

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git