[PATCH v10 38/44] refs.c: pack all refs before we start to rename a ref
- From
Ronnie Sahlberg <sahlberg@google.com>
- Date
- May 16, 2014, 17:37 UTC
- Message-ID
- <1400261852-31303-39-git-send-email-sahlberg@google.com>
- In-Reply-To
- <1400261852-31303-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 1210345..f4899e0 100644 --- a/refs.c +++ b/refs.c @@ -2635,6 +2635,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.rc3.510.g20c254b