fix got_ref_change_symref(); it changed the ref's name instead of its target
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/include/got_reference.h b/include/got_reference.h
index df306d5..5286f89 100644
--- a/include/got_reference.h
+++ b/include/got_reference.h
@@ -121,7 +121,7 @@ got_ref_change_ref(struct got_reference *, struct got_object_id *);
/* Change the reference name a symbolic reference points to. */
const struct got_error *got_ref_change_symref(struct got_reference *,
- char *);
+ const char *);
/*
* Change a symbolic reference into a regular reference which points to
diff --git a/lib/reference.c b/lib/reference.c
index 0355087..a4aa416 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -1048,7 +1048,7 @@ got_ref_change_ref(struct got_reference *ref, struct got_object_id *id)
}
const struct got_error *
-got_ref_change_symref(struct got_reference *ref, char *refname)
+got_ref_change_symref(struct got_reference *ref, const char *refname)
{
char *new_name;
@@ -1059,8 +1059,8 @@ got_ref_change_symref(struct got_reference *ref, char *refname)
if (new_name == NULL)
return got_error_from_errno("strdup");
- free(ref->ref.symref.name);
- ref->ref.symref.name = new_name;
+ free(ref->ref.symref.ref);
+ ref->ref.symref.ref = new_name;
return NULL;
}