{"thread":{"id":"44075","subject":"[PATCH] checkout: constify parameters of checkout_stage() and checkout_merged()","startedAt":"2016-09-13T17:12:52Z","lastAt":"2016-09-13T18:18:16Z","messageCount":2,"participants":["René Scharfe","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"301857","messageId":"a66eedc3-fc86-dd45-628c-e38018a03808@web.de","threadId":"44075","inReplyTo":null,"subject":"[PATCH] checkout: constify parameters of checkout_stage() and checkout_merged()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-09-13T17:11:52Z","receivedAt":"2016-09-13T17:12:52Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Document the fact that checkout_stage() and checkout_merged() don't\nchange the objects passed to them by adding the modifier const.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/checkout.c | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 8672d07..afbff3e 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -154,8 +154,8 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)\n \treturn 0;\n }\n \n-static int checkout_stage(int stage, struct cache_entry *ce, int pos,\n-\t\t\t  struct checkout *state)\n+static int checkout_stage(int stage, const struct cache_entry *ce, int pos,\n+\t\t\t  const struct checkout *state)\n {\n \twhile (pos < active_nr &&\n \t       !strcmp(active_cache[pos]->name, ce->name)) {\n@@ -169,7 +169,7 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,\n \t\treturn error(_(\"path '%s' does not have their version\"), ce->name);\n }\n \n-static int checkout_merged(int pos, struct checkout *state)\n+static int checkout_merged(int pos, const struct checkout *state)\n {\n \tstruct cache_entry *ce = active_cache[pos];\n \tconst char *path = ce->name;\n-- \n2.10.0\n\n"},{"id":"301865","messageId":"20160913181807.2ow5fy6b4622sndr@sigill.intra.peff.net","threadId":"44075","inReplyTo":"a66eedc3-fc86-dd45-628c-e38018a03808@web.de","subject":"Re: [PATCH] checkout: constify parameters of checkout_stage() and checkout_merged()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-09-13T18:18:09Z","receivedAt":"2016-09-13T18:18:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 13, 2016 at 07:11:52PM +0200, René Scharfe wrote:\n\n> Document the fact that checkout_stage() and checkout_merged() don't\n> change the objects passed to them by adding the modifier const.\n\nHmm. Sometimes these big \"context\" objects are hard to make const,\nbecause we end up using them to hold or pass state between functions\n(e.g., see diff_options). So I'd worry slightly that we'll end up\nun-consting this in the long run.\n\nThat being said, it is easy to revert, and it provides some small\nbenefit, so I don't mind it in the meantime.\n\n-Peff\n"}]}