From: Johan Herland <johan@herland.net>
To: gitster@pobox.com
Cc: Per Cederqvist <cederp@opera.com>,
git@vger.kernel.org, Johan Herland <johan@herland.net>
Subject: [PATCHv2 5/5] branch.c: Relax unnecessary requirement on upstream's remote ref name
Date: Sun, 8 Sep 2013 22:58:15 +0200 [thread overview]
Message-ID: <1378673895-23127-6-git-send-email-johan@herland.net> (raw)
In-Reply-To: <1378673895-23127-1-git-send-email-johan@herland.net>
From: Per Cederqvist <cederp@opera.com>
When creating an upstream relationship, we use the configured remotes and
their refspecs to determine the upstream configuration settings
branch.<name>.remote and branch.<name>.merge. However, if the matching
refspec does not have refs/heads/<something> on the remote side, we end
up rejecting the match, and failing the upstream configuration.
It could be argued that when we set up an branch's upstream, we want that
upstream to also be a proper branch in the remote repo. Although this is
typically the common case, there are cases (as demonstrated by the previous
patch in this series) where this requirement prevents a useful upstream
relationship from being formed. Furthermore:
- We have fundamentally no say in how the remote repo have organized its
branches. The remote repo may put branches (or branch-like constructs
that are insteresting for downstreams to track) outside refs/heads/*.
- The user may intentionally want to track a non-branch from a remote
repo, by using a branch and configured upstream in the local repo.
Relaxing the checking to only require a matching remote/refspec allows the
testcase introduced in the previous patch to succeed, and has no negative
effect on the rest of the test suite.
This patch fixes a behavior (arguably a regression) first introduced in
41c21f2 (branch.c: Validate tracking branches with refspecs instead of
refs/remotes/*) on 2013-04-21 (released in >= v1.8.3.2).
Signed-off-by: Johan Herland <johan@herland.net>
---
branch.c | 3 +--
t/t3200-branch.sh | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/branch.c b/branch.c
index c5c6984..2d15c19 100644
--- a/branch.c
+++ b/branch.c
@@ -203,8 +203,7 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)
struct refspec query;
memset(&query, 0, sizeof(struct refspec));
query.dst = tracking_branch;
- return !(remote_find_tracking(remote, &query) ||
- prefixcmp(query.src, "refs/heads/"));
+ return !remote_find_tracking(remote, &query);
}
static int validate_remote_tracking_branch(char *ref)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 4031693..f010303 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -871,7 +871,7 @@ test_expect_success '--merged catches invalid object names' '
test_must_fail git branch --merged 0000000000000000000000000000000000000000
'
-test_expect_failure 'tracking with unexpected .fetch refspec' '
+test_expect_success 'tracking with unexpected .fetch refspec' '
git init a &&
(
cd a &&
--
1.8.3.GIT
prev parent reply other threads:[~2013-09-08 20:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 10:40 [PATCH 0/5] branch: Fix --track on a remote-tracking non-branch Johan Herland
2013-09-06 10:40 ` [PATCH 1/5] t2024: Fix inconsequential typos Johan Herland
2013-09-06 17:32 ` Junio C Hamano
2013-09-06 20:53 ` Johan Herland
2013-09-06 10:40 ` [PATCH 2/5] t3200: Minor fix when preparing for tracking failure Johan Herland
2013-09-06 10:40 ` [PATCH 3/5] Refer to branch.<name>.remote/merge when documenting --track Johan Herland
2013-09-06 10:40 ` [PATCH 4/5] t3200: Add test demonstrating minor regression in 41c21f2 Johan Herland
2013-09-06 10:40 ` [PATCH 5/5] branch.c: Relax unnecessary requirement on upstream's remote ref name Johan Herland
2013-09-06 17:29 ` [PATCH 0/5] branch: Fix --track on a remote-tracking non-branch Junio C Hamano
2013-09-08 20:58 ` [PATCHv2 " Johan Herland
2013-09-08 20:58 ` [PATCHv2 1/5] t2024: Fix &&-chaining and a couple of typos Johan Herland
2013-09-08 20:58 ` [PATCHv2 2/5] t3200: Minor fix when preparing for tracking failure Johan Herland
2013-09-08 20:58 ` [PATCHv2 3/5] Refer to branch.<name>.remote/merge when documenting --track Johan Herland
2013-09-08 20:58 ` [PATCHv2 4/5] t3200: Add test demonstrating minor regression in 41c21f2 Johan Herland
2013-09-08 20:58 ` Johan Herland [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378673895-23127-6-git-send-email-johan@herland.net \
--to=johan@herland.net \
--cc=cederp@opera.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).