{"thread":{"id":"17943","subject":"How to list files that are pending for commit from a merge, including hand modified files","startedAt":"2009-02-21T23:20:21Z","lastAt":"2009-02-22T02:09:59Z","messageCount":3,"participants":["Brent Goodrick","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"105748","messageId":"e38bce640902211520j3f3c2787y28640b0ebcba5e27@mail.gmail.com","threadId":"17943","inReplyTo":null,"subject":"How to list files that are pending for commit from a merge, including hand modified files","fromName":"Brent Goodrick","fromEmail":"bgoodr@gmail.com","sentAt":"2009-02-21T23:20:21Z","receivedAt":"2009-02-21T23:20:21Z","isPatch":false,"sender":{"key":"bgoodr@gmail.com","avatar":"https://gravatar.com/avatar/2399bf5a3468b3516a892183edfd43a7fa0300a2e9d5072189020186961150bc?d=mp&s=160"},"body":"Hi,\n\ngit-ls-files does not seem to show files pending to be committed. The\n-m option does seem to work for files that I might have edited outside\nof git via an editor, but not all of the other ones pending for merge.\nThe -t option \"seems\" to imply that the info would be shown, but only\nlists all files in the repo. Only git-status seems to show these files\nbut in a fashion that makes filtering a bit clunky. Is there some way\nin which to get a listing of the files that git-status shows in its\n\"changes to be committed\" section, but not the \"Untracked files\"\nsection, short of postprocessing the git-status output with sed/awk\ngymnastics?  E.g., the first section of \"modified\" files and \"new\nfile\" type files, but not the junk/ directory:\n\n# On branch work\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tmodified:   .Xmodmap\n#\tnew file:   .some_file\n#\tmodified:   .gitignore\n#\tmodified:   .zone.profile\n#\tmodified:   Vncviewer\n#\tnew file:   bin/gitw-merge-common.sh\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#\tjunk/\n\nThanks,\nBrent\n"},{"id":"105749","messageId":"alpine.LFD.2.00.0902211523280.3111@localhost.localdomain","threadId":"17943","inReplyTo":"e38bce640902211520j3f3c2787y28640b0ebcba5e27@mail.gmail.com","subject":"Re: How to list files that are pending for commit from a merge, including hand modified files","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-02-21T23:29:23Z","receivedAt":"2009-02-21T23:29:23Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 21 Feb 2009, Brent Goodrick wrote:\n> \n> Is there some way in which to get a listing of the files that git-status \n> shows in its \"changes to be committed\" section, but not the \"Untracked \n> files\" section, short of postprocessing the git-status output with \n> sed/awk gymnastics?\n\nJust do variations on\n\n\tgit diff --name-only HEAD\n\nand the reason I say \"variations on\" is that depending on exactly what you \nwant you may want to use slightly different diffs.\n\nFor example, the command line above will list all files that are changed \nin the working tree wrt HEAD. But if you want to see only the files that \nyou have actually updated in the index (ie the ones that would be \ncommitted without using \"-a\"), you should add \"--cached\" to the command \nline, so that it does the diff from HEAD to index, not HEAD to working \ntree.\n\nAnd if you want to see what files are different in the working tree from \nthe index, then drop the \"HEAD\" part, since that's the default behavior \nfor \"git diff\".\n\nFinally, use \"--name-status\" if you want to see if they are new, modified, \nor deleted - rather than just the name.\n\nAnd if you care about renames, and want to see them as such, use -C or -M, \nof course.\n\nSo \"git ls-files\" is not at all what you want. That will give you \ninformation about the current index, but doesn't talk at all about how it \ndiffers from the previous commit or from the working tree. It can be \nuseful for another thing, though: if you're in the middle of a merge, then \nyou can ask for which files are marked as being unmerged in the index.\n\n\t\tLinus\n"},{"id":"105754","messageId":"e38bce640902211809u70c0de2el96a2df0238bc671@mail.gmail.com","threadId":"17943","inReplyTo":"alpine.LFD.2.00.0902211523280.3111@localhost.localdomain","subject":"Re: How to list files that are pending for commit from a merge, including hand modified files","fromName":"Brent Goodrick","fromEmail":"bgoodr@gmail.com","sentAt":"2009-02-22T02:09:59Z","receivedAt":"2009-02-22T02:09:59Z","isPatch":false,"sender":{"key":"bgoodr@gmail.com","avatar":"https://gravatar.com/avatar/2399bf5a3468b3516a892183edfd43a7fa0300a2e9d5072189020186961150bc?d=mp&s=160"},"body":"Thanks very much!  I'll have to play around with those variations a\nbit to get a feel for what will work in my context.\n\nbg\n\nOn Sat, Feb 21, 2009 at 3:29 PM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n>\n>\n> On Sat, 21 Feb 2009, Brent Goodrick wrote:\n>>\n>> Is there some way in which to get a listing of the files that git-status\n>> shows in its \"changes to be committed\" section, but not the \"Untracked\n>> files\" section, short of postprocessing the git-status output with\n>> sed/awk gymnastics?\n>\n> Just do variations on\n>\n>        git diff --name-only HEAD\n>\n> and the reason I say \"variations on\" is that depending on exactly what you\n> want you may want to use slightly different diffs.\n>\n> For example, the command line above will list all files that are changed\n> in the working tree wrt HEAD. But if you want to see only the files that\n> you have actually updated in the index (ie the ones that would be\n> committed without using \"-a\"), you should add \"--cached\" to the command\n> line, so that it does the diff from HEAD to index, not HEAD to working\n> tree.\n>\n> And if you want to see what files are different in the working tree from\n> the index, then drop the \"HEAD\" part, since that's the default behavior\n> for \"git diff\".\n>\n> Finally, use \"--name-status\" if you want to see if they are new, modified,\n> or deleted - rather than just the name.\n>\n> And if you care about renames, and want to see them as such, use -C or -M,\n> of course.\n>\n> So \"git ls-files\" is not at all what you want. That will give you\n> information about the current index, but doesn't talk at all about how it\n> differs from the previous commit or from the working tree. It can be\n> useful for another thing, though: if you're in the middle of a merge, then\n> you can ask for which files are marked as being unmerged in the index.\n>\n>                Linus\n>\n"}]}