update_refs(): fix constness

The old signature of update_refs() required a (const struct ref_update **) for its updates_orig argument. The "const" is presumably there to promise that the function will not modify the contents of the structures. But this declaration does not permit the function to be called with a (struct ref_update **), which is perfectly legitimate. C's type system is not powerful enough to express what we'd like. So remove the first "const" from the declaration. On the other hand, the function *can* promise not to modify the pointers within the array that is passed to it without inconveniencing its callers. So add a "const" that has that effect, making the final declaration (struct ref_update * const *). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 7, 2014 at 15:47 UTC 595deb8da69b4f816ff0c8e669b49f7527ff609b
3 files changed +3 -3
builtin/update-ref.c
+1 -1
@@ -14,7 +14,7 @@ static const char * const git_update_ref_usage[] = {
14
15 static int updates_alloc;
16 static int updates_count;
17 -static const struct ref_update **updates;
17 +static struct ref_update **updates;
18
19 static char line_termination = '\n';
20 static int update_flags;
refs.c
+1 -1
@@ -3306,7 +3306,7 @@ static int ref_update_reject_duplicates(struct ref_update **updates, int n,
3306 return 0;
3307 }
3308
3309 -int update_refs(const char *action, const struct ref_update **updates_orig,
3309 +int update_refs(const char *action, struct ref_update * const *updates_orig,
3310 int n, enum action_on_err onerr)
3311 {
3312 int ret = 0, delnum = 0, i;
refs.h
+1 -1
@@ -228,7 +228,7 @@ int update_ref(const char *action, const char *refname,
228 /**
229 * Lock all refs and then perform all modifications.
230 */
231 -int update_refs(const char *action, const struct ref_update **updates,
231 +int update_refs(const char *action, struct ref_update * const *updates,
232 int n, enum action_on_err onerr);
233
234 extern int parse_hide_refs_config(const char *var, const char *value, const char *);