commit - 0e4002cadf11b9274c4355850d55bd59bbc20d31
commit + 9f142382a5e0fa55e6d614fdb1edc3822d3b80ba
blob - 4f87cf680b2db1a9e42d32ba9fff5ce4869f50f8
blob + cd12b5ed30dbe248b20f407ac20e93f91e120177
--- got/got.c
+++ got/got.c
update_wanted_ref(const char *refname, struct got_object_id *id,
const char *remote_repo_name, int verbosity, struct got_repository *repo)
{
- const struct got_error *err;
+ const struct got_error *err, *unlock_err;
char *remote_refname;
struct got_reference *ref;
remote_repo_name, refname) == -1)
return got_error_from_errno("asprintf");
- err = got_ref_open(&ref, repo, remote_refname, 0);
+ err = got_ref_open(&ref, repo, remote_refname, 1);
if (err) {
if (err->code != GOT_ERR_NOT_REF)
goto done;
err = create_ref(remote_refname, id, verbosity, repo);
} else {
err = update_ref(ref, id, 0, verbosity, repo);
+ unlock_err = got_ref_unlock(ref);
+ if (unlock_err && err == NULL)
+ err = unlock_err;
got_ref_close(ref);
}
done:
static const struct got_error *
cmd_fetch(int argc, char *argv[])
{
- const struct got_error *error = NULL;
+ const struct got_error *error = NULL, *unlock_err;
char *cwd = NULL, *repo_path = NULL;
const char *remote_name;
char *proto = NULL, *host = NULL, *port = NULL;
if (remote->mirror_references ||
strncmp("refs/tags/", refname, 10) == 0) {
- error = got_ref_open(&ref, repo, refname, 0);
+ error = got_ref_open(&ref, repo, refname, 1);
if (error) {
if (error->code != GOT_ERR_NOT_REF)
goto done;
} else {
error = update_ref(ref, id, replace_tags,
verbosity, repo);
+ unlock_err = got_ref_unlock(ref);
+ if (unlock_err && error == NULL)
+ error = unlock_err;
got_ref_close(ref);
if (error)
goto done;
goto done;
}
- error = got_ref_open(&ref, repo, remote_refname, 0);
+ error = got_ref_open(&ref, repo, remote_refname, 1);
if (error) {
if (error->code != GOT_ERR_NOT_REF)
goto done;
} else {
error = update_ref(ref, id, replace_tags,
verbosity, repo);
+ unlock_err = got_ref_unlock(ref);
+ if (unlock_err && error == NULL)
+ error = unlock_err;
got_ref_close(ref);
if (error)
goto done;
}
/* Also create a local branch if none exists yet. */
- error = got_ref_open(&ref, repo, refname, 0);
+ error = got_ref_open(&ref, repo, refname, 1);
if (error) {
if (error->code != GOT_ERR_NOT_REF)
goto done;
repo);
if (error)
goto done;
- } else
+ } else {
+ unlock_err = got_ref_unlock(ref);
+ if (unlock_err && error == NULL)
+ error = unlock_err;
got_ref_close(ref);
+ }
}
}
if (delete_refs)
blob - c0ccfc9a9acb2eed45a59f61406b247bce4ce4ad
blob + ff1f037375b654994fbb0552899cb13e8766cdbb
--- lib/reference.c
+++ lib/reference.c
if (lock) {
err = got_lockfile_lock(&lf, abspath);
- if (err)
- return (err);
+ if (err) {
+ if (err->code == GOT_ERR_ERRNO && errno == ENOENT)
+ err = got_error(GOT_ERR_NOT_REF);
+ return err;
+ }
}
f = fopen(abspath, "rb");