Skip to content

Commit 650ed39

Browse files
committed
Merge branch 'ds/refmap-doc' into maint
"git fetch --refmap=" option has got a better documentation. * ds/refmap-doc: fetch: document and test --refmap=""
2 parents 80b806f + b40a502 commit 650ed39

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Documentation/fetch-options.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ ifndef::git-pull[]
139139
specified refspec (can be given more than once) to map the
140140
refs to remote-tracking branches, instead of the values of
141141
`remote.*.fetch` configuration variables for the remote
142-
repository. See section on "Configured Remote-tracking
142+
repository. Providing an empty `<refspec>` to the
143+
`--refmap` option causes Git to ignore the configured
144+
refspecs and rely entirely on the refspecs supplied as
145+
command-line arguments. See section on "Configured Remote-tracking
143146
Branches" for details.
144147

145148
-t::

t/t5510-fetch.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,30 @@ test_expect_success 'fetch --prune --tags with refspec prunes based on refspec'
174174
git rev-parse sometag
175175
'
176176

177+
test_expect_success '--refmap="" ignores configured refspec' '
178+
cd "$TRASH_DIRECTORY" &&
179+
git clone "$D" remote-refs &&
180+
git -C remote-refs rev-parse remotes/origin/master >old &&
181+
git -C remote-refs update-ref refs/remotes/origin/master master~1 &&
182+
git -C remote-refs rev-parse remotes/origin/master >new &&
183+
git -C remote-refs fetch --refmap= origin "+refs/heads/*:refs/hidden/origin/*" &&
184+
git -C remote-refs rev-parse remotes/origin/master >actual &&
185+
test_cmp new actual &&
186+
git -C remote-refs fetch origin &&
187+
git -C remote-refs rev-parse remotes/origin/master >actual &&
188+
test_cmp old actual
189+
'
190+
191+
test_expect_success '--refmap="" and --prune' '
192+
git -C remote-refs update-ref refs/remotes/origin/foo/otherbranch master &&
193+
git -C remote-refs update-ref refs/hidden/foo/otherbranch master &&
194+
git -C remote-refs fetch --prune --refmap="" origin +refs/heads/*:refs/hidden/* &&
195+
git -C remote-refs rev-parse remotes/origin/foo/otherbranch &&
196+
test_must_fail git -C remote-refs rev-parse refs/hidden/foo/otherbranch &&
197+
git -C remote-refs fetch --prune origin &&
198+
test_must_fail git -C remote-refs rev-parse remotes/origin/foo/otherbranch
199+
'
200+
177201
test_expect_success 'fetch tags when there is no tags' '
178202
179203
cd "$D" &&

0 commit comments

Comments
 (0)