Re: [PATCH v2 06/27] update_refs(): Fix constness

2014-03-31 Thread Junio C Hamano
Michael Haggerty mhag...@alum.mit.edu writes:

 Since full const correctness is beyond the ability of C's type system,
 just put the const where it doesn't do any harm.  A (struct ref_update
 **) can be passed to a (struct ref_update * const *) argument, but not
 to a (const struct ref_update **) argument.

Sounds good, but next time please try not to break lines inside a
single typename, which is somewhat unreadable ;-)

I'd suggest rewording s/Fix/tighten/.  Because a patch that
changes constness can loosen constness to make things more correct,
git shortlog output that says if it is tightening or loosening
would be more informative than the one that says that it is fixing.

 Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
 ---
  builtin/update-ref.c | 2 +-
  refs.c   | 2 +-
  refs.h   | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)

 diff --git a/builtin/update-ref.c b/builtin/update-ref.c
 index f6345e5..a8a68e8 100644
 --- a/builtin/update-ref.c
 +++ b/builtin/update-ref.c
 @@ -14,7 +14,7 @@ static const char * const git_update_ref_usage[] = {
  
  static int updates_alloc;
  static int updates_count;
 -static const struct ref_update **updates;
 +static struct ref_update **updates;
  
  static char line_termination = '\n';
  static int update_flags;
 diff --git a/refs.c b/refs.c
 index 196984e..1305eb1 100644
 --- a/refs.c
 +++ b/refs.c
 @@ -3306,7 +3306,7 @@ static int ref_update_reject_duplicates(struct 
 ref_update **updates, int n,
   return 0;
  }
  
 -int update_refs(const char *action, const struct ref_update **updates_orig,
 +int update_refs(const char *action, struct ref_update * const *updates_orig,
   int n, enum action_on_err onerr)
  {
   int ret = 0, delnum = 0, i;
 diff --git a/refs.h b/refs.h
 index a713b34..08e60ac 100644
 --- a/refs.h
 +++ b/refs.h
 @@ -228,7 +228,7 @@ int update_ref(const char *action, const char *refname,
  /**
   * Lock all refs and then perform all modifications.
   */
 -int update_refs(const char *action, const struct ref_update **updates,
 +int update_refs(const char *action, struct ref_update * const *updates,
   int n, enum action_on_err onerr);
  
  extern int parse_hide_refs_config(const char *var, const char *value, const 
 char *);
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 06/27] update_refs(): Fix constness

2014-03-31 Thread Junio C Hamano
Michael Haggerty mhag...@alum.mit.edu writes:

 On 03/31/2014 11:40 PM, Junio C Hamano wrote:
 Michael Haggerty mhag...@alum.mit.edu writes:
 
 Since full const correctness is beyond the ability of C's type system,
 just put the const where it doesn't do any harm.  A (struct ref_update
 **) can be passed to a (struct ref_update * const *) argument, but not
 to a (const struct ref_update **) argument.
 
 Sounds good, but next time please try not to break lines inside a
 single typename, which is somewhat unreadable ;-)
 
 I'd suggest rewording s/Fix/tighten/.  Because a patch that
 changes constness can loosen constness to make things more correct,
 git shortlog output that says if it is tightening or loosening
 would be more informative than the one that says that it is fixing.

 It is not a strict tightening, because I add a const in one place but
 remove it from another:

 const struct ref_update **

 becomes

 struct ref_update * const *

 in the update_refs() signature.  In fact, the old declaration was too
 strict for some changes later in the patch series, which is why I needed
 to loosen (one aspect) of it.

Interesting.  Then that _is_ a fix.  Thanks for explaining it to
me.  As always, I would prefer it be explained to the proposed
commit log, not to me over an e-mail ;-)


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 06/27] update_refs(): Fix constness

2014-03-24 Thread Michael Haggerty
Since full const correctness is beyond the ability of C's type system,
just put the const where it doesn't do any harm.  A (struct ref_update
**) can be passed to a (struct ref_update * const *) argument, but not
to a (const struct ref_update **) argument.

Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
---
 builtin/update-ref.c | 2 +-
 refs.c   | 2 +-
 refs.h   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index f6345e5..a8a68e8 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -14,7 +14,7 @@ static const char * const git_update_ref_usage[] = {
 
 static int updates_alloc;
 static int updates_count;
-static const struct ref_update **updates;
+static struct ref_update **updates;
 
 static char line_termination = '\n';
 static int update_flags;
diff --git a/refs.c b/refs.c
index 196984e..1305eb1 100644
--- a/refs.c
+++ b/refs.c
@@ -3306,7 +3306,7 @@ static int ref_update_reject_duplicates(struct ref_update 
**updates, int n,
return 0;
 }
 
-int update_refs(const char *action, const struct ref_update **updates_orig,
+int update_refs(const char *action, struct ref_update * const *updates_orig,
int n, enum action_on_err onerr)
 {
int ret = 0, delnum = 0, i;
diff --git a/refs.h b/refs.h
index a713b34..08e60ac 100644
--- a/refs.h
+++ b/refs.h
@@ -228,7 +228,7 @@ int update_ref(const char *action, const char *refname,
 /**
  * Lock all refs and then perform all modifications.
  */
-int update_refs(const char *action, const struct ref_update **updates,
+int update_refs(const char *action, struct ref_update * const *updates,
int n, enum action_on_err onerr);
 
 extern int parse_hide_refs_config(const char *var, const char *value, const 
char *);
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html