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

Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch

From
Wincent Colaiuta <win@wincent.com>
Date
Nov 22, 2007, 01:41 UTC
Message-ID
<A10705BB-3825-49A8-9766-58479237D04C@wincent.com>
In-Reply-To
<7vk5obb09a.fsf@gitster.siamese.dyndns.org>
El 22/11/2007, a las 1:18, Junio C Hamano escribió:
Show 22 quoted lines
> Wincent Colaiuta <win@wincent.com> 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

Previous: Wincent ColaiutaNext: Jeff King
Message 29 of 39 in “teaching git-add--interactive to accept a file param”
  1. teaching git-add--interactive to accept a file paramWincent Colaiuta, Nov 21, 2007
  2. 1/4 Refactor patch_update_cmdWincent Colaiuta, Nov 21, 2007
  3. 2/4 Teach git-add--interactive to accept a file path to patchWincent Colaiuta, Nov 21, 2007
  4. 3/4 Teach builtin-add to pass a path argument to git-add--interactiveWincent Colaiuta, Nov 21, 2007
  5. 4/4 Document optional file parameter to git-add--interactiveWincent Colaiuta, Nov 21, 2007
  6. Jeff KingNov 21, 2007
  7. Wincent ColaiutaNov 21, 2007
  8. Junio C HamanoNov 21, 2007
  9. Wincent ColaiutaNov 21, 2007
  10. Updates: teaching git-add--interactive to accept a file paramWincent Colaiuta, Nov 22, 2007
  11. 1/4 Suppress spurious linefeeds in git-add--interactiveWincent Colaiuta, Nov 22, 2007
  12. 2/4 Teach git-add--interactive to accept multiple file paramsWincent Colaiuta, Nov 22, 2007
  13. 3/4 Teach builtin-add to pass multiple paths to git-add--interactiveWincent Colaiuta, Nov 22, 2007
  14. 4/4 Update git-add documentation for multiple interactive pathsWincent Colaiuta, Nov 22, 2007
  15. Jeff KingNov 22, 2007
  16. Wincent ColaiutaNov 22, 2007
  17. Jeff KingNov 22, 2007
  18. Wincent ColaiutaNov 22, 2007
  19. Jeff KingNov 22, 2007
  20. Jeff KingNov 22, 2007
  21. Wincent ColaiutaNov 22, 2007
  22. Junio C HamanoNov 22, 2007
  23. Junio C HamanoNov 22, 2007
  24. Add path-limiting to git-add--interactiveWincent Colaiuta, Nov 22, 2007
  25. Junio C HamanoNov 22, 2007
  26. Junio C HamanoNov 22, 2007
  27. Wincent ColaiutaNov 22, 2007
  28. Wincent ColaiutaNov 22, 2007
  29. Wincent ColaiutaNov 22, 2007
  30. Jeff KingNov 22, 2007
  31. Junio C HamanoNov 22, 2007
  32. Jeff KingNov 22, 2007
  33. Wincent ColaiutaNov 22, 2007
  34. Jeff KingNov 22, 2007
  35. Junio C HamanoNov 22, 2007
  36. Jeff KingNov 22, 2007
  37. Wincent ColaiutaNov 22, 2007
  38. Junio C HamanoNov 22, 2007
  39. Wincent ColaiutaNov 22, 2007

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.