{"thread":{"id":"10272","subject":"[PATCH] git-add (-a|-u) and -n support","startedAt":"2007-10-14T10:26:28Z","lastAt":"2007-10-15T14:54:18Z","messageCount":10,"participants":["Michael Witten","Matthieu Moy","Jeff King","Karl Hasselström","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"55694","messageId":"E1DCA1D1-1ED3-498A-A919-9EBAF3BA0870@mit.edu","threadId":"10272","inReplyTo":null,"subject":"[PATCH] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-14T10:26:28Z","receivedAt":"2007-10-14T10:26:28Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Hello,\n\nThe git-add command doesn't handle -n when using -u.\n\nI fixed this and added -a for adding ALL files, not\njust those below the current directory (just like\ngit-commit).\n\nThe patch is below, but you can also download it from\nhttp://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two- \nkinds-of-update.patch\n\n\n\n From acc846f5243d26a96aaf0bf1c4f04ecc021385a2 Mon Sep 17 00:00:00 2001\nFrom: Michael Witten <mfwitten@mit.edu>\nDate: Sun, 14 Oct 2007 06:13:20 -0400\nSubject: [PATCH] git-add now understands two kinds of update:\n\n  \t-u: update as before\n  \t-a: update all as in a true 'git commit -a'\n\nAlso, -n works correctly now with the above options.\n\nSigned-off-by: Michael Witten <mfwitten@mit.edu>\n---\n  builtin-add.c |   69 +++++++++++++++++++++++++++++++++++++ \n+-------------------\n  1 files changed, 46 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex f9a6580..24887c7 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -13,10 +13,11 @@\n  #include \"commit.h\"\n  #include \"revision.h\"\n\n+enum update_type {NONE, ALL, CURRENT_DIRECTORY};\n+\n  static const char builtin_add_usage[] =\n  \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--]  \n<filepattern>...\";\n\n-static int take_worktree_changes;\n  static const char *excludes_file;\n\n  static void prune_directory(struct dir_struct *dir, const char  \n**pathspec, int prefix)\n@@ -83,40 +84,57 @@ static void fill_directory(struct dir_struct  \n*dir, const char **pathspec,\n  static void update_callback(struct diff_queue_struct *q,\n  \t\t\t    struct diff_options *opt, void *cbdata)\n  {\n-\tint i, verbose;\n-\n-\tverbose = *((int *)cbdata);\n+\tint i;\n+\t\n+\tint* options   = (int*)cbdata;\n+\tint  verbose   = options[0];\n+\tint  show_only = options[1];\n+\t\n  \tfor (i = 0; i < q->nr; i++) {\n  \t\tstruct diff_filepair *p = q->queue[i];\n  \t\tconst char *path = p->one->path;\n-\t\tswitch (p->status) {\n-\t\tdefault:\n-\t\t\tdie(\"unexpected diff status %c\", p->status);\n-\t\tcase DIFF_STATUS_UNMERGED:\n-\t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n-\t\t\tadd_file_to_cache(path, verbose);\n-\t\t\tbreak;\n-\t\tcase DIFF_STATUS_DELETED:\n-\t\t\tremove_file_from_cache(path);\n-\t\t\tif (verbose)\n-\t\t\t\tprintf(\"remove '%s'\\n\", path);\n-\t\t\tbreak;\n+\t\t\n+\t\tswitch (p->status) {\t\t\t\n+\t\t\tcase DIFF_STATUS_UNMERGED:\n+\t\t\tcase DIFF_STATUS_MODIFIED:\n+\t\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\t\tif (show_only)\n+\t\t\t\t\tprintf(\"add '%s'\\n\", path);\n+\t\t\t\telse\n+\t\t\t\t\tadd_file_to_cache(path, verbose);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tcase DIFF_STATUS_DELETED:\n+\t\t\t\tif (show_only)\n+\t\t\t\t\tremove_file_from_cache(path);\n+\t\t\t\tif (verbose)\n+\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tdefault:\n+\t\t\t\tdie(\"unexpected diff status %c\", p->status);\n  \t\t}\n  \t}\n  }\n\n-static void update(int verbose, const char *prefix, const char **files)\n+static void update(enum update_type type, int verbose, int show_only,\n+                  const char *prefix, const char **files)\n  {\n  \tstruct rev_info rev;\n+\tint callback_options[] = {verbose, show_only};\n+\t\n  \tinit_revisions(&rev, prefix);\n  \tsetup_revisions(0, NULL, &rev, NULL);\n-\trev.prune_data = get_pathspec(prefix, files);\n+\t\n+\trev.prune_data = type == ALL ? NULL : get_pathspec(prefix, files);\n+\t\n  \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n  \trev.diffopt.format_callback = update_callback;\n-\trev.diffopt.format_callback_data = &verbose;\n+\trev.diffopt.format_callback_data = callback_options;\n+\t\n  \tif (read_cache() < 0)\n  \t\tdie(\"index file corrupt\");\n+\t\n  \trun_diff_files(&rev, 0);\n  }\n\n@@ -158,6 +176,7 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  {\n  \tint i, newfd;\n  \tint verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;\n+\tenum update_type update_type = NONE;\n  \tconst char **pathspec;\n  \tstruct dir_struct dir;\n  \tint add_interactive = 0;\n@@ -201,8 +220,12 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\t\tverbose = 1;\n  \t\t\tcontinue;\n  \t\t}\n+\t\tif (!strcmp(arg, \"-a\")) {\n+\t\t\tupdate_type = ALL;\n+\t\t\tcontinue;\n+\t\t}\n  \t\tif (!strcmp(arg, \"-u\")) {\n-\t\t\ttake_worktree_changes = 1;\n+\t\t\tupdate_type = CURRENT_DIRECTORY;\n  \t\t\tcontinue;\n  \t\t}\n  \t\tif (!strcmp(arg, \"--refresh\")) {\n@@ -212,8 +235,8 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\tusage(builtin_add_usage);\n  \t}\n\n-\tif (take_worktree_changes) {\n-\t\tupdate(verbose, prefix, argv + i);\n+\tif (update_type) {\n+\t\tupdate(update_type, verbose, show_only, prefix, argv + i);\n  \t\tgoto finish;\n  \t}\n\n-- \n1.5.3.4.206.g58ba4-dirty\n"},{"id":"55702","messageId":"0458D1DA-6261-4DA6-91B0-739F4D35AADF@mit.edu","threadId":"10272","inReplyTo":"E1DCA1D1-1ED3-498A-A919-9EBAF3BA0870@mit.edu","subject":"Re: [PATCH] [BUG FIXED] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-14T12:11:23Z","receivedAt":"2007-10-14T12:11:23Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"\nOn 14 Oct 2007, at 6:26:28 AM, Michael Witten wrote:\n\n> Hello,\n>\n> The git-add command doesn't handle -n when using -u.\n>\n> I fixed this and added -a for adding ALL files, not\n> just those below the current directory (just like\n> git-commit).\n>\n> The patch is below, but you can also download it from\n> http://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two- \n> kinds-of-update.patch\n>\n\n\nUnfortunately, I introduced a bug.\nThe following:\n\n> +\t\t\t\tif (show_only)\n> +\t\t\t\t\tremove_file_from_cache(path);\n> +\t\t\t\tif (verbose)\n> +\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n\nShould be:\n\n> +\t\t\t\tif (!show_only)\n> +\t\t\t\t\tremove_file_from_cache(path);\n> +\t\t\t\tif (verbose)\n> +\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n\n\nThe new patch is listed below:\n(http://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two- \nkinds-of-update.patch)\n\n\n From 6d7480062b1e1c513441d4bbc17a9a8b5d9b1c8f Mon Sep 17 00:00:00 2001\nFrom: Michael Witten <mfwitten@mit.edu>\nDate: Sun, 14 Oct 2007 06:13:20 -0400\nSubject: [PATCH] git-add now understands two kinds of update:\n\n  \t-u: update as before\n  \t-a: update all as in a true 'git commit -a'\n\nAlso, -n works correctly now with the above options.\n\nSigned-off-by: Michael Witten <mfwitten@mit.edu>\n---\n  builtin-add.c |   69 +++++++++++++++++++++++++++++++++++++ \n+-------------------\n  1 files changed, 46 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex f9a6580..f180afe 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -13,10 +13,11 @@\n  #include \"commit.h\"\n  #include \"revision.h\"\n\n+enum update_type {NONE, ALL, CURRENT_DIRECTORY};\n+\n  static const char builtin_add_usage[] =\n  \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--]  \n<filepattern>...\";\n\n-static int take_worktree_changes;\n  static const char *excludes_file;\n\n  static void prune_directory(struct dir_struct *dir, const char  \n**pathspec, int prefix)\n@@ -83,40 +84,57 @@ static void fill_directory(struct dir_struct  \n*dir, const char **pathspec,\n  static void update_callback(struct diff_queue_struct *q,\n  \t\t\t    struct diff_options *opt, void *cbdata)\n  {\n-\tint i, verbose;\n-\n-\tverbose = *((int *)cbdata);\n+\tint i;\n+\t\n+\tint* options   = (int*)cbdata;\n+\tint  verbose   = options[0];\n+\tint  show_only = options[1];\n+\t\n  \tfor (i = 0; i < q->nr; i++) {\n  \t\tstruct diff_filepair *p = q->queue[i];\n  \t\tconst char *path = p->one->path;\n-\t\tswitch (p->status) {\n-\t\tdefault:\n-\t\t\tdie(\"unexpected diff status %c\", p->status);\n-\t\tcase DIFF_STATUS_UNMERGED:\n-\t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n-\t\t\tadd_file_to_cache(path, verbose);\n-\t\t\tbreak;\n-\t\tcase DIFF_STATUS_DELETED:\n-\t\t\tremove_file_from_cache(path);\n-\t\t\tif (verbose)\n-\t\t\t\tprintf(\"remove '%s'\\n\", path);\n-\t\t\tbreak;\n+\t\t\n+\t\tswitch (p->status) {\t\t\t\n+\t\t\tcase DIFF_STATUS_UNMERGED:\n+\t\t\tcase DIFF_STATUS_MODIFIED:\n+\t\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\t\tif (show_only)\n+\t\t\t\t\tprintf(\"add '%s'\\n\", path);\n+\t\t\t\telse\n+\t\t\t\t\tadd_file_to_cache(path, verbose);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tcase DIFF_STATUS_DELETED:\n+\t\t\t\tif (verbose)\n+\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n+\t\t\t\tif (!show_only)\n+\t\t\t\t\tremove_file_from_cache(path);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tdefault:\n+\t\t\t\tdie(\"unexpected diff status %c\", p->status);\n  \t\t}\n  \t}\n  }\n\n-static void update(int verbose, const char *prefix, const char **files)\n+static void update(enum update_type type, int verbose, int show_only,\n+                  const char *prefix, const char **files)\n  {\n  \tstruct rev_info rev;\n+\tint callback_options[] = {verbose, show_only};\n+\t\n  \tinit_revisions(&rev, prefix);\n  \tsetup_revisions(0, NULL, &rev, NULL);\n-\trev.prune_data = get_pathspec(prefix, files);\n+\t\n+\trev.prune_data = type == ALL ? NULL : get_pathspec(prefix, files);\n+\t\n  \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n  \trev.diffopt.format_callback = update_callback;\n-\trev.diffopt.format_callback_data = &verbose;\n+\trev.diffopt.format_callback_data = callback_options;\n+\t\n  \tif (read_cache() < 0)\n  \t\tdie(\"index file corrupt\");\n+\t\n  \trun_diff_files(&rev, 0);\n  }\n\n@@ -158,6 +176,7 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  {\n  \tint i, newfd;\n  \tint verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;\n+\tenum update_type update_type = NONE;\n  \tconst char **pathspec;\n  \tstruct dir_struct dir;\n  \tint add_interactive = 0;\n@@ -201,8 +220,12 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\t\tverbose = 1;\n  \t\t\tcontinue;\n  \t\t}\n+\t\tif (!strcmp(arg, \"-a\")) {\n+\t\t\tupdate_type = ALL;\n+\t\t\tcontinue;\n+\t\t}\n  \t\tif (!strcmp(arg, \"-u\")) {\n-\t\t\ttake_worktree_changes = 1;\n+\t\t\tupdate_type = CURRENT_DIRECTORY;\n  \t\t\tcontinue;\n  \t\t}\n  \t\tif (!strcmp(arg, \"--refresh\")) {\n@@ -212,8 +235,8 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\tusage(builtin_add_usage);\n  \t}\n\n-\tif (take_worktree_changes) {\n-\t\tupdate(verbose, prefix, argv + i);\n+\tif (update_type) {\n+\t\tupdate(update_type, verbose, show_only, prefix, argv + i);\n  \t\tgoto finish;\n  \t}\n\n-- \n1.5.3.4.206.g58ba4-dirty\n"},{"id":"55711","messageId":"E857D120-787F-460B-A167-4B5F4BD2C3B5@mit.edu","threadId":"10272","inReplyTo":"0458D1DA-6261-4DA6-91B0-739F4D35AADF@mit.edu","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-14T12:24:05Z","receivedAt":"2007-10-14T12:24:05Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Sorry for the \"spam\"!\n\nOn 14 Oct 2007, at 6:26:28 AM, Michael Witten wrote:\n\n> Hello,\n>\n> The git-add command doesn't handle -n when using -u.\n>\n> I fixed this and added -a for adding ALL files, not\n> just those below the current directory (just like\n> git-commit).\n>\n> The patch is below, but you can also download it from\n> http://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two- \n> kinds-of-update.patch\n>\n\n\nUnfortunately, I left a second bug in place.\nI was too excited about submitting a patch,\nand too tired to get it right.\n\nThe following:\n\n> +\t\t\t\tif (verbose)\n> +\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n> +\t\t\t\tif (!show_only)\n> +\t\t\t\t\tremove_file_from_cache(path);\n\nShould be:\n\n> +\t\t\t\tif (show_only || verbose)\n> +\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n> +\t\t\t\tif (!show_only)\n> +\t\t\t\t\tremove_file_from_cache(path);\n\n\nThe new patch is listed below:\n(http://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two- \nkinds-of-update.patch)\n\n\n From c3c2f07f3f94aa75d73fce0dfabc3958532f38c4 Mon Sep 17 00:00:00 2001\nFrom: Michael Witten <mfwitten@mit.edu>\nDate: Sun, 14 Oct 2007 06:13:20 -0400\nSubject: [PATCH] git-add now understands two kinds of update:\n\n  \t-u: update as before\n  \t-a: update all as in a true 'git commit -a'\n\nAlso, -n works correctly now with the above options.\n\nSigned-off-by: Michael Witten <mfwitten@mit.edu>\n---\n  builtin-add.c |   69 +++++++++++++++++++++++++++++++++++++ \n+-------------------\n  1 files changed, 46 insertions(+), 23 deletions(-)\n\ndiff --git a/builtin-add.c b/builtin-add.c\nindex f9a6580..3c79a95 100644\n--- a/builtin-add.c\n+++ b/builtin-add.c\n@@ -13,10 +13,11 @@\n  #include \"commit.h\"\n  #include \"revision.h\"\n\n+enum update_type {NONE, ALL, CURRENT_DIRECTORY};\n+\n  static const char builtin_add_usage[] =\n  \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--]  \n<filepattern>...\";\n\n-static int take_worktree_changes;\n  static const char *excludes_file;\n\n  static void prune_directory(struct dir_struct *dir, const char  \n**pathspec, int prefix)\n@@ -83,40 +84,57 @@ static void fill_directory(struct dir_struct  \n*dir, const char **pathspec,\n  static void update_callback(struct diff_queue_struct *q,\n  \t\t\t    struct diff_options *opt, void *cbdata)\n  {\n-\tint i, verbose;\n-\n-\tverbose = *((int *)cbdata);\n+\tint i;\n+\t\n+\tint* options   = (int*)cbdata;\n+\tint  verbose   = options[0];\n+\tint  show_only = options[1];\n+\t\n  \tfor (i = 0; i < q->nr; i++) {\n  \t\tstruct diff_filepair *p = q->queue[i];\n  \t\tconst char *path = p->one->path;\n-\t\tswitch (p->status) {\n-\t\tdefault:\n-\t\t\tdie(\"unexpected diff status %c\", p->status);\n-\t\tcase DIFF_STATUS_UNMERGED:\n-\t\tcase DIFF_STATUS_MODIFIED:\n-\t\tcase DIFF_STATUS_TYPE_CHANGED:\n-\t\t\tadd_file_to_cache(path, verbose);\n-\t\t\tbreak;\n-\t\tcase DIFF_STATUS_DELETED:\n-\t\t\tremove_file_from_cache(path);\n-\t\t\tif (verbose)\n-\t\t\t\tprintf(\"remove '%s'\\n\", path);\n-\t\t\tbreak;\n+\t\t\n+\t\tswitch (p->status) {\t\t\t\n+\t\t\tcase DIFF_STATUS_UNMERGED:\n+\t\t\tcase DIFF_STATUS_MODIFIED:\n+\t\t\tcase DIFF_STATUS_TYPE_CHANGED:\n+\t\t\t\tif (show_only)\n+\t\t\t\t\tprintf(\"add '%s'\\n\", path);\n+\t\t\t\telse\n+\t\t\t\t\tadd_file_to_cache(path, verbose);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tcase DIFF_STATUS_DELETED:\n+\t\t\t\tif (show_only || verbose)\n+\t\t\t\t\tprintf(\"remove '%s'\\n\", path);\n+\t\t\t\tif (!show_only)\n+\t\t\t\t\tremove_file_from_cache(path);\n+\t\t\t\tbreak;\n+\t\t\t\n+\t\t\tdefault:\n+\t\t\t\tdie(\"unexpected diff status %c\", p->status);\n  \t\t}\n  \t}\n  }\n\n-static void update(int verbose, const char *prefix, const char **files)\n+static void update(enum update_type type, int verbose, int show_only,\n+                  const char *prefix, const char **files)\n  {\n  \tstruct rev_info rev;\n+\tint callback_options[] = {verbose, show_only};\n+\t\n  \tinit_revisions(&rev, prefix);\n  \tsetup_revisions(0, NULL, &rev, NULL);\n-\trev.prune_data = get_pathspec(prefix, files);\n+\t\n+\trev.prune_data = type == ALL ? NULL : get_pathspec(prefix, files);\n+\t\n  \trev.diffopt.output_format = DIFF_FORMAT_CALLBACK;\n  \trev.diffopt.format_callback = update_callback;\n-\trev.diffopt.format_callback_data = &verbose;\n+\trev.diffopt.format_callback_data = callback_options;\n+\t\n  \tif (read_cache() < 0)\n  \t\tdie(\"index file corrupt\");\n+\t\n  \trun_diff_files(&rev, 0);\n  }\n\n@@ -158,6 +176,7 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  {\n  \tint i, newfd;\n  \tint verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;\n+\tenum update_type update_type = NONE;\n  \tconst char **pathspec;\n  \tstruct dir_struct dir;\n  \tint add_interactive = 0;\n@@ -201,8 +220,12 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\t\tverbose = 1;\n  \t\t\tcontinue;\n  \t\t}\n+\t\tif (!strcmp(arg, \"-a\")) {\n+\t\t\tupdate_type = ALL;\n+\t\t\tcontinue;\n+\t\t}\n  \t\tif (!strcmp(arg, \"-u\")) {\n-\t\t\ttake_worktree_changes = 1;\n+\t\t\tupdate_type = CURRENT_DIRECTORY;\n  \t\t\tcontinue;\n  \t\t}\n  \t\tif (!strcmp(arg, \"--refresh\")) {\n@@ -212,8 +235,8 @@ int cmd_add(int argc, const char **argv, const  \nchar *prefix)\n  \t\tusage(builtin_add_usage);\n  \t}\n\n-\tif (take_worktree_changes) {\n-\t\tupdate(verbose, prefix, argv + i);\n+\tif (update_type) {\n+\t\tupdate(update_type, verbose, show_only, prefix, argv + i);\n  \t\tgoto finish;\n  \t}\n\n-- \n1.5.3.4.207.g6d7480-dirty\n"},{"id":"55717","messageId":"vpq3awd25hs.fsf@bauges.imag.fr","threadId":"10272","inReplyTo":"E857D120-787F-460B-A167-4B5F4BD2C3B5@mit.edu","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-10-14T13:25:03Z","receivedAt":"2007-10-14T13:25:03Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Michael Witten <mfwitten@MIT.EDU> writes:\n\n> Subject: [PATCH] git-add now understands two kinds of update:\n>\n>  \t-u: update as before\n>  \t-a: update all as in a true 'git commit -a'\n\nI don't find the option set very intuitive. I'd prefer\n\n  - git add -u . => update the current directory as before\n  - git add -u   => update all files from the root.\n\nBut your solution has the advantage of being backward compatible, so,\nno strong opinion here.\n\n(side note: also, while you're here, it would be nice to have a single\ncommand to do \"git add .; git add -u\", i.e add all unknown files,\nupdate all existing files, and actally remove all deleted files. In\none word, synchronize the index with the working tree completely.\nPerhaps \"-a\" would be a good name for that, not sure)\n\n\n>  builtin-add.c |   69 +++++++++++++++++++++++++++++++++++++\n> +-------------------\n\nYour patch is whitespace-damaged. I don't know how to fix that for\nApple Mail, but git-send-email can help.\n\n>  static const char builtin_add_usage[] =\n>  \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--]\n> <filepattern>...\";\n\nYou should document -a here, and in Documentation/git-add.txt if you\nintroduce it.\n\n-- \nMatthieu\n"},{"id":"55779","messageId":"D44B7811-5A0F-4A31-9DB3-6D2BF645E543@MIT.EDU","threadId":"10272","inReplyTo":"vpq3awd25hs.fsf@bauges.imag.fr","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-14T22:00:44Z","receivedAt":"2007-10-14T22:00:44Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"Thanks for the reply!\n\nOn 14 Oct 2007, at 9:25:03 AM, Matthieu Moy wrote:\n\n> Michael Witten <mfwitten@MIT.EDU> writes:\n>\n>> Subject: [PATCH] git-add now understands two kinds of update:\n>>\n>>  \t-u: update as before\n>>  \t-a: update all as in a true 'git commit -a'\n>\n> I don't find the option set very intuitive. I'd prefer\n>\n>   - git add -u . => update the current directory as before\n>   - git add -u   => update all files from the root.\n>\n> But your solution has the advantage of being backward compatible, so,\n> no strong opinion here.\n\nHere's compromise that is backwards compatible. For both git-add\nand git-commit:\n\t\n\t-a dir [dir2 ...] => all changes in the given dirs.\n\t-a                => all changes from the root.\n\nThen we can just leave -u in place for now, and mark it as deprecated.\n\nIn any case, the goal is to make the intuition solid between\ngit-commit and git-add.\n\n\n> (side note: also, while you're here, it would be nice to have a single\n> command to do \"git add .; git add -u\", i.e add all unknown files,\n> update all existing files, and actally remove all deleted files. In\n> one word, synchronize the index with the working tree completely.\n> Perhaps \"-a\" would be a good name for that, not sure)\n\nWe can couple the above with -f to do this.\n\n\n>>  builtin-add.c |   69 +++++++++++++++++++++++++++++++++++++\n>> +-------------------\n>\n> Your patch is whitespace-damaged. I don't know how to fix that for\n> Apple Mail, but git-send-email can help.\n\nI see that now; Apple's trying to be smart about blank lines, it  \nwould seem.\n\n>> static const char builtin_add_usage[] =\n>>  \"git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--]\n>> <filepattern>...\";\n>\n> You should document -a here, and in Documentation/git-add.txt if you\n> introduce it.\n\nLet's get -a/-u squared away first.\n\nThanks again,\nMichael Witten\n"},{"id":"55811","messageId":"20071015042028.GB4844@coredump.intra.peff.net","threadId":"10272","inReplyTo":"E1DCA1D1-1ED3-498A-A919-9EBAF3BA0870@mit.edu","subject":"Re: [PATCH] git-add (-a|-u) and -n support","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-10-15T04:20:28Z","receivedAt":"2007-10-15T04:20:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Oct 14, 2007 at 06:26:28AM -0400, Michael Witten wrote:\n\n> The patch is below, but you can also download it from\n> http://web.mit.edu/mfwitten/git/0001-git-add-now-understands-two-kinds-of-update.patch\n\nHi Michael,\n\nThank you for submitting a patch! However, please make sure you read\nSubmittingPatches carefully. Your message should consist of the regular\nmail headers (as generated by git-format-patch + whatever else you want\nto add), the commit message, a line containing \"---\", and then the diff.\nAny cover letter material should go after the \"---\".\n\nIOW, the format the git-format-patch generates is actually a mail in the\ncorrect format. If you can convince your mailer to use that as a\ntemplate for sending a mail, that is the best bet.\n\nI know these seem like little things, but they make the life of the\nmaintainer much easier, as it means your patch and commit message can be\napplied directly by the git tools.\n\n-Peff \"policing the list with an iron fist in Junio's absence\" King\n"},{"id":"55836","messageId":"8ACD561E-6F12-4C64-BDBF-CDC697F95D82@MIT.EDU","threadId":"10272","inReplyTo":"20071015042028.GB4844@coredump.intra.peff.net","subject":"Re: [PATCH] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-15T09:09:15Z","receivedAt":"2007-10-15T09:09:15Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"\nOn 15 Oct 2007, at 12:20:28 AM, Jeff King wrote:\n\n> Thank you for submitting a patch! However, please make sure you read\n> SubmittingPatches carefully.\n\nI apologize, though I got your first email about\nDocumentation/SubmittingPatches after I had sent\nin this patch; I had gone rummaging around the homepage\nfor some information, but had found nothing special.\n\nI just submitted a patch (properly!) to Petr Baudis\nto add a link to that documentation on the main page.\n\n> -Peff \"policing the list with an iron fist in Junio's absence\" King\n\nDon't worry, I didn't take it personally ;-)\n\nSincerely,\nMichael Witten\n"},{"id":"55872","messageId":"20071015143137.GA7351@diana.vm.bytemark.co.uk","threadId":"10272","inReplyTo":"D44B7811-5A0F-4A31-9DB3-6D2BF645E543@MIT.EDU","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-15T14:31:37Z","receivedAt":"2007-10-15T14:31:37Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-14 18:00:44 -0400, Michael Witten wrote:\n\n> Here's compromise that is backwards compatible. For both git-add and\n> git-commit:\n>\n>       -a dir [dir2 ...] => all changes in the given dirs.\n>       -a                => all changes from the root.\n>\n> Then we can just leave -u in place for now, and mark it as\n> deprecated.\n>\n> In any case, the goal is to make the intuition solid between\n> git-commit and git-add.\n\nAs I recall, Junio had some specific reason for calling the flag -u\ninstead of -a. Search in the list archive for the patch that\nintroduced the flag, or wait till he gets back and ask him.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"55873","messageId":"85EE4C64-2174-45D3-A459-69746C9CD51C@mit.edu","threadId":"10272","inReplyTo":"20071015143137.GA7351@diana.vm.bytemark.co.uk","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Michael Witten","fromEmail":"mfwitten@mit.edu","sentAt":"2007-10-15T14:47:46Z","receivedAt":"2007-10-15T14:47:46Z","isPatch":true,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"\nOn 15 Oct 2007, at 10:31:37 AM, Karl Hasselström wrote:\n\n> On 2007-10-14 18:00:44 -0400, Michael Witten wrote:\n>\n>> Here's compromise that is backwards compatible. For both git-add and\n>> git-commit:\n>>\n>>       -a dir [dir2 ...] => all changes in the given dirs.\n>>       -a                => all changes from the root.\n>>\n>> Then we can just leave -u in place for now, and mark it as\n>> deprecated.\n>>\n>> In any case, the goal is to make the intuition solid between\n>> git-commit and git-add.\n>\n> As I recall, Junio had some specific reason for calling the flag -u\n> instead of -a. Search in the list archive for the patch that\n> introduced the flag, or wait till he gets back and ask him.\n\nI have a feeling it was because -u currently just updates modified\nfiles in the current directory, while -a updated all modified files.\n\nFortunately, the suggestion above does not break anything.\n\nMichael Witten\n\nP.S.\nWhen is Junio coming back? I know I know... Look through the  \narchives. :-P"},{"id":"55875","messageId":"Pine.LNX.4.64.0710151552160.25221@racer.site","threadId":"10272","inReplyTo":"85EE4C64-2174-45D3-A459-69746C9CD51C@mit.edu","subject":"Re: [PATCH] [BUG FIXED 2] git-add (-a|-u) and -n support","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-15T14:54:18Z","receivedAt":"2007-10-15T14:54:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 15 Oct 2007, Michael Witten wrote:\n\n> When is Junio coming back? I know I know... Look through the archives. \n> :-P-\n\nIt's not in the archives.  Just send your stuff, and let the list be a \nfilter for Junio.  He'll be overwhelmed with the amount of emails already.\n\nIf I were to give him some advice, it would be to just delete all git list \nmails in his inbox and ask for people to resend their latest and greatest, \n_after_ he had a look at what Lars collected.\n\nCiao,\nDscho\n"}]}