git add --patch <path> fails or takes a looong time

258 views
Skip to first unread message

Michael Giuffrida

unread,
May 17, 2016, 2:32:18 PM5/17/16
to Chromium-dev
I'd like to interactively stage hunks of files in my working dir to my index, but the Chromium repo apparently has too many files:

$ git add -p .
Can't exec "git": Argument list too long at /usr/lib/git-core/git-add--interactive line 184.
Died at /usr/lib/git-core/git-add--interactive line 184.

In general, git add -p <pathspec> only seems to work when the paths contain a smalllll subset of files, and even then it can hang for a long time.

git add -p (without the pathspec) is much faster, but ignores newly created (untracked) files.

I found two possible solutions. One, you can interactively run patch and add untracked files:

$ git add -i

This doesn't let you edit untracked files though, you have to stage the entire file.

Two, you can stage the untracked files as empty files, then enter patch mode:

$ git add --intent-to-add . # track all newly created files
$ git add -p # interactive patch mode, including newly tracked files

Seems to do everything I want, so partly I'm sending this to document my solution (can't find it elsewhere).

But is there a better fix for the root issue of "my repo is too big for command line calls"?

Primiano Tucci

unread,
May 17, 2016, 2:40:21 PM5/17/16
to mich...@chromium.org, Chromium-dev
pro tip: if you like git add -p and you are not one of those terminal purists, you might like git-gui. there should be a package for any os, I use it regularly on Mac and Linux. [1] claims that there is both the msys and cyg version for Windows.
The gui is very retro (tcl-tk) but is very functional  when it comes to split patches or do surgeries. also it is one of the few things that works nicely over X11 forwarding, for the lovers of the genre.

[1]https://www.kernel.org/pub/software/scm/git/docs/git-gui.html


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
Reply all
Reply to author
Forward
0 new messages