{"thread":{"id":"9777","subject":"git-commit: if run with <file> arguments, include files removed through git rm","startedAt":"2007-09-04T14:43:04Z","lastAt":"2007-09-05T10:20:34Z","messageCount":3,"participants":["Gerrit Pape","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"52458","messageId":"20070904144304.5920.qmail@42e302a26078dc.315fe32.mid.smarden.org","threadId":"9777","inReplyTo":null,"subject":"git-commit: if run with <file> arguments, include files removed through git rm","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-09-04T14:43:04Z","receivedAt":"2007-09-04T14:43:04Z","isPatch":false,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"If git-commit is given a directory as argument to be included in the\ncommit, it uses git ls-files to find out which files to include; this\nmisses files previously removed from the working tree and the index\nthrough git rm:\n\n  % git init-db\n  Initialized empty Git repository in .git/\n  % mkdir bar baz\n  % touch bar/file1 baz/file1 baz/file2\n  % git add . && git commit -mcommit1\n  Created initial commit 1d7dee4: commit1\n   0 files changed, 0 insertions(+), 0 deletions(-)\n   create mode 100644 bar/file1\n   create mode 100644 baz/file1\n   create mode 100644 baz/file2\n  % git rm baz/file1\n  rm 'baz/file1'\n  % git commit -- baz/\n  # On branch master\n  # Changed but not updated:\n  #   (use \"git add/rm <file>...\" to update what will be committed)\n  #\n  #       deleted:    baz/file1\n  #\n  no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nThis patch lets it additionally use git ls-tree to look for the files in\nthe HEAD tree, but I guess there's a smarter way to fix this.\n---\n git-commit.sh |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 1d04f1f..3ac7c4f 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -381,6 +381,7 @@ t,)\n \t\tfi\n \t\tTMP_INDEX=\"$GIT_DIR/tmp-index$$\"\n \t\tcommit_only=`git ls-files --error-unmatch -- \"$@\"` || exit\n+\t\tcommit_only=\"$commit_only \"`git ls-tree -r --name-only HEAD -- \"$@\"` || exit\n \n \t\t# Build a temporary index and update the real index\n \t\t# the same way.\n-- \n1.5.3\n"},{"id":"52474","messageId":"7vabs2pgj6.fsf@gitster.siamese.dyndns.org","threadId":"9777","inReplyTo":"20070904144304.5920.qmail@42e302a26078dc.315fe32.mid.smarden.org","subject":"Re: git-commit: if run with <file> arguments, include files removed through git rm","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-04T16:00:13Z","receivedAt":"2007-09-04T16:00:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gerrit Pape <pape@smarden.org> writes:\n\n> This patch lets it additionally use git ls-tree to look for the files in\n> the HEAD tree, but I guess there's a smarter way to fix this.\n\nYou raised a good issue, but this also needs other parts of the\nsystem to be adjusted.\n\n>  \t\tcommit_only=`git ls-files --error-unmatch -- \"$@\"` || exit\n> +\t\tcommit_only=\"$commit_only \"`git ls-tree -r --name-only HEAD -- \"$@\"` || exit\n\nThe arguments to git-commit are *NOT* \"<file> arguments\".  They\nare file patterns and 'ls-files --error-unmatch -- \"$@\"' is\nthere to allow you to say something like:\n\n\t$ git commit 'p*/*.c'\n\nAlas, ls-tree does not grok globbing yet.  Try this in git.git\nrepository (surrounding quotes are essential):\n\n\t$ git ls-files 'p*/*.c'\n        $ git ls-tree -r HEAD 'p*/*.c'\n\nCurrently we have two semantics of \"pathspec\", and unifying\nthese semantics is one of the items with somewhat higher\npriority on my TODO list for the 1.5.4 cycle (I started looking\nat diff-tree and log last night):\n\n * ls-files, diff-files, diff-index and grep understand both\n   \"leading directory prefix\" and \"glob pattern\"; you can say:\n\n\t$ git ls-files -- arm/ 'p*/*.c'\n\t$ git grep int -- arm/ 'p*/*.c'\n\n   and they do what you would expect them to do.\n\n * diff-tree, log family and ls-tree understand only \"leading\n   directory prefix\" and not \"glob pattern\"; you cannot say:\n\n\t$ git log -- 'p*/*.c'\n\nSo your patch is a definite improvement for normal (\"non\npattern\" but \"exact pathname\") case, but needs the updates to\npathspec semantics to be the correct fix.\n"},{"id":"52580","messageId":"20070905102034.1838.qmail@ffbf01be8bc5db.315fe32.mid.smarden.org","threadId":"9777","inReplyTo":"7vabs2pgj6.fsf@gitster.siamese.dyndns.org","subject":"Re: git-commit: if run with <file> arguments, include files removed through git rm","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-09-05T10:20:34Z","receivedAt":"2007-09-05T10:20:34Z","isPatch":false,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"On Tue, Sep 04, 2007 at 09:00:13AM -0700, Junio C Hamano wrote:\n> Gerrit Pape <pape@smarden.org> writes:\n> > This patch lets it additionally use git ls-tree to look for the files in\n> > the HEAD tree, but I guess there's a smarter way to fix this.\n> \n> You raised a good issue, but this also needs other parts of the\n\nThanks for your detailed explanations.\n\nSebastian Harl actually noticed this unexpected behavior, and reported\nthrough\n http://bugs.debian.org/437817\n\nRegards, Gerrit.\n"}]}