summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 569740b)
raw | patch | inline | side by side (parent: 569740b)
author | Miklos Vajna <vmiklos@frugalware.org> | |
Wed, 29 Oct 2008 00:05:27 +0000 (01:05 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 30 Oct 2008 20:50:48 +0000 (13:50 -0700) |
There may be cases where one would really want to rename the symbolic
ref without changing its value, but "git branch -m" is not such a
use-case.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ref without changing its value, but "git branch -m" is not such a
use-case.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c | patch | blob | history | |
t/t3200-branch.sh | patch | blob | history |
index b39e6f2c2d7023c45cdc21d4d72064352201fa4d..8a38e0822fab4fd2a06e59265ac713a90700f80d 100644 (file)
--- a/refs.c
+++ b/refs.c
struct stat loginfo;
int log = !lstat(git_path("logs/%s", oldref), &loginfo);
const char *symref = NULL;
- int is_symref = 0;
if (log && S_ISLNK(loginfo.st_mode))
return error("reflog for %s is a symlink", oldref);
symref = resolve_ref(oldref, orig_sha1, 1, &flag);
if (flag & REF_ISSYMREF)
- is_symref = 1;
+ return error("refname %s is a symbolic ref, renaming it is not supported",
+ oldref);
if (!symref)
return error("refname %s not found", oldref);
}
logmoved = log;
- if (!is_symref) {
- lock = lock_ref_sha1_basic(newref, NULL, 0, NULL);
- if (!lock) {
- error("unable to lock %s for update", newref);
- goto rollback;
- }
- lock->force_write = 1;
- hashcpy(lock->old_sha1, orig_sha1);
- if (write_ref_sha1(lock, orig_sha1, logmsg)) {
- error("unable to write current sha1 into %s", newref);
- goto rollback;
- }
- } else
- create_symref(newref, symref, logmsg);
+ lock = lock_ref_sha1_basic(newref, NULL, 0, NULL);
+ if (!lock) {
+ error("unable to lock %s for update", newref);
+ goto rollback;
+ }
+ lock->force_write = 1;
+ hashcpy(lock->old_sha1, orig_sha1);
+ if (write_ref_sha1(lock, orig_sha1, logmsg)) {
+ error("unable to write current sha1 into %s", newref);
+ goto rollback;
+ }
return 0;
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index fdeb1f529ce14d5500976c0e5683c3cbc2fa3501..25e9971fd86af10c1031f4e8061c31a0c80725a7 100755 (executable)
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
"test $(git config branch.s.dummy) = Hello &&
test_must_fail git config branch.s/s/dummy"
-test_expect_success 'renaming a symref' \
+test_expect_success 'renaming a symref is not allowed' \
'
git symbolic-ref refs/heads/master2 refs/heads/master &&
- git branch -m master2 master3 &&
- git symbolic-ref refs/heads/master3 &&
+ test_must_fail git branch -m master2 master3 &&
+ git symbolic-ref refs/heads/master2 &&
test -f .git/refs/heads/master &&
- ! test -f .git/refs/heads/master2
+ ! test -f .git/refs/heads/master3
'
test_expect_success \