From: Wincent Colaiuta Date: Thu, 22 Nov 2007 01:41:12 GMT Subject: Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Message-ID: In-Reply-To: <7vk5obb09a.fsf@gitster.siamese.dyndns.org> El 22/11/2007, a las 1:18, Junio C Hamano escribió: > Wincent Colaiuta writes: > >> - Junio, do you mean to suggest with your comment that when passing >> untracked files either directly or indirectly (ie. when passing a dir >> containing untracked files) that they should be added (ie. invoked >> the >> "add untracked" subcommand) in addition to running the "patch" >> subcommand on the changed files? > > What I meant was that if "git add -i" (unrestricted) shows paths > from a set A, "git add -i paths..." should show paths from a > subset of the set A and that subset should be defined with the > existing ls-files pathspec semantics. > > For example, if "(a)dd untracked" subcommand shows all untracked > files when "add -i" was invoked without paths limitation, the > restricted form "add -i paths..." would show only untracked paths > that match the given set of patterns. If "(p)atch" subcommand > shows all modified tracked files when "add -i" was invoked > without paths limitation, the restricted form "add -i paths..." > would show only such modified tracked files whose names match > the given set of patterns. Ok, I've just posted a patch that implements this. This is now going somewhat beyond my knowledge of git-diff-index, git-diff-files, and git-diff-ls, so I am hoping someone more familiar with the plumbing can review this. Basically I'm mostly a porcelain user and have hardly touched the plumbing at all during these initial months using Git. There may be more efficient ways of doing this, but for now I am running git-ls-files once for each path parameter to determine whether it corresponds to any tracked file(s). This is necessary to weed out the untracked paths because passing these to git-diff-index or git- diff-files otherwise spits out errors to the stderr. Cheers, Wincent