diff options
author | Jay Soffian <jaysoffian@gmail.com> | 2009-02-04 11:06:07 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-02-04 08:47:57 -0800 |
commit | 441adf0ccf571a9fe15658fdfcd856d2aabc01cb (patch) | |
tree | a62a0da5285f95c265e33329929d8a62b7fa4ec9 /t | |
parent | builtin-remote: make rm() use properly named variable to hold return value (diff) | |
download | tgif-441adf0ccf571a9fe15658fdfcd856d2aabc01cb.tar.xz |
builtin-remote: make rm operation safer in mirrored repository
"git remote rm <repo>" happily removes non-remote refs and their reflogs.
This may be okay if the repository truely is a mirror, but if the user
had done "git remote add --mirror <repo>" by accident and was just
undoing their mistake, then they are left in a situation that is
difficult to recover from.
After this commit, "git remote rm" skips over non-remote refs. The user
is advised on how remove branches using "git branch -d", which itself
has nice safety checks wrt to branch removal lacking from "git remote rm".
Non-remote non-branch refs are skipped silently.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t5505-remote.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 0103e1a180..aadf3e9546 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -107,6 +107,32 @@ test_expect_success 'remove remote' ' ) ' +test_expect_success 'remove remote protects non-remote branches' ' +( + cd test && + (cat >expect1 <<EOF +Note: A non-remote branch was not removed; to delete it, use: + git branch -d master +EOF + cat >expect2 <<EOF +Note: Non-remote branches were not removed; to delete them, use: + git branch -d foobranch + git branch -d master +EOF +) && + git tag footag + git config --add remote.oops.fetch "+refs/*:refs/*" && + git remote rm oops 2>actual1 && + git branch foobranch && + git config --add remote.oops.fetch "+refs/*:refs/*" && + git remote rm oops 2>actual2 && + git branch -d foobranch && + git tag -d footag && + test_cmp expect1 actual1 && + test_cmp expect2 actual2 +) +' + cat > test/expect << EOF * remote origin URL: $(pwd)/one |