{"thread":{"id":"10454","subject":"Feature request: Limit git-status reports to a directory","startedAt":"2007-10-24T22:01:26Z","lastAt":"2007-10-25T13:03:35Z","messageCount":5,"participants":["Michel Marti","Yin Ping","Johannes Schindelin","Wincent Colaiuta"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"57110","messageId":"ffofbm$lmc$1@ger.gmane.org","threadId":"10454","inReplyTo":null,"subject":"Feature request: Limit git-status reports to a directory","fromName":"Michel Marti","fromEmail":"mma@objectxp.com","sentAt":"2007-10-24T22:01:26Z","receivedAt":"2007-10-24T22:01:26Z","isPatch":false,"sender":{"key":"mma@objectxp.com","avatar":null},"body":"I am sometimes interested in only seeing the status for a specific \ndirectory (and its sub-directories), but git-status is no help in this \ncase - passing a directory does some sort of \"git-commit --dry-run\". I \nfirst thought that this is a bug until I saw in the man-page that this \nis actually a feature...\n\nWhat I would like to have is something like \"git status --limit <path>\" \nand the reported filenames should then be relative to the current \ndirectory for easier copy/pasting them to e.g. git-add, git-diff, etc.\n\nCheers,\n\n- Michel\n"},{"id":"57122","messageId":"46dff0320710241914t7d93aae1t991fbcaacde77046@mail.gmail.com","threadId":"10454","inReplyTo":"ffofbm$lmc$1@ger.gmane.org","subject":"Re: Feature request: Limit git-status reports to a directory","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-10-25T02:14:17Z","receivedAt":"2007-10-25T02:14:17Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On 10/25/07, Michel Marti <mma@objectxp.com> wrote:\n> I am sometimes interested in only seeing the status for a specific\n> directory (and its sub-directories), but git-status is no help in this\n> case - passing a directory does some sort of \"git-commit --dry-run\". I\n> first thought that this is a bug until I saw in the man-page that this\n> is actually a feature...\nIt's also painful for me. IMHO, the behaviour of \"git-status\" should\nkeep consistent with \"git-diff\" and \"git-log\" which allow for the\npath.\n\nAnother point, It will be helpful to add a config item to change the\ndefault behaviour for 'git-diff\" and \"git-log\". For example,\n'diff.defaultcurrentpath=true' to let git only show difference in\ncurrent directory instead of difference in top directory when typing\n'git-diff'\n>\n> - Michel\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n-- \nfranky\n"},{"id":"57153","messageId":"Pine.LNX.4.64.0710251050390.25221@racer.site","threadId":"10454","inReplyTo":"46dff0320710241914t7d93aae1t991fbcaacde77046@mail.gmail.com","subject":"Re: Feature request: Limit git-status reports to a directory","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-25T09:55:12Z","receivedAt":"2007-10-25T09:55:12Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 25 Oct 2007, Yin Ping wrote:\n\n> On 10/25/07, Michel Marti <mma@objectxp.com> wrote:\n> > I am sometimes interested in only seeing the status for a specific \n> > directory (and its sub-directories), but git-status is no help in this \n> > case - passing a directory does some sort of \"git-commit --dry-run\". I \n> > first thought that this is a bug until I saw in the man-page that this \n> > is actually a feature...\n>\n> It's also painful for me. IMHO, the behaviour of \"git-status\" should \n> keep consistent with \"git-diff\" and \"git-log\" which allow for the path.\n\nI am not so sure.  In other SCMs, \"git status\" may be a way to do \"git \ndiff --name-only\" or \"git ls-files\", but not in git.  Here, it strictly \nmeans \"what would be happening if I were to commit _right_ _now_?\".\n\n> Another point, It will be helpful to add a config item to change the \n> default behaviour for 'git-diff\" and \"git-log\". For example, \n> 'diff.defaultcurrentpath=true' to let git only show difference in \n> current directory instead of difference in top directory when typing \n> 'git-diff'\n\nIMHO it is not asking users too much when you say \"git diff .\" is for the \ncurrent directory, and \"git diff\" is for the whole working tree.\n\nBesides, we cannot really change the default behaviour, since some \nporcelains use \"git log\" (and certainly there are some which use \"git \ndiff\", too).  They would suffer from this unexpected -- and indeed \ninconsistent, since the setting can differ between repositories -- output.\n\nHth,\nDscho\n"},{"id":"57181","messageId":"445E2F73-709F-4A4A-8A16-0C9FF7D67D96@wincent.com","threadId":"10454","inReplyTo":"Pine.LNX.4.64.0710251050390.25221@racer.site","subject":"Re: Feature request: Limit git-status reports to a directory","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-10-25T13:03:21Z","receivedAt":"2007-10-25T13:03:21Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 25/10/2007, a las 11:55, Johannes Schindelin escribió:\n\n> Hi,\n>\n> On Thu, 25 Oct 2007, Yin Ping wrote:\n>\n>> On 10/25/07, Michel Marti <mma@objectxp.com> wrote:\n>>\n>> It's also painful for me. IMHO, the behaviour of \"git-status\" should\n>> keep consistent with \"git-diff\" and \"git-log\" which allow for the  \n>> path.\n>\n> I am not so sure.  In other SCMs, \"git status\" may be a way to do \"git\n> diff --name-only\" or \"git ls-files\", but not in git.  Here, it  \n> strictly\n> means \"what would be happening if I were to commit _right_ _now_?\".\n\nYes, but there's no reason why the user shouldn't be able to scope  \nthat down to a specific path, just as they currently can for git-diff  \n(as you point out):\n\n> IMHO it is not asking users too much when you say \"git diff .\" is  \n> for the\n> current directory, and \"git diff\" is for the whole working tree.\n\nSometimes if you have a dirty tree with lots of modified files and  \npotentially lots of things added to the index the output of git- \nstatus can be quite long, and perhaps all you want to know about is  \nwhat is the status of *this* directory or *that* file rather than  \nhaving to visually scan through the entire git-status output.  \nAccepting path info would therefore be a nice usability improvement.\n\nAllowing git-status to accept a path would be consistent with how  \nother git commands (like git-diff) already work, and with other SCMs  \ntoo. The user is expected to know that what's in the index is what  \nwill be committed, and that if he/she types \"git-status foo\" then he/ \nshe may only be seeing a subset of what's staged in the index.\n\nBut the way git-status currently behaves when supplied path info is  \npuzzling to say the least. As the man page says:\n\n> \"The command takes the same set of options as git-commit; it shows  \n> what would be committed if the same options are given to git-commit.\"\n\nThis means that if you do try passing a path to git-status (as surely  \nmany newcomers have done), you'll see the combined result of what is  \nalready staged in the index *plus* what would happen if you git-added  \nthe path(s) that you passed on the command line. I'd argue that this  \nis counter-intuitive, and I think that most would expect that the  \npaths would serve as scope *limiters* rather than indicators that  \nsomething should be *added* to the index.\n\nTo illustrate this, an example; just say you have git-status output  \nlike this:\n\n# On branch master\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       modified:   foo/bar\n#       modified:   baz\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       NOTES\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nAnd you type \"git-status foo\":\n\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#       modified:   foo/bar\n#\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       modified:   baz\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       NOTES\n\nI understand why it works this way, and it's explained by the man  \npage, but the behaviour is the very last thing I would expect.\n\nCheers,\nWincent\n"},{"id":"57180","messageId":"ffq477$mji$1@ger.gmane.org","threadId":"10454","inReplyTo":"Pine.LNX.4.64.0710251050390.25221@racer.site","subject":"Re: Feature request: Limit git-status reports to a directory","fromName":"Michel Marti","fromEmail":"mma@objectxp.com","sentAt":"2007-10-25T13:03:35Z","receivedAt":"2007-10-25T13:03:35Z","isPatch":false,"sender":{"key":"mma@objectxp.com","avatar":null},"body":"on 10/25/2007 11:55 AM Johannes Schindelin said the following:\n> I am not so sure.  In other SCMs, \"git status\" may be a way to do \"git \n> diff --name-only\" or \"git ls-files\", but not in git.  Here, it strictly \n> means \"what would be happening if I were to commit _right_ _now_?\".\nI somehow agree with your argument, but then again, sometimes I'm still interested in\n*only* the status for a given directory.\n\nIMHO, answering the question \"what would be happening if...?\" should be  git-commit's task\n(e.g. git-commit --dry-run). And git-status should behave similar to git-log and git-diff.\n\nFor those interested: I have attached a little script that mimics current git-status\n(except the \"dry-run\" stuff) but also can take a list of directories/files.\n\n\n\n#!/bin/sh\n\nUSAGE='[--staged] [--changed] [--untracked]'\nSUBDIRECTORY_OK=1 . git-sh-setup\nrequire_work_tree\n\nprint_stat_line() {\n\tcase \"$1\" in\n\t\tM)\techo \"#       modified:  $2\";;\n\t\tA)\techo \"#       new file:  $2\";;\n\t\tR*)\techo \"#       renamed:   $2 -> $3\";;\n\t\tD)\techo \"#       deleted:   $2\";;\n\t\tU)\techo \"#       unmerged:  $2\";;\n\t\tX)\techo \"#       $2\";;\n\t\t*)\techo \"#       [$S]:      $2\";;\n\tesac\n}\n\nSTAGED= CHANGED= UNTRACKED= HP=\n\nwhile test $# != 0\ndo\n\tcase \"$1\" in\n\t\t-s|--staged) STAGED=1; shift;;\n\t\t-c|--changed) CHANGED=1; shift;;\n\t\t-u|--untracked) UNTRACKED=1; shift;;\n\t\t--) shift; break;;\n\t\t-*) usage;;\n\t\t *) break;;\n\tesac\ndone\n\nif BRANCH_NAME=$(git symbolic-ref -q HEAD)\nthen\n\tBRANCH_NAME=\"On branch $(expr \"z$BRANCH_NAME\" : 'zrefs/heads/\\(.*\\)')\"\nelse\n\tBRANCH_NAME=\"Not currently on any branch\"\nfi\n\n[ \"$#\" = 0 ] && cd_to_toplevel\n\n\nif [ -z \"$STAGED$CHANGED$UNTRACKED\" ]; then\n\tSTAGED=1; CHANGED=1; UNTRACKED=1\nfi\n\nSP=$(echo _/$(git rev-parse --show-cdup)|tr '/' ' '|wc -w)\n\necho \"# $BRANCH_NAME\"\n\n# Changes to be commited\n[ \"$STAGED\" ] && git-diff --name-status --cached -M -- \"$@\"|while read S F R\ndo\n\tif [ -z \"$HP\" ]; then\n\t\techo '# Changes to be committed:'\n\t\techo '#   (use \"git reset HEAD <file>...\" to unstage)'\n\t\techo '#'\n\t\tHP=1\n\tfi\n\tF=$(echo $F|cut -d'/' -f$SP-)\n\tprint_stat_line \"$S\" \"$F\" \"$R\"\n\ndone\n\n# Changed but not updated\n[ \"$CHANGED\" ] && git-diff --name-status -- \"$@\"|while read S F\ndo\n\tif [ -z \"$HP\" ]; then\n\t\techo '#'\n\t\techo '# Changed but not updated:'\n\t\techo '#   (use \"git add <file>...\" to update what will be committed)'\n\t\techo '#'\n\t\tHP=1\n\tfi\n\tF=$(echo $F|cut -d'/' -f$SP-)\n\tprint_stat_line \"$S\" \"$F\"\ndone\n\n# Untracked files\n[ \"$UNTRACKED\" ] && git-ls-files --exclude-per-directory=.gitignore -o --directory -- \"$@\"|while read F\ndo\n\tif [ -z \"$HP\" ]; then\n\t\techo '#'\n\t\techo '# Untracked files:'\n\t\techo '#   (use \"git add <file>...\" to include in what will be committed)'\n\t\techo '#'\n\t\tHP=1\n\tfi\n\tprint_stat_line \"X\" \"$F\"\ndone\n\n"}]}