[PATCH v6 36/42] refs.c: pack all refs before we start to rename a ref
- From
Ronnie Sahlberg <sahlberg@google.com>
- Date
- May 1, 2014, 20:37 UTC
- Message-ID
- <1398976662-6962-37-git-send-email-sahlberg@google.com>
- In-Reply-To
- <1398976662-6962-1-git-send-email-sahlberg@google.com>
This means that most loose refs will no longer be present after the rename which triggered a test failure since it assumes the file for an unrelated ref would still be present after the rename.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> --- refs.c | 3 +++ t/t3200-branch.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/refs.c b/refs.c index e1f919e..14d1573 100644 --- a/refs.c +++ b/refs.c @@ -2595,6 +2595,9 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s", oldrefname, strerror(errno)); + if (pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)) + return error("unable to pack refs"); + if (delete_ref(oldrefname, orig_sha1, REF_NODEREF)) { error("unable to delete old %s", oldrefname); goto rollback; diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index ac31b71..fafd38a 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -289,7 +289,7 @@ test_expect_success 'renaming a symref is not allowed' ' git symbolic-ref refs/heads/master2 refs/heads/master && test_must_fail git branch -m master2 master3 && git symbolic-ref refs/heads/master2 && - test_path_is_file .git/refs/heads/master && + test_path_is_missing .git/refs/heads/master && test_path_is_missing .git/refs/heads/master3 '
-- 2.0.0.rc1.351.g4d2c8e4