make got_ref_delete() report symbolic references as intended
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 38 39 40 41
diff --git a/got/got.c b/got/got.c
index 8a51215..f4cf4eb 100644
--- a/got/got.c
+++ b/got/got.c
@@ -5279,23 +5279,29 @@ delete_ref(struct got_repository *repo, const char *refname)
struct got_reference *ref;
struct got_object_id *id = NULL;
char *id_str = NULL;
+ const char *target;
err = got_ref_open(&ref, repo, refname, 0);
if (err)
return err;
- err = got_ref_resolve(&id, repo, ref);
- if (err)
- goto done;
- err = got_object_id_str(&id_str, id);
- if (err)
- goto done;
+ if (got_ref_is_symbolic(ref)) {
+ target = got_ref_get_symref_target(ref);
+ } else {
+ err = got_ref_resolve(&id, repo, ref);
+ if (err)
+ goto done;
+ err = got_object_id_str(&id_str, id);
+ if (err)
+ goto done;
+ target = id_str;
+ }
err = got_ref_delete(ref, repo);
if (err)
goto done;
- printf("Deleted %s: %s\n", got_ref_get_name(ref), id_str);
+ printf("Deleted %s: %s\n", got_ref_get_name(ref), target);
done:
got_ref_close(ref);
free(id);