git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] checkout: constify parameters of checkout_stage() and checkout_merged()
@ 2016-09-13 17:11 René Scharfe
  2016-09-13 18:18 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2016-09-13 17:11 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Document the fact that checkout_stage() and checkout_merged() don't
change the objects passed to them by adding the modifier const.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/checkout.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 8672d07..afbff3e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -154,8 +154,8 @@ static int check_stages(unsigned stages, const struct cache_entry *ce, int pos)
 	return 0;
 }
 
-static int checkout_stage(int stage, struct cache_entry *ce, int pos,
-			  struct checkout *state)
+static int checkout_stage(int stage, const struct cache_entry *ce, int pos,
+			  const struct checkout *state)
 {
 	while (pos < active_nr &&
 	       !strcmp(active_cache[pos]->name, ce->name)) {
@@ -169,7 +169,7 @@ static int checkout_stage(int stage, struct cache_entry *ce, int pos,
 		return error(_("path '%s' does not have their version"), ce->name);
 }
 
-static int checkout_merged(int pos, struct checkout *state)
+static int checkout_merged(int pos, const struct checkout *state)
 {
 	struct cache_entry *ce = active_cache[pos];
 	const char *path = ce->name;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] checkout: constify parameters of checkout_stage() and checkout_merged()
  2016-09-13 17:11 [PATCH] checkout: constify parameters of checkout_stage() and checkout_merged() René Scharfe
@ 2016-09-13 18:18 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2016-09-13 18:18 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git List, Junio C Hamano

On Tue, Sep 13, 2016 at 07:11:52PM +0200, René Scharfe wrote:

> Document the fact that checkout_stage() and checkout_merged() don't
> change the objects passed to them by adding the modifier const.

Hmm. Sometimes these big "context" objects are hard to make const,
because we end up using them to hold or pass state between functions
(e.g., see diff_options). So I'd worry slightly that we'll end up
un-consting this in the long run.

That being said, it is easy to revert, and it provides some small
benefit, so I don't mind it in the meantime.

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-13 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13 17:11 [PATCH] checkout: constify parameters of checkout_stage() and checkout_merged() René Scharfe
2016-09-13 18:18 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).