git/list[1] front-page[2] threads[3] people[4] search[5] about
 

"git add -i" with path gives "Argument list too long"

From
Wincent Colaiuta <win@wincent.com>
Date
Jan 4, 2010, 18:43 UTC
Message-ID
<36FEB8A0-968D-4B43-AEFB-9B0E227A1F88@wincent.com>

Just ran "git add -i <path>" with "<path>" pointing to a subdirectory which happens to have a bunch of files in it (about 7k) and it barfed thusly:

   Can't exec "git": Argument list too long at /usr/local/libexec/git- 
core/git-add--interactive line 158.
   Died at /usr/local/libexec/git-core/git-add--interactive line 158.
I see that what it's trying to do under the hood is:
   git diff-index --cached --numstat --summary HEAD -- <7,000+ paths...>

Sure, we could divide the paths into smaller groups, run multiple invocations of "git diff-index", and concatenate the results. But it would be nicer if there was some other way that we could get at the same information without having to pass 7,000 paths explicitly on the command line; is there any which I am overlooking?

The enormous file list is the result of passing <path> into "git ls- files -- <path>". Would it be worth:

- either, modifying "git diff-index" to accept a list of paths over  
stdin so that we could at least pipe the output from "git ls-files"  
into "git diff-index"
- or, preferably, teach "git diff index" to recurse into directories  
rather than expect a list of paths-of-blobs (possibly with a command  
line switch to activate the behaviour if it were deemed a dangerous  
default)

This is one piece of plumbing that I've never dabbled with, so forgive me if my questions are a little dumb.

Cheers, Wincent

Next: Jeff King
Message 1 of 5 in “"git add -i" with path gives "Argument list too long"”
  1. Wincent ColaiutaJan 4, 2010
  2. Jeff KingJan 5, 2010
  3. Junio C HamanoJan 5, 2010
  4. Wincent ColaiutaJan 5, 2010
  5. Jeff KingJan 6, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.