threads / discuss / 45368

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

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

## tl;dr

4 messages between Mar 13, 2017 and Mar 13, 2017.

replies: 3people: 3as markdown or json

Anthony Scian· Mar 13, 2017, 18:51 UTC · lore

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· Mar 13, 2017, 19:09 UTC · re: Anthony Scian · lore

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

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· Mar 13, 2017, 19:16 UTC · re: Jeff King · lore

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

Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> 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'.

Junio C Hamano· Mar 13, 2017, 19:13 UTC · re: Anthony Scian · lore

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

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.

← back to recent threads