Re: [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:34

Alex Riesen [off-list ref] writes:
On Mon, Oct 19, 2009 at 08:07, Alex Riesen [off-list ref] wrote:
quoted
On Mon, Oct 19, 2009 at 00:49, Junio C Hamano [off-list ref] wrote:
quoted
Alex Riesen [off-list ref] writes:
quoted
+             OPT_SET_INT(0, "dwim", &dwim_new_local_branch,
+                         "Guess local branch from remote reference (default)", 0),
Humph, how does SET_INT know to set it to 1 with --dwim and set it to 0
with --no-dwim?
It seems to do, though (I checked before sending).
Right, just looked at the parse-options: it is defined for all types.

parse-options.c +/get_value

	const int unset = flags & OPT_UNSET;
...
	case OPTION_SET_INT:
		*(int *)opt->value = unset ? 0 : opt->defval;
		return 0;

Very useful.
Ah, did you mean to change the default value to 1 as well?

Re: [PATCH] Use "--no-" prefix to switch off some of checkout dwimmery

From: Alex Riesen <hidden>
Date: 2016-06-15 22:47:34

On Mon, Oct 19, 2009 at 08:16, Junio C Hamano [off-list ref] wrote:
Alex Riesen [off-list ref] writes:
quoted
On Mon, Oct 19, 2009 at 08:07, Alex Riesen [off-list ref] wrote:
quoted
On Mon, Oct 19, 2009 at 00:49, Junio C Hamano [off-list ref] wrote:
quoted
Alex Riesen [off-list ref] writes:
quoted
+             OPT_SET_INT(0, "dwim", &dwim_new_local_branch,
+                         "Guess local branch from remote reference (default)", 0),
Humph, how does SET_INT know to set it to 1 with --dwim and set it to 0
with --no-dwim?
It seems to do, though (I checked before sending).
Right, just looked at the parse-options: it is defined for all types.

parse-options.c +/get_value

      const int unset = flags & OPT_UNSET;
...
      case OPTION_SET_INT:
              *(int *)opt->value = unset ? 0 : opt->defval;
              return 0;

Very useful.
Ah, did you mean to change the default value to 1 as well?
Err... yes. I (wrongly) assumed that the current value in the
storage is the default. Now, having looked at struct option
I see that It isn't (and the default is in defval).

BTW, why is the option an ...INT? Where a future extension planned?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help