summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28f555f)
raw | patch | inline | side by side (parent: 28f555f)
author | Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> | |
Fri, 2 Sep 2011 00:50:34 +0000 (20:50 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 12 Sep 2011 04:39:56 +0000 (21:39 -0700) |
When renaming a remote called 'o' using 'git remote rename o foo', git
should also rename any remote-tracking branches for the remote. This
does happen, but any remote-tracking branches starting with
'refs/remotes/o', such as 'refs/remotes/origin/bar', will also be
renamed (to 'refs/remotes/foorigin/bar' in this case).
Fix it by simply matching one more character, up to the slash
following the remote name.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
should also rename any remote-tracking branches for the remote. This
does happen, but any remote-tracking branches starting with
'refs/remotes/o', such as 'refs/remotes/origin/bar', will also be
renamed (to 'refs/remotes/foorigin/bar' in this case).
Fix it by simply matching one more character, up to the slash
following the remote name.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/remote.c | patch | blob | history | |
t/t5505-remote.sh | patch | blob | history |
diff --git a/builtin/remote.c b/builtin/remote.c
index af96849dc9cb3688ca2f3f4aba3142662f0a78cd..180da895be56b34d1ab62552676d1840c6e0b5bc 100644 (file)
--- a/builtin/remote.c
+++ b/builtin/remote.c
unsigned char orig_sha1[20];
const char *symref;
- strbuf_addf(&buf, "refs/remotes/%s", rename->old);
+ strbuf_addf(&buf, "refs/remotes/%s/", rename->old);
if (!prefixcmp(refname, buf.buf)) {
item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref(refname, orig_sha1, 1, &flag);
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 36c807c6086fa5e0cefb32fc325cd037985c3efd..15186c8cbfa7a3c7409033a26cdfd16835e1c7cd 100755 (executable)
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
'
+test_expect_success 'rename a remote with name prefix of other remote' '
+
+ git clone one four.three &&
+ (cd four.three &&
+ git remote add o git://example.com/repo.git &&
+ git remote rename o upstream &&
+ test "$(git rev-parse origin/master)" = "$(git rev-parse master)")
+
+'
+
cat > remotes_origin << EOF
URL: $(pwd)/one
Push: refs/heads/master:refs/heads/upstream