# 'git add --patch' no longer allows you to select files before selecting patches

4 messages from 2017-03-13 to 2017-03-13. Participants: Anthony Scian, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/45368

## Anthony Scian, 2017-03-13 18:51

Subject: 'git add --patch' no longer allows you to select files before selecting patches
Message-ID: <DF55CDE6-E556-4C07-B661-0F5AA00D306E@auvik.com>
URL: https://gitlist.dev/e/DF55CDE6-E556-4C07-B661-0F5AA00D306E%40auvik.com

```
Similarly the patch sub-command in ‘git add —interactive’ goes immediately to selecting patches starting with the first file.
Is there a git configuration that would being back the old behaviour? Why was this changed?

here is a sample interaction that shows the ‘r’ sub-command still retains the desired behaviour of asking what files to involve but the ‘p’
sub-command immediately assumes all files are important and starts stepping through all the patches…

:~$ brew list
... git ...
:~$ which git
/usr/local/bin/git
:~$ git version
git version 2.12.0
:~$ 
:~$  git add --interactive
           staged     unstaged path
  1:    unchanged       +43/-2 core/src/main/scala/com/company/npl/planner/TrAc.scala
  2:    unchanged        +4/-4 core/src/main/scala/com/company/npl/tools/AnFu.scala
  3:    unchanged      +59/-12 core/src/main/scala/com/company/npl/tools/CoFu.scala
  4:    unchanged        +7/-1 module/reports/src/main/scala/com/company/npl/reports/ReStCo.scala
  5:    unchanged      +10/-23 runtime/src/main/npl/migrationSchemas/schema_for_migration_to_W4.npl
  6:    unchanged        +5/-3 runtime/src/main/scala/com/company/npl/table/adapter/InPe.scala
  7:    unchanged      +39/-82 runtime/src/main/scala/com/company/npl/table/migrations/schema_for_W4.scala
  8:    unchanged       +14/-1 ui/modules/admin/app/assets/javascripts/defs/de_sub.js

*** Commands ***
  1: status	  2: update	  3: revert	  4: add untracked
  5: patch	  6: diff	  7: quit	  8: help
What now> r
           staged     unstaged path
  1:    unchanged       +43/-2 core/src/main/scala/com/company/npl/planner/TrAc.scala
  2:    unchanged        +4/-4 core/src/main/scala/com/company/npl/tools/AnFu.scala
  3:    unchanged      +59/-12 core/src/main/scala/com/company/npl/tools/CoFu.scala
  4:    unchanged        +7/-1 module/reports/src/main/scala/com/company/npl/reports/ReStCo.scala
  5:    unchanged      +10/-23 runtime/src/main/npl/migrationSchemas/schema_for_migration_to_W4.npl
  6:    unchanged        +5/-3 runtime/src/main/scala/com/company/npl/table/adapter/InPe.scala
  7:    unchanged      +39/-82 runtime/src/main/scala/com/company/npl/table/migrations/schema_for_W4.scala
  8:    unchanged       +14/-1 ui/modules/admin/app/assets/javascripts/defs/de_sub.js
Revert>> 5
           staged     unstaged path
  1:    unchanged       +43/-2 core/src/main/scala/com/company/npl/planner/TrAc.scala
  2:    unchanged        +4/-4 core/src/main/scala/com/company/npl/tools/AnFu.scala
  3:    unchanged      +59/-12 core/src/main/scala/com/company/npl/tools/CoFu.scala
  4:    unchanged        +7/-1 module/reports/src/main/scala/com/company/npl/reports/ReStCo.scala
* 5:    unchanged      +10/-23 runtime/src/main/npl/migrationSchemas/schema_for_migration_to_W4.npl
  6:    unchanged        +5/-3 runtime/src/main/scala/com/company/npl/table/adapter/InPe.scala
  7:    unchanged      +39/-82 runtime/src/main/scala/com/company/npl/table/migrations/schema_for_W4.scala
  8:    unchanged       +14/-1 ui/modules/admin/app/assets/javascripts/defs/de_sub.js
Revert>> 7
           staged     unstaged path
  1:    unchanged       +43/-2 core/src/main/scala/com/company/npl/planner/TrAc.scala
  2:    unchanged        +4/-4 core/src/main/scala/com/company/npl/tools/AnFu.scala
  3:    unchanged      +59/-12 core/src/main/scala/com/company/npl/tools/CoFu.scala
  4:    unchanged        +7/-1 module/reports/src/main/scala/com/company/npl/reports/ReStCo.scala
* 5:    unchanged      +10/-23 runtime/src/main/npl/migrationSchemas/schema_for_migration_to_W4.npl
  6:    unchanged        +5/-3 runtime/src/main/scala/com/company/npl/table/adapter/InPe.scala
* 7:    unchanged      +39/-82 runtime/src/main/scala/com/company/npl/table/migrations/schema_for_W4.scala
  8:    unchanged       +14/-1 ui/modules/admin/app/assets/javascripts/defs/de_sub.js
Revert>> 
reverted 2 paths

*** Commands ***
  1: status	  2: update	  3: revert	  4: add untracked
  5: patch	  6: diff	  7: quit	  8: help
What now> p
diff --git a/core/src/main/scala/com/company/npl/planner/TrAc.scala b/core/src/main/scala/com/company/npl/planner/TrAc.scala
index 938cdc2a1b..669dc5f95b 100644
--- a/core/src/main/scala/com/company/npl/planner/TrAc.scala
+++ b/core/src/main/scala/com/company/npl/planner/TrAc.scala
@@ -24,8 +24,7 @@ import com.company.npl.tools.CoFu
  */
 case class TrAc(action: View with Generator, when: View, exceptWhen: Option[View], required: Boolean) {
   private def mergeAction(rhs: TrAc): View with Generator = action match {
-    case Always | Never =>
-      rhs.action
+    case Always | Never => rhs.action
     case _ =>
       require(rhs.action == Always || rhs.action == Never)
       action
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? q

*** Commands ***
  1: status	  2: update	  3: revert	  4: add untracked
  5: patch	  6: diff	  7: quit	  8: help
What now> q
Bye.
:~$




```

## Jeff King, 2017-03-13 19:09

Subject: Re: 'git add --patch' no longer allows you to select files before selecting patches
Message-ID: <20170313190936.vjyzdr2s2rc66frc@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20170313190936.vjyzdr2s2rc66frc%40sigill.intra.peff.net
In-Reply-To: <DF55CDE6-E556-4C07-B661-0F5AA00D306E@auvik.com>

```
On Mon, Mar 13, 2017 at 02:51:52PM -0400, Anthony Scian wrote:

> Similarly the patch sub-command in ‘git add —interactive’ goes
> immediately to selecting patches starting with the first file.
> Is there a git configuration that would being back the old behaviour?
> Why was this changed?

My, this seems to be a popular bug. This is the third report already. :)

The answer to your final question is that it's a bug. The fix is in
c852bd54bd87fdcdc825f5d45c26aa745be13ba6, which is currently in the
"master" branch of git.git.

Junio, I notice this isn't in "maint", and probably should be. It's a
regression in v2.12.0, so hopefully we'd fix it in v2.12.1.

-Peff

```

## Junio C Hamano, 2017-03-13 19:13

Subject: Re: 'git add --patch' no longer allows you to select files before selecting patches
Message-ID: <xmqq8to9rnwe.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq8to9rnwe.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <DF55CDE6-E556-4C07-B661-0F5AA00D306E@auvik.com>

```
Anthony Scian <ascian@auvik.com> writes:

> Similarly the patch sub-command in ‘git add —interactive’ goes
> immediately to selecting patches starting with the first file.  Is
> there a git configuration that would being back the old behaviour?
> Why was this changed?

Because people are careless ;-) 

The fix is already proposed and in the 'master' branch.  Please keep
using that version to make sure there is no unexpected regression
caused by the fix.

Thanks.

```

## Junio C Hamano, 2017-03-13 19:16

Subject: Re: 'git add --patch' no longer allows you to select files before selecting patches
Message-ID: <xmqq4lyxrnr3.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqq4lyxrnr3.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <20170313190936.vjyzdr2s2rc66frc@sigill.intra.peff.net>

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

> My, this seems to be a popular bug. This is the third report already. :)
>
> The answer to your final question is that it's a bug. The fix is in
> c852bd54bd87fdcdc825f5d45c26aa745be13ba6, which is currently in the
> "master" branch of git.git.

If only more people learn to run 'next', we would get less reports on
already fixed bug and instead get more reports on unexpected regressions
caused by these fixes, both of which would be a very good thing ;-)

> Junio, I notice this isn't in "maint", and probably should be. It's a
> regression in v2.12.0, so hopefully we'd fix it in v2.12.1.

Yes, thanks for an extra reminder.  The reason why I pushed it out
on 'master' during weekend is so that we can have it at least for a
few days there before merging it down to 'maint'.

```
