{"thread":{"id":"1711","subject":"[PATCH] Show modified files in git-ls-files","startedAt":"2005-09-02T00:35:37Z","lastAt":"2005-09-02T12:17:09Z","messageCount":4,"participants":["Brian Gerst","Catalin Marinas","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"7999","messageId":"43179E59.80106@didntduck.org","threadId":"1711","inReplyTo":null,"subject":"[PATCH] Show modified files in git-ls-files","fromName":"Brian Gerst","fromEmail":"bgerst@didntduck.org","sentAt":"2005-09-02T00:35:37Z","receivedAt":"2005-09-02T00:35:37Z","isPatch":true,"sender":{"key":"bgerst@didntduck.org","avatar":null},"body":"Add -m/--modified to show files that have been modified wrt. the index.\n\nM was already taken so the tag for modifified files is C (changed).\n\n$ git-ls-files -m -t\nC Documentation/git-ls-files.txt\nC ls-files.c\n\nSigned-off-by: Brian Gerst <bgerst@didntduck.org>\n\n---\n\n  Documentation/git-ls-files.txt |    4 ++++\n  ls-files.c                     |   20 +++++++++++++++-----\n  2 files changed, 19 insertions(+), 5 deletions(-)\n\n\n\nSubject: [PATCH] Show modified files in git-ls-files\n\nAdd -m/--modified to show files that have been modified wrt. the index.\n\nM was already taken so the tag for modifified files is C (changed).\n\n$ git-ls-files -m -t\nC Documentation/git-ls-files.txt\nC ls-files.c\n\nSigned-off-by: Brian Gerst <bgerst@didntduck.org>\n\n---\n\n Documentation/git-ls-files.txt |    4 ++++\n ls-files.c                     |   20 +++++++++++++++-----\n 2 files changed, 19 insertions(+), 5 deletions(-)\n\n9de83ef7cce7ed5c1aa129cf2a81f8bce3aedb4f\ndiff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt\n--- a/Documentation/git-ls-files.txt\n+++ b/Documentation/git-ls-files.txt\n@@ -33,6 +33,9 @@ OPTIONS\n -d|--deleted::\n \tShow deleted files in the output\n \n+-m|--modified::\n+\tShow modified files in the output\n+\n -o|--others::\n \tShow other files in the output\n \n@@ -71,6 +74,7 @@ OPTIONS\n \tH\tcached\n \tM\tunmerged\n \tR\tremoved/deleted\n+\tC\tmodifed (changed)\n \tK\tto be killed\n \t?\tother\n \ndiff --git a/ls-files.c b/ls-files.c\n--- a/ls-files.c\n+++ b/ls-files.c\n@@ -17,6 +17,7 @@ static int show_ignored = 0;\n static int show_stage = 0;\n static int show_unmerged = 0;\n static int show_killed = 0;\n+static int show_modified = 0;\n static int line_terminator = '\\n';\n \n static int prefix_len = 0, prefix_offset = 0;\n@@ -26,6 +27,7 @@ static const char **pathspec = NULL;\n static const char *tag_cached = \"\";\n static const char *tag_unmerged = \"\";\n static const char *tag_removed = \"\";\n+static const char *tag_modified = \"\";\n static const char *tag_other = \"\";\n static const char *tag_killed = \"\";\n \n@@ -443,15 +445,18 @@ static void show_files(void)\n \t\t\tshow_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);\n \t\t}\n \t}\n-\tif (show_deleted) {\n+\tif (show_deleted | show_modified) {\n \t\tfor (i = 0; i < active_nr; i++) {\n \t\t\tstruct cache_entry *ce = active_cache[i];\n \t\t\tstruct stat st;\n+\t\t\tint err;\n \t\t\tif (excluded(ce->name) != show_ignored)\n \t\t\t\tcontinue;\n-\t\t\tif (!lstat(ce->name, &st))\n-\t\t\t\tcontinue;\n-\t\t\tshow_ce_entry(tag_removed, ce);\n+\t\t\terr = lstat(ce->name, &st);\n+\t\t\tif (show_deleted && err)\n+\t\t\t\tshow_ce_entry(tag_removed, ce);\n+\t\t\tif (show_modified && ce_match_stat(ce, &st))\n+\t\t\t\tshow_ce_entry(tag_modified, ce);\n \t\t}\n \t}\n }\n@@ -547,6 +552,7 @@ int main(int argc, char **argv)\n \t\t\ttag_cached = \"H \";\n \t\t\ttag_unmerged = \"M \";\n \t\t\ttag_removed = \"R \";\n+\t\t\ttag_modified = \"C \";\n \t\t\ttag_other = \"? \";\n \t\t\ttag_killed = \"K \";\n \t\t\tcontinue;\n@@ -559,6 +565,10 @@ int main(int argc, char **argv)\n \t\t\tshow_deleted = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"-m\") || !strcmp(arg, \"--modified\")) {\n+\t\t\tshow_modified = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"-o\") || !strcmp(arg, \"--others\")) {\n \t\t\tshow_others = 1;\n \t\t\tcontinue;\n@@ -630,7 +640,7 @@ int main(int argc, char **argv)\n \t}\n \n \t/* With no flags, we default to showing the cached files */\n-\tif (!(show_stage | show_deleted | show_others | show_unmerged | show_killed))\n+\tif (!(show_stage | show_deleted | show_others | show_unmerged | show_killed | show_modified))\n \t\tshow_cached = 1;\n \n \tread_cache();\n"},{"id":"8006","messageId":"tnxzmqvalie.fsf@arm.com","threadId":"1711","inReplyTo":"43179E59.80106@didntduck.org","subject":"Re: [PATCH] Show modified files in git-ls-files","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-09-02T09:04:25Z","receivedAt":"2005-09-02T09:04:25Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Brian Gerst <bgerst@didntduck.org> wrote:\n> Add -m/--modified to show files that have been modified wrt. the index.\n>\n> M was already taken so the tag for modifified files is C (changed).\n\nI think git-ls-files should be consistent with git-diff-cache where M\nmeans modified and U unmerged (but for the former, M is unmerged).\n\nStGIT currently uses C to report a merge conflict but I will probably\nchange this since it means copied in git-diff-cache.\n\n-- \nCatalin\n"},{"id":"8008","messageId":"7v3bonkecp.fsf@assigned-by-dhcp.cox.net","threadId":"1711","inReplyTo":"tnxzmqvalie.fsf@arm.com","subject":"Re: [PATCH] Show modified files in git-ls-files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-02T09:28:54Z","receivedAt":"2005-09-02T09:28:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Catalin Marinas <catalin.marinas@gmail.com> writes:\n\n> Brian Gerst <bgerst@didntduck.org> wrote:\n>> Add -m/--modified to show files that have been modified wrt. the index.\n>>\n>> M was already taken so the tag for modifified files is C (changed).\n>\n> I think git-ls-files should be consistent with git-diff-cache where M\n> means modified and U unmerged (but for the former, M is unmerged).\n>\n> StGIT currently uses C to report a merge conflict but I will probably\n> change this since it means copied in git-diff-cache.\n\nI think that is an excellent suggestion.  It looks to me that\nthe tag feature in ls-files needs serious renaming.\n\n * an option is called --deleted and the variable to control the\n   output is show_deleted; the tag variable and string is\n   removed and \"R\".  Probably the tag should be renamed to \"D\".\n\n * before \"modified\", tag_cached was OK, but probably \"known to\n   git\" would have been a better name.  I'd vote for just a\n   single space \" \" as the tag letter; if we want to use printing\n   character, then a single dot \".\".  Most of the things are\n   \"known to git\" anyway so these are visually less\n   distracting.\n\n * unmerged should be \"U\" as you say.\n"},{"id":"8016","messageId":"431842C5.6060606@didntduck.org","threadId":"1711","inReplyTo":"7v3bonkecp.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Show modified files in git-ls-files","fromName":"Brian Gerst","fromEmail":"bgerst@didntduck.org","sentAt":"2005-09-02T12:17:09Z","receivedAt":"2005-09-02T12:17:09Z","isPatch":true,"sender":{"key":"bgerst@didntduck.org","avatar":null},"body":"Junio C Hamano wrote:\n> Catalin Marinas <catalin.marinas@gmail.com> writes:\n> \n> \n>>Brian Gerst <bgerst@didntduck.org> wrote:\n>>\n>>>Add -m/--modified to show files that have been modified wrt. the index.\n>>>\n>>>M was already taken so the tag for modifified files is C (changed).\n>>\n>>I think git-ls-files should be consistent with git-diff-cache where M\n>>means modified and U unmerged (but for the former, M is unmerged).\n>>\n>>StGIT currently uses C to report a merge conflict but I will probably\n>>change this since it means copied in git-diff-cache.\n> \n> \n> I think that is an excellent suggestion.  It looks to me that\n> the tag feature in ls-files needs serious renaming.\n> \n>  * an option is called --deleted and the variable to control the\n>    output is show_deleted; the tag variable and string is\n>    removed and \"R\".  Probably the tag should be renamed to \"D\".\n> \n>  * before \"modified\", tag_cached was OK, but probably \"known to\n>    git\" would have been a better name.  I'd vote for just a\n>    single space \" \" as the tag letter; if we want to use printing\n>    character, then a single dot \".\".  Most of the things are\n>    \"known to git\" anyway so these are visually less\n>    distracting.\n\nIt should have some character, so the output is parseable by other scripts.\n\n>  * unmerged should be \"U\" as you say.\n\nI agree that the tags should be renamed.  I just didn't want to break \nother scripts which depend on those tags.\n\n--\n\t\t\t\t\tBrian Gerst\n"}]}