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 21, 2007, 16:15 UTC
Message-ID
<A57F69DB-8AEC-4E48-8309-866D1B72C261@wincent.com>
In-Reply-To
<20071121152118.GG24108@sigill.intra.peff.net>
El 21/11/2007, a las 16:21, Jeff King escribió:
Show 21 quoted lines
> On Wed, Nov 21, 2007 at 01:36:39PM +0100, Wincent Colaiuta wrote:
>
>> +if ($#ARGV == 0) {
>> +	patch_update_file($ARGV[0]);
>> +}
>
> Why only one file? How about something like this instead:
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index fb1e92a..8036c95 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -804,5 +804,8 @@ sub main_loop {
> }
>
> refresh();
> +foreach my $file (@ARGV) {
> +	patch_update_file($file);
> +}
> status_cmd();
> main_loop();

Yes, that makes sense. I wasn't sure how to handle multiple files, but I guess just looping through them is fine.

Show 8 quoted lines
> On top of that, it would be great to be able to do something like
>
>  git-add -i *.c
>
> and just get prompted for changed files (right now, you only get
> prompted for changed files, but unchanged files seem to print a  
> spurious
> newline).

That spurious newline comes from the last line of the patch_update_file function (previously named patch_update_cmd):

	print "\n";

The solution will be to do an early return, printing nothing for those unchanged files (and same thing for untracked files). Will look into it.

> And at any rate, this would require fixing 3/4 to handle the multiple
> files from git-add.
>
> What do you think?

Should have some time later this evening or tomorrow to incorporate your suggestions.

Cheers, Wincent

Previous: Jeff KingNext: Junio C Hamano
Message 7 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.