{"thread":{"id":"10956","subject":"[PATCH 1/4] Refactor patch_update_cmd","startedAt":"2007-11-21T12:36:37Z","lastAt":"2007-11-22T21:55:37Z","messageCount":39,"participants":["Wincent Colaiuta","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"60502","messageId":"1195648601-21736-1-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":null,"subject":"[PATCH] teaching git-add--interactive to accept a file param","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:36:37Z","receivedAt":"2007-11-21T12:36:37Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Back in October a thread came up, \"Proposed git mv behavioral change\",\nand I inadvertently suggested a new feature for git-add--interactive;\nthe ability to supply an optional file path parameter and jump straight\nto the \"patch\" subcommand for that file:\n\n<http://kerneltrap.org/mailarchive/git/2007/10/19/348229>\n\nThis small patch series implements that suggestion:\n\n      Refactor patch_update_cmd\n      Teach git-add--interactive to accept a file path to patch\n      Teach builtin-add to pass a path argument to git-add--interactive\n      Document optional file parameter to git-add--interactive\n\nIt applies against the current master. I've not yet submitted many\npatches to Git, so please be gentle!\n                        \nDocumentation/git-add.txt |    5 ++++-\nbuiltin-add.c             |   16 ++++++++++------\ncommit.h                  |    2 +-\ngit-add--interactive.perl |   11 +++++++++--\n4 files changed, 24 insertions(+), 10 deletions(-)\n"},{"id":"60499","messageId":"1195648601-21736-2-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195648601-21736-1-git-send-email-win@wincent.com","subject":"[PATCH 1/4] Refactor patch_update_cmd","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:36:38Z","receivedAt":"2007-11-21T12:36:38Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Split patch_update_cmd into two functions, one to prompt the user for\na path to patch and another to do the actual work given that file path.\nThis lays the groundwork for a future commit which will teach\ngit-add--interactive to accept a path parameter and jump directly to\nthe patch subcommand for that path, bypassing the interactive prompt.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-add--interactive.perl |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 0317ad9..fb1e92a 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -564,10 +564,12 @@ sub patch_update_cmd {\n \t\t\t\t     IMMEDIATE => 1,\n \t\t\t\t     HEADER => $status_head, },\n \t\t\t\t   @mods);\n-\treturn if (!$it);\n+\tpatch_update_file($it->{VALUE}) if ($it);\n+}\n \n+sub patch_update_file {\n \tmy ($ix, $num);\n-\tmy $path = $it->{VALUE};\n+\tmy $path = shift;\n \tmy ($head, @hunk) = parse_diff($path);\n \tfor (@{$head->{TEXT}}) {\n \t\tprint;\n-- \n1.5.3.5.737.gdee1b\n"},{"id":"60503","messageId":"1195648601-21736-3-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195648601-21736-2-git-send-email-win@wincent.com","subject":"[PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:36:39Z","receivedAt":"2007-11-21T12:36:39Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"If supplied a single file path parameter the git-add--interactive script\nnow bypasses the command loop and jumps straight to the patch subcommand\nusing the passed path. After returning from the subcommand the main\ncommand loop is entered. If a non-resolvable path is supplied the\noperation is a no-op and the command loop is entered.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-add--interactive.perl |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex fb1e92a..8f21c03 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -803,6 +803,11 @@ sub main_loop {\n \t}\n }\n \n+die \"add --interactive may take only 1 optional parameter\" if ($#ARGV > 0);\n refresh();\n+if ($#ARGV == 0) {\n+\tpatch_update_file($ARGV[0]);\n+}\n status_cmd();\n main_loop();\n+\n-- \n1.5.3.5.737.gdee1b\n"},{"id":"60500","messageId":"1195648601-21736-4-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195648601-21736-3-git-send-email-win@wincent.com","subject":"[PATCH 3/4] Teach builtin-add to pass a path argument to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:36:40Z","receivedAt":"2007-11-21T12:36:40Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"The previous patch in the series taught git-add--interactive to handle\na single optional path argument. This patch teaches builtin-add to pass\nthis argument through to the script.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n builtin-add.c |   16 ++++++++++------\n commit.h      |    2 +-\n 2 files changed, 11 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex cf815a0..278c02e 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -135,9 +135,9 @@ static void refresh(int verbose, const char **pathspec)\n         free(seen);\n }\n \n-int interactive_add(void)\n+int interactive_add(const char *path)\n {\n-\tconst char *argv[2] = { \"add--interactive\", NULL };\n+\tconst char *argv[3] = { \"add--interactive\", path, NULL };\n \n \treturn run_command_v_opt(argv, RUN_GIT_CMD);\n }\n@@ -163,16 +163,20 @@ static struct option builtin_add_options[] = {\n \n int cmd_add(int argc, const char **argv, const char *prefix)\n {\n-\tint i, newfd, orig_argc = argc;\n+\tint i, newfd = argc;\n \tconst char **pathspec;\n \tstruct dir_struct dir;\n \n \targc = parse_options(argc, argv, builtin_add_options,\n \t\t\t  builtin_add_usage, 0);\n \tif (add_interactive) {\n-\t\tif (add_interactive != 1 || orig_argc != 2)\n-\t\t\tdie(\"add --interactive does not take any parameters\");\n-\t\texit(interactive_add());\n+\t\tif (argc > 1)\n+\t\t\tdie(\"add --interactive may take only 1 optional \"\n+\t\t\t    \"parameter\");\n+\t\telse if (argc == 1)\n+\t\t\texit(interactive_add(argv[0]));\n+\t\telse\n+\t\t\texit(interactive_add(NULL));\n \t}\n \n \tgit_config(git_default_config);\ndiff --git a/commit.h b/commit.h\nindex aa67986..03a6ec5 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \n int in_merge_bases(struct commit *, struct commit **, int);\n \n-extern int interactive_add(void);\n+extern int interactive_add(const char *path);\n extern void add_files_to_cache(int verbose, const char *prefix, const char **files);\n extern int rerere(void);\n \n-- \n1.5.3.5.737.gdee1b\n"},{"id":"60501","messageId":"1195648601-21736-5-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195648601-21736-4-git-send-email-win@wincent.com","subject":"[PATCH 4/4] Document optional file parameter to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T12:36:41Z","receivedAt":"2007-11-21T12:36:41Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Update the documentation for git-add to mention the new optional\nfile parameter to git-add--interactive.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n Documentation/git-add.txt |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 63829d9..4b44802 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -61,7 +61,10 @@ OPTIONS\n \n -i, \\--interactive::\n \tAdd modified contents in the working tree interactively to\n-\tthe index.\n+\tthe index. If a single optional file argument is supplied the\n+\tinitial command loop is bypassed and the 'patch' subcommand is\n+\tinvoked for the specified file. See ``Interactive mode'' below\n+\tfor details.\n \n -u::\n \tUpdate only files that git already knows about. This is similar\n-- \n1.5.3.5.737.gdee1b\n"},{"id":"60526","messageId":"20071121152118.GG24108@sigill.intra.peff.net","threadId":"10956","inReplyTo":"1195648601-21736-3-git-send-email-win@wincent.com","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-21T15:21:18Z","receivedAt":"2007-11-21T15:21:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 21, 2007 at 01:36:39PM +0100, Wincent Colaiuta wrote:\n\n> If supplied a single file path parameter the git-add--interactive script\n> now bypasses the command loop and jumps straight to the patch subcommand\n> using the passed path. After returning from the subcommand the main\n> command loop is entered. If a non-resolvable path is supplied the\n> operation is a no-op and the command loop is entered.\n\nGreat, the lack of this feature has bugged me in the past. Thank you for\nworking on it. However...\n\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index fb1e92a..8f21c03 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -803,6 +803,11 @@ sub main_loop {\n>  \t}\n>  }\n>  \n> +die \"add --interactive may take only 1 optional parameter\" if ($#ARGV > 0);\n>  refresh();\n> +if ($#ARGV == 0) {\n> +\tpatch_update_file($ARGV[0]);\n> +}\n>  status_cmd();\n>  main_loop();\n> +\n\nWhy only one file? How about something like this instead:\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex fb1e92a..8036c95 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -804,5 +804,8 @@ sub main_loop {\n }\n \n refresh();\n+foreach my $file (@ARGV) {\n+\tpatch_update_file($file);\n+}\n status_cmd();\n main_loop();\n\n\nOn top of that, it would be great to be able to do something like\n\n  git-add -i *.c\n\nand just get prompted for changed files (right now, you only get\nprompted for changed files, but unchanged files seem to print a spurious\nnewline).\n\nAnd at any rate, this would require fixing 3/4 to handle the multiple\nfiles from git-add.\n\nWhat do you think?\n\n-Peff\n"},{"id":"60537","messageId":"A57F69DB-8AEC-4E48-8309-866D1B72C261@wincent.com","threadId":"10956","inReplyTo":"20071121152118.GG24108@sigill.intra.peff.net","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T16:15:59Z","receivedAt":"2007-11-21T16:15:59Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 21/11/2007, a las 16:21, Jeff King escribió:\n\n> On Wed, Nov 21, 2007 at 01:36:39PM +0100, Wincent Colaiuta wrote:\n>\n>> +if ($#ARGV == 0) {\n>> +\tpatch_update_file($ARGV[0]);\n>> +}\n>\n> Why only one file? How about something like this instead:\n>\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index fb1e92a..8036c95 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -804,5 +804,8 @@ sub main_loop {\n> }\n>\n> refresh();\n> +foreach my $file (@ARGV) {\n> +\tpatch_update_file($file);\n> +}\n> status_cmd();\n> main_loop();\n\nYes, that makes sense. I wasn't sure how to handle multiple files, but  \nI guess just looping through them is fine.\n\n> On top of that, it would be great to be able to do something like\n>\n>  git-add -i *.c\n>\n> and just get prompted for changed files (right now, you only get\n> prompted for changed files, but unchanged files seem to print a  \n> spurious\n> newline).\n\nThat spurious newline comes from the last line of the  \npatch_update_file function (previously named patch_update_cmd):\n\n\tprint \"\\n\";\n\nThe solution will be to do an early return, printing nothing for those  \nunchanged files (and same thing for untracked files). Will look into it.\n\n> And at any rate, this would require fixing 3/4 to handle the multiple\n> files from git-add.\n>\n> What do you think?\n\nShould have some time later this evening or tomorrow to incorporate  \nyour suggestions.\n\nCheers,\nWincent\n"},{"id":"60568","messageId":"7vejejfi28.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"20071121152118.GG24108@sigill.intra.peff.net","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-21T20:40:47Z","receivedAt":"2007-11-21T20:40:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> ...\n> On top of that, it would be great to be able to do something like\n>\n>   git-add -i *.c\n>\n> and just get prompted for changed files (right now, you only get\n> prompted for changed files, but unchanged files seem to print a spurious\n> newline).\n>\n> And at any rate, this would require fixing 3/4 to handle the multiple\n> files from git-add.\n>\n> What do you think?\n\nIf we are to add path limited behaviour, I think it should also\ngrok \"git-add -i sub/dir/\".  IOW, you would want to have the\nsame path selection semantics as git-add without the\n\"interactive\" bit.\n"},{"id":"60573","messageId":"C6E820C8-91E9-48B2-9219-377CA83163A7@wincent.com","threadId":"10956","inReplyTo":"7vejejfi28.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-21T22:44:33Z","receivedAt":"2007-11-21T22:44:33Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 21/11/2007, a las 21:40, Junio C Hamano escribió:\n\n> Jeff King <peff@peff.net> writes:\n>\n>> ...\n>> On top of that, it would be great to be able to do something like\n>>\n>>  git-add -i *.c\n>>\n>> and just get prompted for changed files (right now, you only get\n>> prompted for changed files, but unchanged files seem to print a  \n>> spurious\n>> newline).\n>>\n>> And at any rate, this would require fixing 3/4 to handle the multiple\n>> files from git-add.\n>>\n>> What do you think?\n>\n> If we are to add path limited behaviour, I think it should also\n> grok \"git-add -i sub/dir/\".  IOW, you would want to have the\n> same path selection semantics as git-add without the\n> \"interactive\" bit.\n\nI can work on adding support for dirs as well as files, but am  \nwondering what the desired behaviour is:\n\n- Jeff would like to pass \"*.c\" and have it only add changed files,  \nnot unchanged or untracked files\n\n- Junio, do you mean to suggest with your comment that when passing  \nuntracked files either directly or indirectly (ie. when passing a dir  \ncontaining untracked files) that they should be added (ie. invoked the  \n\"add untracked\" subcommand) in addition to running the \"patch\"  \nsubcommand on the changed files?\n\nOf these two approaches, I suspect that the latter would be more  \n\"correct\", because it would be consistent with the \"not interactive\"  \nversion of git-add.\n\nCheers,\nWincent\n"},{"id":"60580","messageId":"1195689773-28601-1-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"C6E820C8-91E9-48B2-9219-377CA83163A7@wincent.com","subject":"Updates: teaching git-add--interactive to accept a file param","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T00:02:49Z","receivedAt":"2007-11-22T00:02:49Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Here are some incremental updates incorporating the feedback received on the\npatch series that I sent earlier today. These apply on top of the previous\npatches; when this series matures I'll rebase and squash this down to a\nsmaller number of commits, but for the timebeing I think it's clearer if I\npost these modifications separately so they can be reviewed in themselves.\n\nThe modifications are:\n\n      Suppress spurious linefeeds in git-add--interactive\n      Teach git-add--interactive to accept multiple file params\n      Teach builtin-add to pass multiple paths to git-add--interactive\n      Update git-add documentation for multiple interactive paths\n\nNext step will be to follow-up on Junio's suggestion that we should support\ndirectory paths, not just file paths, and replicate the semantics of\nnon-interactive git-add.\n\n Documentation/git-add.txt |    4 ++--\n builtin-add.c             |   23 +++++++++++++----------\n commit.h                  |    2 +-\n git-add--interactive.perl |    5 ++---\n 4 files changed, 18 insertions(+), 16 deletions(-)\n"},{"id":"60579","messageId":"1195689773-28601-2-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195689773-28601-1-git-send-email-win@wincent.com","subject":"[PATCH 1/4] Suppress spurious linefeeds in git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T00:02:50Z","receivedAt":"2007-11-22T00:02:50Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Eliminate the spurious linefeed echoed to the terminal when passing an\nuntracked or unchanged file as a parameter to git-add--interactive.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-add--interactive.perl |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 8f21c03..95e537c 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -336,6 +336,7 @@ sub add_untracked_cmd {\n sub parse_diff {\n \tmy ($path) = @_;\n \tmy @diff = run_cmd_pipe(qw(git diff-files -p --), $path);\n+\treturn undef if ($#diff == -1);\n \tmy (@hunk) = { TEXT => [] };\n \n \tfor (@diff) {\n@@ -571,6 +572,7 @@ sub patch_update_file {\n \tmy ($ix, $num);\n \tmy $path = shift;\n \tmy ($head, @hunk) = parse_diff($path);\n+\treturn unless $head;\n \tfor (@{$head->{TEXT}}) {\n \t\tprint;\n \t}\n-- \n1.5.3.6.867.g539b6-dirty\n"},{"id":"60582","messageId":"1195689773-28601-3-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195689773-28601-2-git-send-email-win@wincent.com","subject":"[PATCH 2/4] Teach git-add--interactive to accept multiple file params","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T00:02:51Z","receivedAt":"2007-11-22T00:02:51Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"As per Jeff King's suggestion, this commit teaches git-add--interactive\nto accept multiple optional file parameters, which will be fed into the\n\"patch\" subcommand one by one. After all parameters are processed we\ndrop back into the standard command loop.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-add--interactive.perl |    5 ++---\n 1 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 95e537c..2bba07d 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -805,10 +805,9 @@ sub main_loop {\n \t}\n }\n \n-die \"add --interactive may take only 1 optional parameter\" if ($#ARGV > 0);\n refresh();\n-if ($#ARGV == 0) {\n-\tpatch_update_file($ARGV[0]);\n+foreach my $file (@ARGV) {\n+\tpatch_update_file($file);\n }\n status_cmd();\n main_loop();\n-- \n1.5.3.6.867.g539b6-dirty\n"},{"id":"60583","messageId":"1195689773-28601-4-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195689773-28601-3-git-send-email-win@wincent.com","subject":"[PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T00:02:52Z","receivedAt":"2007-11-22T00:02:52Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Instead of just accepting a single file parameter, git-add now accepts\nany number of path parameters, fowarding them to git-add--interactive.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n builtin-add.c |   23 +++++++++++++----------\n commit.h      |    2 +-\n 2 files changed, 14 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex 278c02e..13f27e8 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -135,11 +135,17 @@ static void refresh(int verbose, const char **pathspec)\n         free(seen);\n }\n \n-int interactive_add(const char *path)\n+int interactive_add(const char **argv, int argc)\n {\n-\tconst char *argv[3] = { \"add--interactive\", path, NULL };\n-\n-\treturn run_command_v_opt(argv, RUN_GIT_CMD);\n+\tint status;\n+\tconst char **args = xmalloc(sizeof(const char *) * (argc + 1));\n+\targs[0] = \"add--interactive\";\n+\tmemcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);\n+\targs[argc + 1] = NULL;\n+\n+\tstatus = run_command_v_opt(args, RUN_GIT_CMD);\n+\tfree(args);\n+\treturn status;\n }\n \n static struct lock_file lock_file;\n@@ -170,13 +176,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, builtin_add_options,\n \t\t\t  builtin_add_usage, 0);\n \tif (add_interactive) {\n-\t\tif (argc > 1)\n-\t\t\tdie(\"add --interactive may take only 1 optional \"\n-\t\t\t    \"parameter\");\n-\t\telse if (argc == 1)\n-\t\t\texit(interactive_add(argv[0]));\n+\t\tif (argc > 0)\n+\t\t\texit(interactive_add(argv, argc));\n \t\telse\n-\t\t\texit(interactive_add(NULL));\n+\t\t\texit(interactive_add(NULL, 0));\n \t}\n \n \tgit_config(git_default_config);\ndiff --git a/commit.h b/commit.h\nindex 03a6ec5..3a398fc 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -113,7 +113,7 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \n int in_merge_bases(struct commit *, struct commit **, int);\n \n-extern int interactive_add(const char *path);\n+extern int interactive_add(const char **argv, int argc);\n extern void add_files_to_cache(int verbose, const char *prefix, const char **files);\n extern int rerere(void);\n \n-- \n1.5.3.6.867.g539b6-dirty\n"},{"id":"60581","messageId":"1195689773-28601-5-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"1195689773-28601-4-git-send-email-win@wincent.com","subject":"[PATCH 4/4] Update git-add documentation for multiple interactive paths","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T00:02:53Z","receivedAt":"2007-11-22T00:02:53Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Tweak the documentation to reflect that git-add--interactive can now\naccept multiple path parameters.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n Documentation/git-add.txt |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 4b44802..0675dbe 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -61,9 +61,9 @@ OPTIONS\n \n -i, \\--interactive::\n \tAdd modified contents in the working tree interactively to\n-\tthe index. If a single optional file argument is supplied the\n+\tthe index. If optional path arguments are supplied the\n \tinitial command loop is bypassed and the 'patch' subcommand is\n-\tinvoked for the specified file. See ``Interactive mode'' below\n+\tinvoked for each specified path. See ``Interactive mode'' below\n \tfor details.\n \n -u::\n-- \n1.5.3.6.867.g539b6-dirty\n"},{"id":"60584","messageId":"7vk5obb09a.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"C6E820C8-91E9-48B2-9219-377CA83163A7@wincent.com","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T00:18:57Z","receivedAt":"2007-11-22T00:18:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> - Junio, do you mean to suggest with your comment that when passing\n> untracked files either directly or indirectly (ie. when passing a dir\n> containing untracked files) that they should be added (ie. invoked the\n> \"add untracked\" subcommand) in addition to running the \"patch\"\n> subcommand on the changed files?\n\nWhat I meant was that if \"git add -i\" (unrestricted) shows paths\nfrom a set A, \"git add -i paths...\" should show paths from a\nsubset of the set A and that subset should be defined with the\nexisting ls-files pathspec semantics.\n\nFor example, if \"(a)dd untracked\" subcommand shows all untracked\nfiles when \"add -i\" was invoked without paths limitation, the\nrestricted form \"add -i paths...\" would show only untracked paths\nthat match the given set of patterns.  If \"(p)atch\" subcommand\nshows all modified tracked files when \"add -i\" was invoked\nwithout paths limitation, the restricted form \"add -i paths...\"\nwould show only such modified tracked files whose names match\nthe given set of patterns.\n"},{"id":"60593","messageId":"1195695384-41329-1-git-send-email-win@wincent.com","threadId":"10956","inReplyTo":"7vk5obb09a.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Add path-limiting to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T01:36:24Z","receivedAt":"2007-11-22T01:36:24Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Implement Junio's suggestion that git-add--interactive should reproduce the\npath-limiting semantics of non-interactive git-add.\n\nIn otherwords, if \"git add -i\" (unrestricted) shows paths from a set A,\n\"git add -i paths...\" should show paths from a subset of the set A and that\nsubset should be defined with the existing ls-files pathspec semantics.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n git-add--interactive.perl |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 2bba07d..a5a07bc 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -37,7 +37,7 @@ sub list_untracked {\n \t\tchomp $_;\n \t\t$_;\n \t}\n-\trun_cmd_pipe(qw(git ls-files --others --exclude-standard --), @_);\n+\trun_cmd_pipe(qw(git ls-files --others --exclude-standard --), @ARGV);\n }\n \n my $status_fmt = '%12s %12s %s';\n@@ -56,9 +56,14 @@ sub list_modified {\n \tmy ($only) = @_;\n \tmy (%data, @return);\n \tmy ($add, $del, $adddel, $file);\n+\tmy @tracked = grep {\n+\t\tdefined run_cmd_pipe(qw(git ls-files\n+\t\t\t                --exclude-standard --), $_)\n+\t} @ARGV;\n+\treturn if $#tracked == -1 && $#ARGV != -1;\n \n \tfor (run_cmd_pipe(qw(git diff-index --cached\n-\t\t\t     --numstat --summary HEAD))) {\n+\t\t\t     --numstat --summary HEAD --), @tracked)) {\n \t\tif (($add, $del, $file) =\n \t\t    /^([-\\d]+)\t([-\\d]+)\t(.*)/) {\n \t\t\tmy ($change, $bin);\n@@ -81,7 +86,7 @@ sub list_modified {\n \t\t}\n \t}\n \n-\tfor (run_cmd_pipe(qw(git diff-files --numstat --summary))) {\n+\tfor (run_cmd_pipe(qw(git diff-files --numstat --summary --), @tracked)) {\n \t\tif (($add, $del, $file) =\n \t\t    /^([-\\d]+)\t([-\\d]+)\t(.*)/) {\n \t\t\tif (!exists $data{$file}) {\n-- \n1.5.3.6.870.g8799-dirty\n"},{"id":"60595","messageId":"A10705BB-3825-49A8-9766-58479237D04C@wincent.com","threadId":"10956","inReplyTo":"7vk5obb09a.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T01:41:12Z","receivedAt":"2007-11-22T01:41:12Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 1:18, Junio C Hamano escribió:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> - Junio, do you mean to suggest with your comment that when passing\n>> untracked files either directly or indirectly (ie. when passing a dir\n>> containing untracked files) that they should be added (ie. invoked  \n>> the\n>> \"add untracked\" subcommand) in addition to running the \"patch\"\n>> subcommand on the changed files?\n>\n> What I meant was that if \"git add -i\" (unrestricted) shows paths\n> from a set A, \"git add -i paths...\" should show paths from a\n> subset of the set A and that subset should be defined with the\n> existing ls-files pathspec semantics.\n>\n> For example, if \"(a)dd untracked\" subcommand shows all untracked\n> files when \"add -i\" was invoked without paths limitation, the\n> restricted form \"add -i paths...\" would show only untracked paths\n> that match the given set of patterns.  If \"(p)atch\" subcommand\n> shows all modified tracked files when \"add -i\" was invoked\n> without paths limitation, the restricted form \"add -i paths...\"\n> would show only such modified tracked files whose names match\n> the given set of patterns.\n\nOk, I've just posted a patch that implements this. This is now going  \nsomewhat beyond my knowledge of git-diff-index, git-diff-files, and  \ngit-diff-ls, so I am hoping someone more familiar with the plumbing  \ncan review this. Basically I'm mostly a porcelain user and have hardly  \ntouched the plumbing at all during these initial months using Git.\n\nThere may be more efficient ways of doing this, but for now I am  \nrunning git-ls-files once for each path parameter to determine whether  \nit corresponds to any tracked file(s). This is necessary to weed out  \nthe untracked paths because passing these to git-diff-index or git- \ndiff-files otherwise spits out errors to the stderr.\n\nCheers,\nWincent\n"},{"id":"60622","messageId":"20071122085919.GB7153@sigill.intra.peff.net","threadId":"10956","inReplyTo":"1195689773-28601-2-git-send-email-win@wincent.com","subject":"Re: [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T08:59:20Z","receivedAt":"2007-11-22T08:59:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 01:02:50AM +0100, Wincent Colaiuta wrote:\n\n> +\treturn undef if ($#diff == -1);\n\nStyle nit: I think the rest of the code generally uses (and I prefer)\n\"@diff\" to get the number of elements. So:\n\n  return undef unless @diff;\n\nor I might even have written\n\n  my @diff = ...\n    or return undef;\n\nbut perhaps I am the only one who finds $#array comparisons to -1 hard\non the eyes.\n\n-Peff\n"},{"id":"60623","messageId":"20071122090828.GC7153@sigill.intra.peff.net","threadId":"10956","inReplyTo":"1195689773-28601-4-git-send-email-win@wincent.com","subject":"Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T09:08:28Z","receivedAt":"2007-11-22T09:08:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 01:02:52AM +0100, Wincent Colaiuta wrote:\n\n> -int interactive_add(const char *path)\n> +int interactive_add(const char **argv, int argc)\n>  {\n> -\tconst char *argv[3] = { \"add--interactive\", path, NULL };\n> -\n> -\treturn run_command_v_opt(argv, RUN_GIT_CMD);\n> +\tint status;\n> +\tconst char **args = xmalloc(sizeof(const char *) * (argc + 1));\n> +\targs[0] = \"add--interactive\";\n> +\tmemcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);\n\nThe source for the memcpy (argv) is sometimes NULL. The standard forbids\nthis, even when the size field is 0. I have no idea if any reasonable\nimplementations actually care.\n\nBut...\n\n> +\t\tif (argc > 0)\n> +\t\t\texit(interactive_add(argv, argc));\n>  \t\telse\n> -\t\t\texit(interactive_add(NULL));\n> +\t\t\texit(interactive_add(NULL, 0));\n\nThere really is no reason to pass NULL at all (since the argc limits us\nanyway), so we can just get rid of the conditional and simplify to:\n\n  exit(interactive_add(argv, argc));\n\nfor both cases.\n\n-Peff\n"},{"id":"60624","messageId":"7vpry27id0.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"1195695384-41329-1-git-send-email-win@wincent.com","subject":"Re: [PATCH] Add path-limiting to git-add--interactive","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T09:13:47Z","receivedAt":"2007-11-22T09:13:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> @@ -56,9 +56,14 @@ sub list_modified {\n>  \tmy ($only) = @_;\n>  \tmy (%data, @return);\n>  \tmy ($add, $del, $adddel, $file);\n> +\tmy @tracked = grep {\n> +\t\tdefined run_cmd_pipe(qw(git ls-files\n> +\t\t\t                --exclude-standard --), $_)\n> +\t} @ARGV;\n> +\treturn if $#tracked == -1 && $#ARGV != -1;\n\nEek.  why?\n\nDid you mean to say:\n\n    my @tracked = run_cmd_pipe(gw(git ls-files --exclude-standard --) @ARGV);\n\nIt would also make sense to use --error-unmatch and perhaps --with-tree=HEAD\nlike git-commit.sh does.\n"},{"id":"60625","messageId":"20071122091356.GD7153@sigill.intra.peff.net","threadId":"10956","inReplyTo":"7vk5obb09a.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T09:13:57Z","receivedAt":"2007-11-22T09:13:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 21, 2007 at 04:18:57PM -0800, Junio C Hamano wrote:\n\n> What I meant was that if \"git add -i\" (unrestricted) shows paths\n> from a set A, \"git add -i paths...\" should show paths from a\n> subset of the set A and that subset should be defined with the\n> existing ls-files pathspec semantics.\n\nAh, I think that is definitely the right behavior. But it does raise one\nmore question: is going right into the 'add hunk' interface the correct\nbehavior, or is that an orthogonal issue?\n\nIOW, do we actually want to support:\n\n  # go to patch menu for each file\n  git-add -i -p file1 file2 ...\n  # add untracked for each file\n  git-add -i -a file1 file2 ...\n\nWhich is of course tricky because the '-p' is contextually dependent on\nthe presence of '-i'.\n\nBut perhaps there is no need, since for just these two operations you\ncan do something like:\n\n  foreach my $file (@ARGV) {\n    if(tracked($file)) {\n      patch_update_file($file);\n    }\n    else {\n      add_tracked($file);\n    }\n  }\n\nAre there any other per-file operations that would make sense to start\nwith? Or might somebody just want to path-limit _without_ starting the\nhunk selector?\n\n-Peff\n"},{"id":"60628","messageId":"7vd4u27gvn.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"7vpry27id0.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add path-limiting to git-add--interactive","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T09:45:48Z","receivedAt":"2007-11-22T09:45:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> @@ -56,9 +56,14 @@ sub list_modified {\n>>  \tmy ($only) = @_;\n>>  \tmy (%data, @return);\n>>  \tmy ($add, $del, $adddel, $file);\n>> +\tmy @tracked = grep {\n>> +\t\tdefined run_cmd_pipe(qw(git ls-files\n>> +\t\t\t                --exclude-standard --), $_)\n>> +\t} @ARGV;\n>> +\treturn if $#tracked == -1 && $#ARGV != -1;\n>\n> Eek.  why?\n>\n> Did you mean to say:\n>\n>     my @tracked = run_cmd_pipe(gw(git ls-files --exclude-standard --) @ARGV);\n>\n> It would also make sense to use --error-unmatch and perhaps --with-tree=HEAD\n> like git-commit.sh does.\n\nActually, the ls-files need to be chomped, but I'd prefer to\nrun -z form of the command and split with NUL.  Does run_cmd_pipe()\ncrap^Wstuff support that?\n\nOn top of:\n\n * refactor patch_update_cmd,\n * teach builtin-add to pass multiple paths,\n * add path-limiting to git-add--interacgtive (with an obvious\n   suggested above),\n\nthe attached patch teaches [p]atch subcommand to take multiple\nselections.  With these, you can do:\n\n\t$ git add -i 'u*.h'\n\tWhat now> p\n                   staged     unstaged path\n          1:    unchanged        +1/-0 unpack-trees.h\n          2:    unchanged        +1/-0 utf8.h\n        Patch update>> *\n        diff --git a/unpack-trees.h b/unpack-trees.h\n\t...\n        Stage this hunk [y/n/a/d/?]? y\n        ...\n\tdiff --git a/utf8.h b/utf8.h\n        ...\n\n-- >8 --\ngit-add -i: allow multiple selection in [p]atch subcommand\n\nThis allows more than one files from the list to be chosen from\nthe patch subcommand instead of going through the file one by\none.\n\nThis also updates the \"list-and-choose\" UI for usability.  When\nthe prompt ends with \">>\", if you type '*' to choose all\nchoices, the prompt immediately returns the choice without\nrequiring an extra empty line to confirm the selection.\n\n---\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 9236ffc..372dc2c 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -256,7 +256,7 @@ sub list_and_choose {\n \t\t\t\t$chosen[$i] = $choose;\n \t\t\t}\n \t\t}\n-\t\tlast if ($opts->{IMMEDIATE});\n+\t\tlast if ($opts->{IMMEDIATE} || $line eq '*');\n \t}\n \tfor ($i = 0; $i < @stuff; $i++) {\n \t\tif ($chosen[$i]) {\n@@ -563,12 +563,12 @@ sub patch_update_cmd {\n \t@mods = grep { !($_->{BINARY}) } @mods;\n \treturn if (!@mods);\n \n-\tmy ($it) = list_and_choose({ PROMPT => 'Patch update',\n-\t\t\t\t     SINGLETON => 1,\n-\t\t\t\t     IMMEDIATE => 1,\n-\t\t\t\t     HEADER => $status_head, },\n-\t\t\t\t   @mods);\n-\tpatch_update_file($it->{VALUE}) if ($it);\n+\tmy (@them) = list_and_choose({ PROMPT => 'Patch update',\n+\t\t\t\t       HEADER => $status_head, },\n+\t\t\t\t     @mods);\n+\tfor (@them) {\n+\t\tpatch_update_file($_->{VALUE});\n+\t}\n }\n \n sub patch_update_file {\n"},{"id":"60629","messageId":"7v8x4q7gns.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"20071122091356.GD7153@sigill.intra.peff.net","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T09:50:31Z","receivedAt":"2007-11-22T09:50:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Wed, Nov 21, 2007 at 04:18:57PM -0800, Junio C Hamano wrote:\n>\n>> What I meant was that if \"git add -i\" (unrestricted) shows paths\n>> from a set A, \"git add -i paths...\" should show paths from a\n>> subset of the set A and that subset should be defined with the\n>> existing ls-files pathspec semantics.\n>\n> Ah, I think that is definitely the right behavior. But it does raise one\n> more question: is going right into the 'add hunk' interface the correct\n> behavior, or is that an orthogonal issue?\n\nI am moderately negative about \"paths imply jump to patch\nsubcommand\".  An option to git-add--interactive that tells which\nsubcommand to initially choose is probably acceptable, though.\n\nWould the patch I just sent out (you need to assemble the parts)\nmake things easier?\n"},{"id":"60630","messageId":"20071122095747.GF7153@sigill.intra.peff.net","threadId":"10956","inReplyTo":"7v8x4q7gns.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T09:57:48Z","receivedAt":"2007-11-22T09:57:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 01:50:31AM -0800, Junio C Hamano wrote:\n\n> I am moderately negative about \"paths imply jump to patch\n> subcommand\".  An option to git-add--interactive that tells which\n> subcommand to initially choose is probably acceptable, though.\n\nI agree that an option is nicer; it's just that it may be awkward since\n'-i' is itself already an option.\n\n> Would the patch I just sent out (you need to assemble the parts)\n> make things easier?\n\nPerhaps. This feature doesn't come up all that often for me, but I will\ntry running with your patch for a while to see if I like it.\n\n-Peff\n"},{"id":"60634","messageId":"B649FFCA-C85F-4BB4-884A-525676ABCA9B@wincent.com","threadId":"10956","inReplyTo":"20071122085919.GB7153@sigill.intra.peff.net","subject":"Re: [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T10:18:27Z","receivedAt":"2007-11-22T10:18:27Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 9:59, Jeff King escribió:\n\n> On Thu, Nov 22, 2007 at 01:02:50AM +0100, Wincent Colaiuta wrote:\n>\n>> +\treturn undef if ($#diff == -1);\n>\n> Style nit: I think the rest of the code generally uses (and I prefer)\n> \"@diff\" to get the number of elements. So:\n>\n>  return undef unless @diff;\n>\n> or I might even have written\n>\n>  my @diff = ...\n>    or return undef;\n>\n> but perhaps I am the only one who finds $#array comparisons to -1 hard\n> on the eyes.\n\nNo, I agree with you; it does read nicer. I'm not a real Perl  \nprogrammer, so everything I do I have to do it with a copy of  \n\"Programming Perl\" next to me to find out how to do things. It's handy  \nto have advice from people more familiar with the idioms. Will  \nincorporate something like this into the series:\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex a5a07bc..0a8f0a9 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -60,7 +60,7 @@ sub list_modified {\n  \t\tdefined run_cmd_pipe(qw(git ls-files\n  \t\t\t                --exclude-standard --), $_)\n  \t} @ARGV;\n-\treturn if $#tracked == -1 && $#ARGV != -1;\n+\treturn if !@tracked && @ARGV;\n\n  \tfor (run_cmd_pipe(qw(git diff-index --cached\n  \t\t\t     --numstat --summary HEAD --), @tracked)) {\n@@ -340,8 +340,8 @@ sub add_untracked_cmd {\n\n  sub parse_diff {\n  \tmy ($path) = @_;\n-\tmy @diff = run_cmd_pipe(qw(git diff-files -p --), $path);\n-\treturn undef if ($#diff == -1);\n+\tmy @diff = run_cmd_pipe(qw(git diff-files -p --), $path)\n+\t    or return undef;\n  \tmy (@hunk) = { TEXT => [] };\n\n  \tfor (@diff) {\n\n\n\nCheers,\nWincent\n"},{"id":"60635","messageId":"825BAB3C-FAB4-4A48-AB94-FAAF5B808CD1@wincent.com","threadId":"10956","inReplyTo":"20071122090828.GC7153@sigill.intra.peff.net","subject":"Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T10:28:17Z","receivedAt":"2007-11-22T10:28:17Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 10:08, Jeff King escribió:\n\n> On Thu, Nov 22, 2007 at 01:02:52AM +0100, Wincent Colaiuta wrote:\n>\n>> -int interactive_add(const char *path)\n>> +int interactive_add(const char **argv, int argc)\n>> {\n>> -\tconst char *argv[3] = { \"add--interactive\", path, NULL };\n>> -\n>> -\treturn run_command_v_opt(argv, RUN_GIT_CMD);\n>> +\tint status;\n>> +\tconst char **args = xmalloc(sizeof(const char *) * (argc + 1));\n>> +\targs[0] = \"add--interactive\";\n>> +\tmemcpy((void *)args + sizeof(const char *), argv, sizeof(const  \n>> char *) * argc);\n>\n> The source for the memcpy (argv) is sometimes NULL. The standard  \n> forbids\n> this, even when the size field is 0. I have no idea if any reasonable\n> implementations actually care.\n\nGood point. I've now conditionalized the memcpy with an \"if (argc >  \n0)\". While I was at it I also got rid of the unneeded cast to void *.\n\n> But...\n>\n>> +\t\tif (argc > 0)\n>> +\t\t\texit(interactive_add(argv, argc));\n>> \t\telse\n>> -\t\t\texit(interactive_add(NULL));\n>> +\t\t\texit(interactive_add(NULL, 0));\n>\n> There really is no reason to pass NULL at all (since the argc limits  \n> us\n> anyway), so we can just get rid of the conditional and simplify to:\n>\n>  exit(interactive_add(argv, argc));\n>\n> for both cases.\n\nYes, that's a nice cleanup. Thanks for suggesting it.\n\nCheers,\nWincent\n"},{"id":"60636","messageId":"20071122103339.GA12692@sigill.intra.peff.net","threadId":"10956","inReplyTo":"825BAB3C-FAB4-4A48-AB94-FAAF5B808CD1@wincent.com","subject":"Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T10:33:40Z","receivedAt":"2007-11-22T10:33:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 11:28:17AM +0100, Wincent Colaiuta wrote:\n\n>>> +\tmemcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * \n>>> argc);\n>>\n>> The source for the memcpy (argv) is sometimes NULL. The standard forbids\n>> this, even when the size field is 0. I have no idea if any reasonable\n>> implementations actually care.\n>\n> Good point. I've now conditionalized the memcpy with an \"if (argc > 0)\". \n> While I was at it I also got rid of the unneeded cast to void *.\n\nI don't think you need it if you do the other cleanup (since you will\nalways be passing a valid argv pointer).\n\n-Peff\n"},{"id":"60638","messageId":"7vzlx65zw6.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"B649FFCA-C85F-4BB4-884A-525676ABCA9B@wincent.com","subject":"Re: [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T10:38:01Z","receivedAt":"2007-11-22T10:38:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> No, I agree with you; it does read nicer. I'm not a real Perl  \n> programmer, so everything I do I have to do it with a copy of  \n> \"Programming Perl\" next to me to find out how to do things. It's handy  \n> to have advice from people more familiar with the idioms. Will  \n> incorporate something like this into the series:\n\nI took the liberty of rewriting them and will push out on pu\nshortly hopefully before I go to bed.\n"},{"id":"60642","messageId":"887C3CB1-D21B-4143-8D4E-BF37709FA102@wincent.com","threadId":"10956","inReplyTo":"7v8x4q7gns.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T10:44:54Z","receivedAt":"2007-11-22T10:44:54Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 10:50, Junio C Hamano escribió:\n\n> Jeff King <peff@peff.net> writes:\n>\n>> On Wed, Nov 21, 2007 at 04:18:57PM -0800, Junio C Hamano wrote:\n>>\n>>> What I meant was that if \"git add -i\" (unrestricted) shows paths\n>>> from a set A, \"git add -i paths...\" should show paths from a\n>>> subset of the set A and that subset should be defined with the\n>>> existing ls-files pathspec semantics.\n>>\n>> Ah, I think that is definitely the right behavior. But it does  \n>> raise one\n>> more question: is going right into the 'add hunk' interface the  \n>> correct\n>> behavior, or is that an orthogonal issue?\n>\n> I am moderately negative about \"paths imply jump to patch\n> subcommand\".  An option to git-add--interactive that tells which\n> subcommand to initially choose is probably acceptable, though.\n\nLet me explain a little why I started this series. Basically, given  \nfile \"foo\" which had multiple changes in it I wanted to stage only  \nselected hunks; so I typed:\n\n\tgit add -i foo\n\nWhich of course didn't work. What I wanted to do was jump straight  \ninto the patch subcommand (hence this series).\n\nIf I wanted to add entire files I would have just typed:\n\n\tgit add foo\n\nSo I don't think the proposal to add \"-p\" (jump to \"patch\" subcommand)  \nand \"-a\" (jump to \"add untracked\" subcommand) are a very good idea,  \nseeing as we already have builtin-add for adding entire files.\n\nCheers,\nWincent\n"},{"id":"60648","messageId":"43664C66-59F9-4B12-B5FD-86011938EC07@wincent.com","threadId":"10956","inReplyTo":"20071122103339.GA12692@sigill.intra.peff.net","subject":"Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T11:02:17Z","receivedAt":"2007-11-22T11:02:17Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 11:33, Jeff King escribió:\n\n> On Thu, Nov 22, 2007 at 11:28:17AM +0100, Wincent Colaiuta wrote:\n>\n>>>> +\tmemcpy((void *)args + sizeof(const char *), argv, sizeof(const  \n>>>> char *) *\n>>>> argc);\n>>>\n>>> The source for the memcpy (argv) is sometimes NULL. The standard  \n>>> forbids\n>>> this, even when the size field is 0. I have no idea if any  \n>>> reasonable\n>>> implementations actually care.\n>>\n>> Good point. I've now conditionalized the memcpy with an \"if (argc >  \n>> 0)\".\n>> While I was at it I also got rid of the unneeded cast to void *.\n>\n> I don't think you need it if you do the other cleanup (since you will\n> always be passing a valid argv pointer).\n\nTrue, argv will never be NULL. We'll still be doing a zero-byte memcpy  \nthough, which I guess is not a big deal here. I'll drop the conditional.\n\nCheers,\nWincent\n"},{"id":"60653","messageId":"C11275B3-4E3A-4A3F-B782-BACE43953704@wincent.com","threadId":"10956","inReplyTo":"7vpry27id0.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add path-limiting to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T11:14:43Z","receivedAt":"2007-11-22T11:14:43Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 10:13, Junio C Hamano escribió:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> @@ -56,9 +56,14 @@ sub list_modified {\n>> \tmy ($only) = @_;\n>> \tmy (%data, @return);\n>> \tmy ($add, $del, $adddel, $file);\n>> +\tmy @tracked = grep {\n>> +\t\tdefined run_cmd_pipe(qw(git ls-files\n>> +\t\t\t                --exclude-standard --), $_)\n>> +\t} @ARGV;\n>> +\treturn if $#tracked == -1 && $#ARGV != -1;\n>\n> Eek.  why?\n>\n> Did you mean to say:\n>\n>    my @tracked = run_cmd_pipe(gw(git ls-files --exclude-standard --)  \n> @ARGV);\n\nBah, indeed that will work. I mistakenly (stupidly?) thought I had to  \ncheck each path in @ARGV one at a time; didn't realize that I could  \npass in all at once and that it would do the right thing.... I've  \nincorporated the suggested change.\n\n> It would also make sense to use --error-unmatch and perhaps --with- \n> tree=HEAD\n> like git-commit.sh does.\n\nMy reading of the run_cmd_pipe function indicates that those options  \nwon't have any effect at all because run_cmd_pipe doesn't check the  \nexit status of the command.\n\nCheers,\nWincent\n"},{"id":"60661","messageId":"20071122112406.GA12913@sigill.intra.peff.net","threadId":"10956","inReplyTo":"887C3CB1-D21B-4143-8D4E-BF37709FA102@wincent.com","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T11:24:06Z","receivedAt":"2007-11-22T11:24:06Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 11:44:54AM +0100, Wincent Colaiuta wrote:\n\n> So I don't think the proposal to add \"-p\" (jump to \"patch\" subcommand) and \n> \"-a\" (jump to \"add untracked\" subcommand) are a very good idea, seeing as we \n> already have builtin-add for adding entire files.\n\nI agree that \"git-add -i untracked_file\" is a bit useless. I think it\nmight be more useful if you could split the one giant hunk (which\ngit-add--interactive does not currently allow) into smaller hunks, and\nthen just add parts of them (so conceptually treat it like it had been a\ntracked file with empty contents, and go to the patch menu). Of course,\nthere is currently no way to usefully split a hunk that has consecutive\nadded lines, so that would have to be figured out, too.\n\nSo I think it is not so much \"this other thing is useful right now\" as\n\"do we want to paint ourselves in a corner for making it (or other\nthings) useful later on?\" And assuming that having arguments means\n\"start the patch menu on these files\" doesn't leave room for changes\nlater.\n\n-Peff\n"},{"id":"60662","messageId":"7vlk8q5xj4.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"887C3CB1-D21B-4143-8D4E-BF37709FA102@wincent.com","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T11:29:03Z","receivedAt":"2007-11-22T11:29:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> If I wanted to add entire files I would have just typed:\n>\n> \tgit add foo\n>\n> So I don't think the proposal to add \"-p\" (jump to \"patch\" subcommand)  \n> and \"-a\" (jump to \"add untracked\" subcommand) are a very good idea,  \n> seeing as we already have builtin-add for adding entire files.\n\nIt is quite valid for users to run:\n\n\tgit add -i \\*.sh\n\nand be able to choose from a list which paths to stage (as a\nwhole), as well as choose from a list which files to run the\nper-hunk staging interface.  \"git add \\*.sh\" won't give you any\nchance to choose which ones to stage, and that's what we have\n\"-i\" (interactive) mode in \"git add\" for.\n\nI think you can massage \"git add --partial foo\" given by the\nuser internally into \"git-add--interactive -i --patch foo\".  I\nstrongly suspect that \"direct to patch subcommand\" mode needs\nmore than just initially jumping into the subcommand (for\nexample, you would want to exit when the patch selection\ninteraction ends, without going back to the main menu), and we\nwould want a signal stronger than mere presense of pathspecs to\ntrigger such a specialized behaviour.\n\nBy the way, the arguments on the command line to git commands\nafter \"--\" are generally pathspecs, iow, patterns to specify\ngroups of files.  Please do not introduce unnecessary\ninconsistencies to the UI by requiring them to be exact pathname\nonly in this particular mode of the command and nowhere else.\n\nThere was one funny thing I fixed up.  The arguments to the\ninteractive_add() function in builtin-add.c was like this:\n\n\tint interactive_add(const char **argv, int argc)\n\nAnybody who writes a function with such a signature and do not\nnotice its craziness before sending it out either (1) has never\nprogrammed in C, (2) did not review the code before submitting,\nor (3) worked too hard and was too tired.\n\nI suspect, judging from the timestamp of your message, it was\n(3) this time.  The collaborative development is not a race ---\ndon't work too hastily and too hard; please relax and review\nafter a good night's sleep before sending things out.\n"},{"id":"60666","messageId":"41577A45-4DF7-4A49-9AD1-1FCBDA1D6A6E@wincent.com","threadId":"10956","inReplyTo":"7vd4u27gvn.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add path-limiting to git-add--interactive","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T11:35:57Z","receivedAt":"2007-11-22T11:35:57Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 10:45, Junio C Hamano escribió:\n\n> the attached patch teaches [p]atch subcommand to take multiple\n> selections.  With these, you can do:\n>\n> \t$ git add -i 'u*.h'\n> \tWhat now> p\n>                   staged     unstaged path\n>          1:    unchanged        +1/-0 unpack-trees.h\n>          2:    unchanged        +1/-0 utf8.h\n>        Patch update>> *\n>        diff --git a/unpack-trees.h b/unpack-trees.h\n> \t...\n>        Stage this hunk [y/n/a/d/?]? y\n>        ...\n> \tdiff --git a/utf8.h b/utf8.h\n>        ...\n>\n> -- >8 --\n\nNice usability improvement.\n\nCheers,\nWincent\n"},{"id":"60665","messageId":"20071122113600.GB12913@sigill.intra.peff.net","threadId":"10956","inReplyTo":"7vlk8q5xj4.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T11:36:00Z","receivedAt":"2007-11-22T11:36:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 03:29:03AM -0800, Junio C Hamano wrote:\n\n> There was one funny thing I fixed up.  The arguments to the\n> interactive_add() function in builtin-add.c was like this:\n> \n> \tint interactive_add(const char **argv, int argc)\n> \n> Anybody who writes a function with such a signature and do not\n> notice its craziness before sending it out either (1) has never\n> programmed in C, (2) did not review the code before submitting,\n> or (3) worked too hard and was too tired.\n\nHeh. I looked the patch over, noticed a subtle memcpy issue, and didn't\neven notice the craziness. I claim 3, also.\n\n-Peff\n"},{"id":"60668","messageId":"20071122113735.GC12913@sigill.intra.peff.net","threadId":"10956","inReplyTo":"43664C66-59F9-4B12-B5FD-86011938EC07@wincent.com","subject":"Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-11-22T11:37:35Z","receivedAt":"2007-11-22T11:37:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 22, 2007 at 12:02:17PM +0100, Wincent Colaiuta wrote:\n\n> True, argv will never be NULL. We'll still be doing a zero-byte memcpy \n> though, which I guess is not a big deal here. I'll drop the conditional.\n\nRight. And zero-byte memcpy _is_ allowed by the standard, so it will\nalready internally have some form of that conditional.\n\n-Peff\n"},{"id":"60684","messageId":"FDAFAD8C-8FF5-4DD7-AC5E-BA39790281A4@wincent.com","threadId":"10956","inReplyTo":"7vlk8q5xj4.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T13:34:14Z","receivedAt":"2007-11-22T13:34:14Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 12:29, Junio C Hamano escribió:\n\n> It is quite valid for users to run:\n>\n> \tgit add -i \\*.sh\n>\n> and be able to choose from a list which paths to stage (as a\n> whole), as well as choose from a list which files to run the\n> per-hunk staging interface.  \"git add \\*.sh\" won't give you any\n> chance to choose which ones to stage, and that's what we have\n> \"-i\" (interactive) mode in \"git add\" for.\n>\n> I think you can massage \"git add --partial foo\" given by the\n> user internally into \"git-add--interactive -i --patch foo\".  I\n> strongly suspect that \"direct to patch subcommand\" mode needs\n> more than just initially jumping into the subcommand (for\n> example, you would want to exit when the patch selection\n> interaction ends, without going back to the main menu)\n\nThis will become especially important if we decide to allow \"git  \ncommit --interactive\" to accept a path spec as well (although exactly  \nwhen we should exit isn't immediately clear to me); I didn't touch  \nthis for the time-being because builtin-commit is getting very close  \nto replacing git-commit.sh.\n\n> and we\n> would want a signal stronger than mere presense of pathspecs to\n> trigger such a specialized behaviour.\n>\n> By the way, the arguments on the command line to git commands\n> after \"--\" are generally pathspecs, iow, patterns to specify\n> groups of files.  Please do not introduce unnecessary\n> inconsistencies to the UI by requiring them to be exact pathname\n> only in this particular mode of the command and nowhere else.\n\nWell, I it wasn't my intention to introduce any such requirement. The  \npath parameters get passed in and eventually handed over unmodified to:\n\n\tgit diff-files -p --\n\nWhich was what was previously in the parse_diff function. It turns out  \nthat if you pass something like \\*.sh to git-diff-files then it won't  \nmatch, but it's not a restriction that I chose to impose, rather it's  \na consequence of the way git-diff-files works. Are there options we  \ncould pass to avoid that restriction?\n\nIn any case, one good thing to come out of this discussion is the  \nability to use pathspecs to limit the number of files displayed when  \nin interactive mode. But it wasn't what I was originally aiming for.  \nMy initial goal was to have git-add--interactive do something useful  \nand convenient when you type:\n\n\tgit add -i foo\n\nIf we don't jump straight to the subcommand then the user has to:\n\n\t- press 5 or p, then Enter\n\t- press 1, then Enter\n\nThis was easier than it was before (same number of keystrokes, but  \nfewer files to visually scan in the list of candidates), but it's  \nstill not that much easier.\n\nOr if we add some kind of \"--patch\" switch, instead do:\n\n\tgit add -i --patch foo\n\nOnce again, not that easy but you could always set up a Git alias, I  \nguess, as a shortcut. Not sure whether this is offers enough of a  \nworkflow improvement to make it worthwhile (ie. you may as well just  \nfire up git-gui).\n\n> There was one funny thing I fixed up.  The arguments to the\n> interactive_add() function in builtin-add.c was like this:\n>\n> \tint interactive_add(const char **argv, int argc)\n>\n> Anybody who writes a function with such a signature and do not\n> notice its craziness before sending it out either (1) has never\n> programmed in C, (2) did not review the code before submitting,\n> or (3) worked too hard and was too tired.\n>\n> I suspect, judging from the timestamp of your message, it was\n> (3) this time.  The collaborative development is not a race ---\n> don't work too hastily and too hard; please relax and review\n> after a good night's sleep before sending things out.\n\nIn any case I've rebased and squished the changes down to a nice 4- \npatch series, incorporating all the feedback given so far. Will sit on  \nit a while before sending it out, as you suggest. But I don't really  \nhave a clear idea where to go forward from here.\n\nCheers,\nWincent\n"},{"id":"60702","messageId":"7vsl2y3wph.fsf@gitster.siamese.dyndns.org","threadId":"10956","inReplyTo":"FDAFAD8C-8FF5-4DD7-AC5E-BA39790281A4@wincent.com","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-22T19:29:46Z","receivedAt":"2007-11-22T19:29:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> El 22/11/2007, a las 12:29, Junio C Hamano escribió:\n>\n>> By the way, the arguments on the command line to git commands\n>> after \"--\" are generally pathspecs, iow, patterns to specify\n>> groups of files.  Please do not introduce unnecessary\n>> inconsistencies to the UI by requiring them to be exact pathname\n>> only in this particular mode of the command and nowhere else.\n>\n> Well, I it wasn't my intention to introduce any such requirement. The\n> path parameters get passed in and eventually handed over unmodified to:\n>\n> \tgit diff-files -p --\n\nWhat I was referring to was this in your original:\n\n>> +\tmy @tracked = grep {\n>> +\t\tdefined run_cmd_pipe(qw(git ls-files\n>> +\t\t\t                --exclude-standard --), $_)\n>> +\t} @ARGV;\n\nIt picks elements from @ARGV that ls-files says \"Ok\" back, not\nthe expanded result from ls-files, and @tracked elements are\nused later as filenames.  Which means you are expecting @ARGV to\ncontain only concrete filenames, not pathspec.\n\n> Or if we add some kind of \"--patch\" switch, instead do:\n>\n> \tgit add -i --patch foo\n\nYou do not need both \"-i\" and \"--patch\", do you?  Plain git-add\ndoes not take --patch anyway so it can pass --patch to the\nunderlying interactive one.\n"},{"id":"60714","messageId":"4C292793-6EEF-4C1A-A91A-B5040A3752C5@wincent.com","threadId":"10956","inReplyTo":"7vsl2y3wph.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-11-22T21:55:37Z","receivedAt":"2007-11-22T21:55:37Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 22/11/2007, a las 20:29, Junio C Hamano escribió:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> Or if we add some kind of \"--patch\" switch, instead do:\n>>\n>> \tgit add -i --patch foo\n>\n> You do not need both \"-i\" and \"--patch\", do you?  Plain git-add\n> does not take --patch anyway so it can pass --patch to the\n> underlying interactive one.\n\nGood point.\n\nCheers,\nWincent\n"}]}