File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,8 @@ static int add(int argc, const char **argv)
193193
194194 if (mirror && master )
195195 die ("specifying a master branch makes no sense with --mirror" );
196- if (mirror && track .nr )
197- die ("specifying branches to track makes no sense with --mirror " );
196+ if (mirror && !( mirror & MIRROR_FETCH ) && track .nr )
197+ die ("specifying branches to track makes sense only with fetch mirrors " );
198198
199199 name = argv [0 ];
200200 url = argv [1 ];
Original file line number Diff line number Diff line change @@ -347,6 +347,21 @@ test_expect_success 'fetch mirrors do not act as mirrors during push' '
347347 )
348348'
349349
350+ test_expect_success ' add fetch mirror with specific branches' '
351+ git init --bare mirror-fetch/track &&
352+ (cd mirror-fetch/track &&
353+ git remote add --mirror=fetch -t heads/new parent ../parent
354+ )
355+ '
356+
357+ test_expect_success ' fetch mirror respects specific branches' '
358+ (cd mirror-fetch/track &&
359+ git fetch parent &&
360+ git rev-parse --verify refs/heads/new &&
361+ test_must_fail git rev-parse --verify refs/heads/renamed
362+ )
363+ '
364+
350365test_expect_success ' add --mirror=push' '
351366 mkdir mirror-push &&
352367 git init --bare mirror-push/public &&
@@ -382,6 +397,13 @@ test_expect_success 'push mirrors do not act as mirrors during fetch' '
382397 )
383398'
384399
400+ test_expect_success ' push mirrors do not allow you to specify refs' '
401+ git init mirror-push/track &&
402+ (cd mirror-push/track &&
403+ test_must_fail git remote add --mirror=push -t new public ../public
404+ )
405+ '
406+
385407test_expect_success ' add alt && prune' '
386408 (mkdir alttst &&
387409 cd alttst &&
You can’t perform that action at this time.
0 commit comments