git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
b6d1776c98d07bb02f25482f6329c06979eca0a8 blob 7055 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
 
#!/bin/sh

test_description='check various push.default settings'
. ./test-lib.sh

test_expect_success 'setup bare remotes' '
	git init --bare repo1 &&
	git remote add parent1 repo1 &&
	git init --bare repo2 &&
	git remote add parent2 repo2 &&
	test_commit one &&
	git push parent1 HEAD &&
	git push parent2 HEAD
'

# $1 = local revision
# $2 = remote revision (tested to be equal to the local one)
# $3 = [optional] repo to check for actual output (repo1 by default)
check_pushed_commit () {
	git log -1 --format='%h %s' "$1" >expect &&
	git --git-dir="${3:-repo1}" log -1 --format='%h %s' "$2" >actual &&
	test_cmp expect actual
}

# $1 = push.default value
# $2 = expected target branch for the push
# $3 = [optional] repo to check for actual output (repo1 by default)
test_push_success () {
	git ${1:+-c} ${1:+push.default="$1"} push &&
	check_pushed_commit HEAD "$2" "$3"
}

# $1 = push.default value
# check that push fails and does not modify any remote branch
test_push_failure () {
	git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&
	test_must_fail git ${1:+-c} ${1:+push.default="$1"} push &&
	git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&
	test_cmp expect actual
}

# $1 = success or failure
# $2 = push.default value
# $3 = branch to check for actual output (main or foo)
# $4 = [optional] switch to triangular workflow
test_pushdefault_workflow () {
	workflow=central
	pushdefault=parent1
	if test -n "${4-}"; then
		workflow=triangular
		pushdefault=parent2
	fi
	test_expect_success "push.default = $2 $1 in $workflow workflows" "
		test_config branch.main.remote parent1 &&
		test_config branch.main.merge refs/heads/foo &&
		test_config remote.pushdefault $pushdefault &&
		test_commit commit-for-$2${4+-triangular} &&
		test_push_$1 $2 $3 ${4+repo2}
	"
}

test_expect_success '"upstream" pushes to configured upstream' '
	git checkout main &&
	test_config branch.main.remote parent1 &&
	test_config branch.main.merge refs/heads/foo &&
	test_commit two &&
	test_push_success upstream foo
'

test_expect_success '"upstream" does not push on unconfigured remote' '
	git checkout main &&
	test_unconfig branch.main.remote &&
	test_commit three &&
	test_push_failure upstream
'

test_expect_success '"upstream" does not push on unconfigured branch' '
	git checkout main &&
	test_config branch.main.remote parent1 &&
	test_unconfig branch.main.merge &&
	test_commit four &&
	test_push_failure upstream
'

test_expect_success '"upstream" does not push when remotes do not match' '
	git checkout main &&
	test_config branch.main.remote parent1 &&
	test_config branch.main.merge refs/heads/foo &&
	test_config push.default upstream &&
	test_commit five &&
	test_must_fail git push parent2
'

test_expect_success 'push from/to new branch with upstream, matching and simple' '
	git checkout -b new-branch &&
	test_push_failure simple &&
	test_push_failure matching &&
	test_push_failure upstream
'

test_expect_success '"matching" fails if none match' '
	git init --bare empty &&
	test_must_fail git push empty : 2>actual &&
	test_i18ngrep "Perhaps you should specify a branch" actual
'

test_expect_success 'push ambiguously named branch with upstream, matching and simple' '
	git checkout -b ambiguous &&
	test_config branch.ambiguous.remote parent1 &&
	test_config branch.ambiguous.merge refs/heads/ambiguous &&
	git tag ambiguous &&
	test_push_success simple ambiguous &&
	test_push_success matching ambiguous &&
	test_push_success upstream ambiguous
'

test_expect_success 'push from/to new branch with current creates remote branch' '
	test_config branch.new-branch.remote repo1 &&
	git checkout new-branch &&
	test_push_success current new-branch
'

test_expect_success 'push to existing branch, with no upstream configured' '
	test_config branch.main.remote repo1 &&
	git checkout main &&
	test_push_failure simple &&
	test_push_failure upstream
'

test_expect_success 'push to existing branch, upstream configured with same name' '
	test_config branch.main.remote repo1 &&
	test_config branch.main.merge refs/heads/main &&
	git checkout main &&
	test_commit six &&
	test_push_success upstream main &&
	test_commit seven &&
	test_push_success simple main
'

test_expect_success 'push to existing branch, upstream configured with different name' '
	test_config branch.main.remote repo1 &&
	test_config branch.main.merge refs/heads/other-name &&
	git checkout main &&
	test_commit eight &&
	test_push_success upstream other-name &&
	test_commit nine &&
	test_push_failure simple &&
	git --git-dir=repo1 log -1 --format="%h %s" "other-name" >expect-other-name &&
	test_push_success current main &&
	git --git-dir=repo1 log -1 --format="%h %s" "other-name" >actual-other-name &&
	test_cmp expect-other-name actual-other-name
'

# We are on 'main', which integrates with 'foo' from parent1
# remote (set in test_pushdefault_workflow helper).  Push to
# parent1 in centralized, and push to parent2 in triangular workflow.
# The parent1 repository has 'main' and 'foo' branches, while
# the parent2 repository has only 'main' branch.
#
# test_pushdefault_workflow() arguments:
# $1 = success or failure
# $2 = push.default value
# $3 = branch to check for actual output (main or foo)
# $4 = [optional] switch to triangular workflow

# update parent1's main (which is not our upstream)
test_pushdefault_workflow success current main

# update parent1's foo (which is our upstream)
test_pushdefault_workflow success upstream foo

# upstream is foo which is not the name of the current branch
test_pushdefault_workflow failure simple main

# main and foo are updated
test_pushdefault_workflow success matching main

# main is updated
test_pushdefault_workflow success current main triangular

# upstream mode cannot be used in triangular
test_pushdefault_workflow failure upstream foo triangular

# in triangular, 'simple' works as 'current' and update the branch
# with the same name.
test_pushdefault_workflow success simple main triangular

# main is updated (parent2 does not have foo)
test_pushdefault_workflow success matching main triangular

# default tests, when no push-default is specified. This
# should behave the same as "simple" in non-triangular
# settings, and as "current" otherwise.

test_expect_success 'default behavior allows "simple" push' '
	test_config branch.main.remote parent1 &&
	test_config branch.main.merge refs/heads/main &&
	test_config remote.pushdefault parent1 &&
	test_commit default-main-main &&
	test_push_success "" main
'

test_expect_success 'default behavior rejects non-simple push' '
	test_config branch.main.remote parent1 &&
	test_config branch.main.merge refs/heads/foo &&
	test_config remote.pushdefault parent1 &&
	test_commit default-main-foo &&
	test_push_failure ""
'

test_expect_success 'default triangular behavior acts like "current"' '
	test_config branch.main.remote parent1 &&
	test_config branch.main.merge refs/heads/foo &&
	test_config remote.pushdefault parent2 &&
	test_commit default-triangular &&
	test_push_success "" main repo2
'

test_done
debug log:

solving b6d1776c98 ...
found b6d1776c98 in https://public-inbox.org/git/3aef39320e96aad10e133f1c97a9010aa85aa894.1605221039.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/4b1b1ee51f19b6625118f39ac1389b485f99290a.1605629548.git.gitgitgadget@gmail.com/
found f0a287d97d in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 f0a287d97dba8e2e72ed50f85d75df91852dab5f	t/t5528-push-default.sh

applying [1/2] https://public-inbox.org/git/3aef39320e96aad10e133f1c97a9010aa85aa894.1605221039.git.gitgitgadget@gmail.com/
diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh
index f0a287d97d..b6d1776c98 100755

Checking patch t/t5528-push-default.sh...
Applied patch t/t5528-push-default.sh cleanly.

skipping https://public-inbox.org/git/4b1b1ee51f19b6625118f39ac1389b485f99290a.1605629548.git.gitgitgadget@gmail.com/ for b6d1776c98
index at:
100755 b6d1776c98d07bb02f25482f6329c06979eca0a8	t/t5528-push-default.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