# [PATCH] replace --edit: respect core.editor

10 messages from 2016-04-19 to 2016-04-20. Participants: Johannes Schindelin, Junio C Hamano, Jeff King, Christian Couder.
Thread: https://gitlist.dev/t/42070

## Johannes Schindelin, 2016-04-19 14:37

Subject: [PATCH] replace --edit: respect core.editor
Message-ID: <909769abaff1babdab77625bebd04e2013c6e344.1461076425.git.johannes.schindelin@gmx.de>
URL: https://gitlist.dev/e/909769abaff1babdab77625bebd04e2013c6e344.1461076425.git.johannes.schindelin%40gmx.de

```
We simply need to read the config, is all.

This fixes https://github.com/git-for-windows/git/issues/733

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/replace.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/replace.c b/builtin/replace.c
index 748c6ca..02b13f6 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -475,6 +475,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 		return replace_object(argv[0], argv[1], force);
 
 	case MODE_EDIT:
+		git_config(git_default_config, NULL);
 		if (argc != 1)
 			usage_msg_opt("-e needs exactly one argument",
 				      git_replace_usage, options);
-- 
2.8.1.206.g8b39b4a

```

## Junio C Hamano, 2016-04-19 16:22

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <xmqqoa9536wi.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqoa9536wi.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <909769abaff1babdab77625bebd04e2013c6e344.1461076425.git.johannes.schindelin@gmx.de>

```
"git blame -L475,6 builtin/replace.c" points at b892bb45 (replace:
add --edit option, 2014-04-26) and the commit log message names two
people who can review this change, so that is what I am doing here.

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> We simply need to read the config, is all.
>
> This fixes https://github.com/git-for-windows/git/issues/733
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  builtin/replace.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/builtin/replace.c b/builtin/replace.c
> index 748c6ca..02b13f6 100644
> --- a/builtin/replace.c
> +++ b/builtin/replace.c
> @@ -475,6 +475,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
>  		return replace_object(argv[0], argv[1], force);
>  
>  	case MODE_EDIT:
> +		git_config(git_default_config, NULL);
>  		if (argc != 1)
>  			usage_msg_opt("-e needs exactly one argument",
>  				      git_replace_usage, options);

The placement of git_config() makes me wonder why.

I can understand "we only know edit mode needs config, and we know
it will never affect other modes to have the new call here", and it
would be good for an emergency patch for ancient maintenance track
that will not get any other changes or enhancements.  I do not think
it is a sound reasoning to maintain the codefor the longer term,
though.

```

## Jeff King, 2016-04-20 03:53

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <20160420035353.GA31890@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160420035353.GA31890%40sigill.intra.peff.net
In-Reply-To: <xmqqoa9536wi.fsf@gitster.mtv.corp.google.com>

```
On Tue, Apr 19, 2016 at 09:22:37AM -0700, Junio C Hamano wrote:

> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> 
> > We simply need to read the config, is all.
> >
> > This fixes https://github.com/git-for-windows/git/issues/733
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> >  builtin/replace.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/builtin/replace.c b/builtin/replace.c
> > index 748c6ca..02b13f6 100644
> > --- a/builtin/replace.c
> > +++ b/builtin/replace.c
> > @@ -475,6 +475,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
> >  		return replace_object(argv[0], argv[1], force);
> >  
> >  	case MODE_EDIT:
> > +		git_config(git_default_config, NULL);
> >  		if (argc != 1)
> >  			usage_msg_opt("-e needs exactly one argument",
> >  				      git_replace_usage, options);
> 
> The placement of git_config() makes me wonder why.
> 
> I can understand "we only know edit mode needs config, and we know
> it will never affect other modes to have the new call here", and it
> would be good for an emergency patch for ancient maintenance track
> that will not get any other changes or enhancements.  I do not think
> it is a sound reasoning to maintain the codefor the longer term,
> though.

Yeah. I agree the patch here is not wrong, but I would prefer to just
have git-replace load the config when it starts. It's _possible_ that
something might break or misbehave, but IMHO any program which breaks
when git_default_config() is run is probably in need of fixing.

And I cannot recall any reason we did not read config when "--edit"
was added; we just didn't think of it.

-Peff

```

## Christian Couder, 2016-04-20 05:51

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <CAP8UFD189+AcLstEx4s_2ZYWp6UOtDb=vWGYhCpJayM8ma5hxw@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD189%2BAcLstEx4s_2ZYWp6UOtDb%3DvWGYhCpJayM8ma5hxw%40mail.gmail.com
In-Reply-To: <20160420035353.GA31890@sigill.intra.peff.net>

```
On Wed, Apr 20, 2016 at 5:53 AM, Jeff King <peff@peff.net> wrote:
> On Tue, Apr 19, 2016 at 09:22:37AM -0700, Junio C Hamano wrote:
>
>> I can understand "we only know edit mode needs config, and we know
>> it will never affect other modes to have the new call here", and it
>> would be good for an emergency patch for ancient maintenance track
>> that will not get any other changes or enhancements.  I do not think
>> it is a sound reasoning to maintain the codefor the longer term,
>> though.
>
> Yeah. I agree the patch here is not wrong, but I would prefer to just
> have git-replace load the config when it starts. It's _possible_ that
> something might break or misbehave, but IMHO any program which breaks
> when git_default_config() is run is probably in need of fixing.

I agree.

> And I cannot recall any reason we did not read config when "--edit"
> was added; we just didn't think of it.

Yeah I think so.

Thanks,
Christian.

```

## Johannes Schindelin, 2016-04-20 06:33

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <alpine.DEB.2.20.1604200832430.2826@virtualbox>
URL: https://gitlist.dev/e/alpine.DEB.2.20.1604200832430.2826%40virtualbox
In-Reply-To: <xmqqoa9536wi.fsf@gitster.mtv.corp.google.com>

```
Hi Junio,

On Tue, 19 Apr 2016, Junio C Hamano wrote:

> "git blame -L475,6 builtin/replace.c" points at b892bb45 (replace: add
> --edit option, 2014-04-26) and the commit log message names two people
> who can review this change, so that is what I am doing here.

D'oh. Sorry.
Dscho

```

## Johannes Schindelin, 2016-04-20 06:37

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <alpine.DEB.2.20.1604200836050.2826@virtualbox>
URL: https://gitlist.dev/e/alpine.DEB.2.20.1604200836050.2826%40virtualbox
In-Reply-To: <CAP8UFD189+AcLstEx4s_2ZYWp6UOtDb=vWGYhCpJayM8ma5hxw@mail.gmail.com>

```
Hi Christian & Peff,

On Wed, 20 Apr 2016, Christian Couder wrote:

> On Wed, Apr 20, 2016 at 5:53 AM, Jeff King <peff@peff.net> wrote:
> > On Tue, Apr 19, 2016 at 09:22:37AM -0700, Junio C Hamano wrote:
> >
> >> I can understand "we only know edit mode needs config, and we know it
> >> will never affect other modes to have the new call here", and it
> >> would be good for an emergency patch for ancient maintenance track
> >> that will not get any other changes or enhancements.  I do not think
> >> it is a sound reasoning to maintain the codefor the longer term,
> >> though.
> >
> > Yeah. I agree the patch here is not wrong, but I would prefer to just
> > have git-replace load the config when it starts. It's _possible_ that
> > something might break or misbehave, but IMHO any program which breaks
> > when git_default_config() is run is probably in need of fixing.
> 
> I agree.

Okay. I tried to err on the side of caution (side effects? Ever heard of
side effects? ;-))

v2 coming.

Ciao,
Dscho

```

## Johannes Schindelin, 2016-04-20 06:38

Subject: [PATCH v2] replace --edit: respect core.editor
Message-ID: <a7b889d525f99fecfb9d4a890fd2a5d4bf3001e0.1461134258.git.johannes.schindelin@gmx.de>
URL: https://gitlist.dev/e/a7b889d525f99fecfb9d4a890fd2a5d4bf3001e0.1461134258.git.johannes.schindelin%40gmx.de
In-Reply-To: <909769abaff1babdab77625bebd04e2013c6e344.1461076425.git.johannes.schindelin@gmx.de>

```
We simply need to read the config, is all.

This fixes https://github.com/git-for-windows/git/issues/733

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/replace.c | 1 +
 1 file changed, 1 insertion(+)
Interdiff vs v1:

 diff --git a/builtin/replace.c b/builtin/replace.c
 index 02b13f6..b58c714 100644
 --- a/builtin/replace.c
 +++ b/builtin/replace.c
 @@ -440,6 +440,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
  	};
  
  	check_replace_refs = 0;
 +	git_config(git_default_config, NULL);
  
  	argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
  
 @@ -475,7 +476,6 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
  		return replace_object(argv[0], argv[1], force);
  
  	case MODE_EDIT:
 -		git_config(git_default_config, NULL);
  		if (argc != 1)
  			usage_msg_opt("-e needs exactly one argument",
  				      git_replace_usage, options);


diff --git a/builtin/replace.c b/builtin/replace.c
index 748c6ca..b58c714 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -440,6 +440,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 	};
 
 	check_replace_refs = 0;
+	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
 
-- 
2.8.1.207.g7b140d3

```

## Jeff King, 2016-04-20 06:53

Subject: Re: [PATCH v2] replace --edit: respect core.editor
Message-ID: <20160420065349.GA14490@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20160420065349.GA14490%40sigill.intra.peff.net
In-Reply-To: <a7b889d525f99fecfb9d4a890fd2a5d4bf3001e0.1461134258.git.johannes.schindelin@gmx.de>

```
On Wed, Apr 20, 2016 at 08:38:03AM +0200, Johannes Schindelin wrote:

> We simply need to read the config, is all.
> 
> This fixes https://github.com/git-for-windows/git/issues/733
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

Looks good to me. Thanks.

-Peff

```

## Junio C Hamano, 2016-04-20 15:26

Subject: Re: [PATCH] replace --edit: respect core.editor
Message-ID: <xmqq7ffsxpvh.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq7ffsxpvh.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <alpine.DEB.2.20.1604200832430.2826@virtualbox>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi Junio,
>
> On Tue, 19 Apr 2016, Junio C Hamano wrote:
>
>> "git blame -L475,6 builtin/replace.c" points at b892bb45 (replace: add
>> --edit option, 2014-04-26) and the commit log message names two people
>> who can review this change, so that is what I am doing here.
>
> D'oh. Sorry.
> Dscho

Heh, no need to be sorry, that is what maintainers do.  If anything,
both of us need to thank them for commenting ;-)

```

## Junio C Hamano, 2016-04-20 15:29

Subject: Re: [PATCH v2] replace --edit: respect core.editor
Message-ID: <xmqq37qgxprl.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq37qgxprl.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20160420065349.GA14490@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Wed, Apr 20, 2016 at 08:38:03AM +0200, Johannes Schindelin wrote:
>
>> We simply need to read the config, is all.
>> 
>> This fixes https://github.com/git-for-windows/git/issues/733
>> 
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Looks good to me. Thanks.

Yup, I think the new placement is at the most logical place, just
before parse options.  I looked at other codepaths and I do not see
a reason why they shouldn't read the configuration variables.

Thanks, both.

```
