# [BUG] (git commit --patch --message $MESSAGE) disallows hunk editing

3 messages from 2012-10-23 to 2014-09-29. Participants: Max Nanasy, Pierre-Olivier Vares.
Thread: https://gitlist.dev/t/31912

## Max Nanasy, 2012-10-23 05:48

Subject: [BUG] (git commit --patch --message $MESSAGE) disallows hunk editing
Message-ID: <CAM998vGieYU+8s1ermDJSfT8Zu8jDRS4WLjypraoB3iOf+qH7g@mail.gmail.com>
URL: https://gitlist.dev/e/CAM998vGieYU%2B8s1ermDJSfT8Zu8jDRS4WLjypraoB3iOf%2BqH7g%40mail.gmail.com

```
Tested against v1.7.12.4

Steps to reproduce:
	A. cd $DIRTY_WORKING_COPY
	B. git commit --patch --message $MESSAGE
	C. Stage this hunk? e
Expected behavior:
	After step C, the hunk opens in the user's editor
Actual behavior:
	After step C, the hunk is selected unedited (as if the user had entered "y")

AFAICT, this occurs because of the following code in
builtin/commit.c:parse_and_validate_options:
	if (... || message.len || ...)
		use_editor = 0;
	...
	if (!use_editor)
		setenv("GIT_EDITOR", ":", 1);
Because --message is specified, GIT_EDITOR is set to ":", which
prevents the user from editing hunks, although the intent is most
likely to just prevent the user from editing the commit message.

```

## Pierre-Olivier Vares, 2014-02-26 15:07

Subject: Re: [BUG] (git commit --patch --message $MESSAGE) disallows hunk editing
Message-ID: <loom.20140226T160605-845@post.gmane.org>
URL: https://gitlist.dev/e/loom.20140226T160605-845%40post.gmane.org
In-Reply-To: <CAM998vGieYU+8s1ermDJSfT8Zu8jDRS4WLjypraoB3iOf+qH7g@mail.gmail.com>

```
Max Nanasy <max.nanasy <at> gmail.com> writes:

> Tested against v1.7.12.4

Confirmed in 1.8.5.2

```

## Max Nanasy, 2014-09-29 23:01

Subject: Re: [BUG] (git commit --patch --message $MESSAGE) disallows hunk editing
Message-ID: <loom.20140930T005553-169@post.gmane.org>
URL: https://gitlist.dev/e/loom.20140930T005553-169%40post.gmane.org
In-Reply-To: <CAM998vGieYU+8s1ermDJSfT8Zu8jDRS4WLjypraoB3iOf+qH7g@mail.gmail.com>

```
Max Nanasy <max.nanasy <at> gmail.com> writes:

> 
> Tested against v1.7.12.4
> 
> Steps to reproduce:
> 	A. cd $DIRTY_WORKING_COPY
> 	B. git commit --patch --message $MESSAGE
> 	C. Stage this hunk? e
> Expected behavior:
> 	After step C, the hunk opens in the user's editor
> Actual behavior:
> 	After step C, the hunk is selected unedited (as if the user had entered "y")
> 
> AFAICT, this occurs because of the following code in
> builtin/commit.c:parse_and_validate_options:
> 	if (... || message.len || ...)
> 		use_editor = 0;
> 	...
> 	if (!use_editor)
> 		setenv("GIT_EDITOR", ":", 1);
> Because --message is specified, GIT_EDITOR is set to ":", which
> prevents the user from editing hunks, although the intent is most
> likely to just prevent the user from editing the commit message.
> 

It appears that this was fixed in version 2.0.  The changelog entry says:

 * When it is not necessary to edit a commit log message (e.g. "git
   commit -m" is given a message without specifying "-e"), we used to
   disable the spawning of the editor by overriding GIT_EDITOR, but
   this means all the uses of the editor, other than to edit the
   commit log message, are also affected.
   (merge b549be0 bp/commit-p-editor later to maint).

```
