{"thread":{"id":"3424","subject":"[PATCH] Add new git-rm command with documentation","startedAt":"2006-02-21T21:47:20Z","lastAt":"2006-02-25T06:05:18Z","messageCount":15,"participants":["Carl Worth","Krzysiek Pawlik","Johannes Schindelin","Shawn Pearce","Junio C Hamano","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"16526","messageId":"87u0ass7tj.wl%cworth@cworth.org","threadId":"3424","inReplyTo":null,"subject":"[PATCH] Add new git-rm command with documentation","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-21T21:47:20Z","receivedAt":"2006-02-21T21:47:20Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"This adds a git-rm command which provides convenience similar to\ngit-add, (and a bit more since it takes care of the rm as well).\n\nLike git-add, git-rm expands the given path names through\ngit-ls-files. This means it only acts on files listed in the\nindex. And it does act recursively on directories by default, (no -r\nneeded as in the case of rm itself). When it recurses, it does not\nremove empty directories that are left behind.\n\n---\n\n It wouldn't be too hard to make this act more like rm in requiring -r\n before recursing into directories. Let me know what people think\n about this.\n\n As before, if you'd prefer to fetch/pull this, you should be able to\n from:\n\n\tgit://git.freedesktop.org/~cworth/git\n\n This time on the git-rm branch, (again merged into cworth for what\n that's worth).\n\n -Carl\n\n PS. I didn't change the Linus and Junio attribution since all of the\n code and documentation here is just minor changes from git-add.\n\n .gitignore               |    1 +\n Documentation/git-rm.txt |   77 ++++++++++++++++++++++++++++++++++++++++++++++\n Makefile                 |    2 +\n git-rm.sh                |   58 +++++++++++++++++++++++++++++++++++\n 4 files changed, 137 insertions(+), 1 deletions(-)\n create mode 100644 Documentation/git-rm.txt\n create mode 100644 git-rm.sh\n\ncf3ff7a87defa6ced7e6a8b6d719a9f237a08314\ndiff --git a/.gitignore b/.gitignore\nindex d7e8d2a..94f66d5 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -84,6 +84,7 @@ git-resolve\n git-rev-list\n git-rev-parse\n git-revert\n+git-rm\n git-send-email\n git-send-pack\n git-sh-setup\ndiff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt\nnew file mode 100644\nindex 0000000..6095df8\n--- /dev/null\n+++ b/Documentation/git-rm.txt\n@@ -0,0 +1,77 @@\n+git-rm(1)\n+=========\n+\n+NAME\n+----\n+git-rm - Remove files from the working tree and from the index.\n+\n+SYNOPSIS\n+--------\n+'git-rm' [-n] [-v] <file>...\n+\n+DESCRIPTION\n+-----------\n+A convenience wrapper for rm and git-update-index --remove. For those\n+coming from cvs, git-rm provides an operation similar to \"cvs rm -f\".\n+\n+\n+OPTIONS\n+-------\n+<file>...::\n+\tFiles to remove from the working tree and the index.\n+\n+-n::\n+        Don't actually remove the file(s), just show if they exist in\n+        the index.\n+\n+-v::\n+        Be verbose.\n+\n+\n+DISCUSSION\n+----------\n+\n+The list of <file> given to the command is fed to `git-ls-files`\n+command to list files that are registered in the index and\n+are not ignored/excluded by `$GIT_DIR/info/exclude` file or\n+`.gitignore` file in each directory.  This means two things:\n+\n+. You can put the name of a directory on the command line, and the\n+  command will remove all files in it and its subdirectories (the\n+  directories themselves are not removed);\n+\n+. Giving the name of a file that is not in the index does not\n+  remove that file.\n+\n+\n+EXAMPLES\n+--------\n+git-rm Documentation/\\\\*.txt::\n+\n+\tRemoves all `\\*.txt` files that are in the index under\n+\t`Documentation` directory and its subdirectories.\n++\n+Note that the asterisk `\\*` is quoted from the shell in this\n+example; this lets the command include the files from\n+subdirectories of `Documentation/` directory.\n+\n+git-rm git-*.sh::\n+\n+\tRemove all git-*.sh scripts that are in the index.\n+\tBecause this example lets the shell expand the asterisk\n+\t(i.e. you are listing the files explicitly), it does not\n+\tremove `subdir/git-foo.sh`.\n+\n+\n+Author\n+------\n+Written by Linus Torvalds <torvalds@osdl.org>\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff --git a/Makefile b/Makefile\nindex 317be3c..e98b056 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -109,7 +109,7 @@ SCRIPT_SH = \\\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-prune.sh git-pull.sh git-push.sh git-rebase.sh \\\n \tgit-repack.sh git-request-pull.sh git-reset.sh \\\n-\tgit-resolve.sh git-revert.sh git-sh-setup.sh \\\n+\tgit-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \\\n \tgit-tag.sh git-verify-tag.sh git-whatchanged.sh \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\ndiff --git a/git-rm.sh b/git-rm.sh\nnew file mode 100644\nindex 0000000..840c458\n--- /dev/null\n+++ b/git-rm.sh\n@@ -0,0 +1,58 @@\n+#!/bin/sh\n+\n+USAGE='<file>...'\n+SUBDIRECTORY_OK='Yes'\n+. git-sh-setup\n+\n+show_only=\n+verbose=\n+while : ; do\n+  case \"$1\" in\n+    -n)\n+\tshow_only=true\n+\t;;\n+    -v)\n+\tverbose=--verbose\n+\t;;\n+    -*)\n+\tusage\n+\t;;\n+    *)\n+\tbreak\n+\t;;\n+  esac\n+  shift\n+done\n+\n+# This is typo-proofing. If some paths match and some do not, we want\n+# to do nothing.\n+case \"$#\" in\n+0)\t;;\n+*)\n+\tgit-ls-files --error-unmatch -- \"$@\" >/dev/null || {\n+\t\techo >&2 \"Maybe you misspelled it?\"\n+\t\texit 1\n+\t}\n+\t;;\n+esac\n+\n+files=$(\n+    if test -f \"$GIT_DIR/info/exclude\" ; then\n+\tgit-ls-files \\\n+\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n+\t    --exclude-per-directory=.gitignore -- \"$@\"\n+    else\n+\tgit-ls-files \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+    fi | sort | uniq\n+)\n+\n+case \"$show_only\" in\n+true)\n+\techo $files\n+\t;;\n+*)\n+\trm $files\n+\tgit-update-index --remove $verbose $files\n+\t;;\n+esac\n-- \n1.2.2.g73be-dirty\n\n"},{"id":"16530","messageId":"43FB8F31.9090302@people.pl","threadId":"3424","inReplyTo":"87u0ass7tj.wl%cworth@cworth.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Krzysiek Pawlik","fromEmail":"krzysiek.pawlik@people.pl","sentAt":"2006-02-21T22:07:45Z","receivedAt":"2006-02-21T22:07:45Z","isPatch":true,"sender":{"key":"krzysiek.pawlik@people.pl","avatar":"https://gravatar.com/avatar/05218c3d47410c496c83467dd36d83d4e4457f4825f00124575b50302bd952e2?d=mp&s=160"},"body":"Carl Worth wrote:\n> This adds a git-rm command which provides convenience similar to\n> git-add\n\nI've modified it a little - it has now a '-f' option to delete files\n(much like cvs rm behaviour). It makes it a bit safer ;) I've fixed the\n`rm` - it wouldn't work for example for file named '--help'.\n\n-- \nKrzysiek Pawlik (Nelchael)\nRLU #322999 GPG Key ID: 0xBC555551\n\n\ndiff -Nru git-1.2.2/.gitignore git-1.2.2.patched/.gitignore\n--- git-1.2.2/.gitignore\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/.gitignore\t2006-02-21 22:56:23.000000000 +0100\n@@ -84,6 +84,7 @@\n git-rev-list\n git-rev-parse\n git-revert\n+git-rm\n git-send-email\n git-send-pack\n git-sh-setup\ndiff -Nru git-1.2.2/Documentation/git-rm.txt git-1.2.2.patched/Documentation/git-rm.txt\n--- git-1.2.2/Documentation/git-rm.txt\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/Documentation/git-rm.txt\t2006-02-21 23:00:13.000000000 +0100\n@@ -0,0 +1,80 @@\n+git-rm(1)\n+=========\n+\n+NAME\n+----\n+git-rm - Remove files from the index.\n+\n+SYNOPSIS\n+--------\n+'git-rm' [-n|-f] [-v] <file>...\n+\n+DESCRIPTION\n+-----------\n+A convenience wrapper for rm and git-update-index --remove. For those\n+coming from cvs, git-rm provides an operation similar to \"cvs rm -f\".\n+\n+\n+OPTIONS\n+-------\n+<file>...::\n+\tFiles to remove from the working tree and the index.\n+\n+-n::\n+        Don't actually remove the file(s), just show if they exist in\n+        the index.\n+\n+-f::\n+        Delete the file(s) before removing it.\n+\n+-v::\n+        Be verbose.\n+\n+\n+DISCUSSION\n+----------\n+\n+The list of <file> given to the command is fed to `git-ls-files`\n+command to list files that are registered in the index and\n+are not ignored/excluded by `$GIT_DIR/info/exclude` file or\n+`.gitignore` file in each directory.  This means two things:\n+\n+. You can put the name of a directory on the command line, and the\n+  command will remove all files in it and its subdirectories (the\n+  directories themselves are not removed);\n+\n+. Giving the name of a file that is not in the index does not\n+  remove that file.\n+\n+\n+EXAMPLES\n+--------\n+git-rm Documentation/\\\\*.txt::\n+\n+\tRemoves all `\\*.txt` files that are in the index under\n+\t`Documentation` directory and its subdirectories.\n++\n+Note that the asterisk `\\*` is quoted from the shell in this\n+example; this lets the command include the files from\n+subdirectories of `Documentation/` directory.\n+\n+git-rm git-*.sh::\n+\n+\tRemove all git-*.sh scripts that are in the index.\n+\tBecause this example lets the shell expand the asterisk\n+\t(i.e. you are listing the files explicitly), it does not\n+\tremove `subdir/git-foo.sh`.\n+\n+\n+Author\n+------\n+Written by Linus Torvalds <torvalds@osdl.org>\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff -Nru git-1.2.2/Makefile git-1.2.2.patched/Makefile\n--- git-1.2.2/Makefile\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/Makefile\t2006-02-21 22:56:23.000000000 +0100\n@@ -107,7 +107,7 @@\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-prune.sh git-pull.sh git-push.sh git-rebase.sh \\\n \tgit-repack.sh git-request-pull.sh git-reset.sh \\\n-\tgit-resolve.sh git-revert.sh git-sh-setup.sh \\\n+\tgit-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \\\n \tgit-tag.sh git-verify-tag.sh git-whatchanged.sh \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\ndiff -Nru git-1.2.2/git-rm.sh git-1.2.2.patched/git-rm.sh\n--- git-1.2.2/git-rm.sh\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/git-rm.sh\t2006-02-21 23:02:13.000000000 +0100\n@@ -0,0 +1,62 @@\n+#!/bin/sh\n+\n+USAGE='<file>...'\n+SUBDIRECTORY_OK='Yes'\n+. git-sh-setup\n+\n+show_only=\n+verbose=\n+remove_files=\n+while : ; do\n+  case \"$1\" in\n+    -n)\n+\tshow_only=true\n+\t;;\n+    -v)\n+\tverbose=--verbose\n+\t;;\n+\t-f)\n+\tremove_files=true\n+\t;;\n+    -*)\n+\tusage\n+\t;;\n+    *)\n+\tbreak\n+\t;;\n+  esac\n+  shift\n+done\n+\n+# This is typo-proofing. If some paths match and some do not, we want\n+# to do nothing.\n+case \"$#\" in\n+0)\t;;\n+*)\n+\tgit-ls-files --error-unmatch -- \"$@\" >/dev/null || {\n+\t\techo >&2 \"Maybe you misspelled it?\"\n+\t\texit 1\n+\t}\n+\t;;\n+esac\n+\n+files=$(\n+    if test -f \"$GIT_DIR/info/exclude\" ; then\n+\tgit-ls-files \\\n+\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n+\t    --exclude-per-directory=.gitignore -- \"$@\"\n+    else\n+\tgit-ls-files \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+    fi | sort | uniq\n+)\n+\n+case \"$show_only\" in\n+true)\n+\techo $files\n+\t;;\n+*)\n+\t[[ \"$remove_files\" = \"true\" ]] && rm -f -- $files\n+\tgit-update-index --remove $verbose $files\n+\t;;\n+esac\n"},{"id":"16533","messageId":"20060221221446.GA20744@spearce.org","threadId":"3424","inReplyTo":"43FB8F31.9090302@people.pl","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-02-21T22:14:46Z","receivedAt":"2006-02-21T22:14:46Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"How about supporting -- to break out of the option loop?  The rest\nof the script will support files named --help just fine but the\noption parser will just spit out usage information.\n\n[...]\n> +while : ; do\n> +  case \"$1\" in\n> +    -n)\n> +\tshow_only=true\n> +\t;;\n> +    -v)\n> +\tverbose=--verbose\n> +\t;;\n> +\t-f)\n> +\tremove_files=true\n> +\t;;\n> +    -*)\n> +\tusage\n> +\t;;\n> +    *)\n> +\tbreak\n> +\t;;\n> +  esac\n> +  shift\n> +done\n[...]\n\nAlso I don't think the -f option's whitespace matches the others...\n\n-- \nShawn.\n"},{"id":"16532","messageId":"Pine.LNX.4.63.0602212314090.12634@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3424","inReplyTo":"87u0ass7tj.wl%cworth@cworth.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-02-21T22:15:08Z","receivedAt":"2006-02-21T22:15:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 21 Feb 2006, Carl Worth wrote:\n\n>  PS. I didn't change the Linus and Junio attribution since all of the\n>  code and documentation here is just minor changes from git-add.\n\nIf that is so, why not reuse the same binary (a la git-whatchanged and \ngit-show)?\n\nCiao,\nDscho\n"},{"id":"16536","messageId":"43FB9455.6010402@people.pl","threadId":"3424","inReplyTo":"20060221221446.GA20744@spearce.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Krzysiek Pawlik","fromEmail":"krzysiek.pawlik@people.pl","sentAt":"2006-02-21T22:29:41Z","receivedAt":"2006-02-21T22:29:41Z","isPatch":true,"sender":{"key":"krzysiek.pawlik@people.pl","avatar":"https://gravatar.com/avatar/05218c3d47410c496c83467dd36d83d4e4457f4825f00124575b50302bd952e2?d=mp&s=160"},"body":"Shawn Pearce wrote:\n> How about supporting -- to break out of the option loop?  The rest\n> of the script will support files named --help just fine but the\n> option parser will just spit out usage information.\n\nYeah... forgot to add this.\n\n> Also I don't think the -f option's whitespace matches the others...\n\nThanks, fixed :)\n\n-- \nKrzysiek Pawlik (Nelchael)\nRLU #322999 GPG Key ID: 0xBC555551\n\n\ndiff -Nru git-1.2.2/.gitignore git-1.2.2.patched/.gitignore\n--- git-1.2.2/.gitignore\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/.gitignore\t2006-02-21 22:56:23.000000000 +0100\n@@ -84,6 +84,7 @@\n git-rev-list\n git-rev-parse\n git-revert\n+git-rm\n git-send-email\n git-send-pack\n git-sh-setup\ndiff -Nru git-1.2.2/Documentation/git-rm.txt git-1.2.2.patched/Documentation/git-rm.txt\n--- git-1.2.2/Documentation/git-rm.txt\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/Documentation/git-rm.txt\t2006-02-21 23:00:13.000000000 +0100\n@@ -0,0 +1,80 @@\n+git-rm(1)\n+=========\n+\n+NAME\n+----\n+git-rm - Remove files from the index.\n+\n+SYNOPSIS\n+--------\n+'git-rm' [-n|-f] [-v] <file>...\n+\n+DESCRIPTION\n+-----------\n+A convenience wrapper for rm and git-update-index --remove. For those\n+coming from cvs, git-rm provides an operation similar to \"cvs rm -f\".\n+\n+\n+OPTIONS\n+-------\n+<file>...::\n+\tFiles to remove from the working tree and the index.\n+\n+-n::\n+        Don't actually remove the file(s), just show if they exist in\n+        the index.\n+\n+-f::\n+        Delete the file(s) before removing it.\n+\n+-v::\n+        Be verbose.\n+\n+\n+DISCUSSION\n+----------\n+\n+The list of <file> given to the command is fed to `git-ls-files`\n+command to list files that are registered in the index and\n+are not ignored/excluded by `$GIT_DIR/info/exclude` file or\n+`.gitignore` file in each directory.  This means two things:\n+\n+. You can put the name of a directory on the command line, and the\n+  command will remove all files in it and its subdirectories (the\n+  directories themselves are not removed);\n+\n+. Giving the name of a file that is not in the index does not\n+  remove that file.\n+\n+\n+EXAMPLES\n+--------\n+git-rm Documentation/\\\\*.txt::\n+\n+\tRemoves all `\\*.txt` files that are in the index under\n+\t`Documentation` directory and its subdirectories.\n++\n+Note that the asterisk `\\*` is quoted from the shell in this\n+example; this lets the command include the files from\n+subdirectories of `Documentation/` directory.\n+\n+git-rm git-*.sh::\n+\n+\tRemove all git-*.sh scripts that are in the index.\n+\tBecause this example lets the shell expand the asterisk\n+\t(i.e. you are listing the files explicitly), it does not\n+\tremove `subdir/git-foo.sh`.\n+\n+\n+Author\n+------\n+Written by Linus Torvalds <torvalds@osdl.org>\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff -Nru git-1.2.2/Makefile git-1.2.2.patched/Makefile\n--- git-1.2.2/Makefile\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/Makefile\t2006-02-21 22:56:23.000000000 +0100\n@@ -107,7 +107,7 @@\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-prune.sh git-pull.sh git-push.sh git-rebase.sh \\\n \tgit-repack.sh git-request-pull.sh git-reset.sh \\\n-\tgit-resolve.sh git-revert.sh git-sh-setup.sh \\\n+\tgit-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \\\n \tgit-tag.sh git-verify-tag.sh git-whatchanged.sh \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\ndiff -Nru git-1.2.2/git-rm.sh git-1.2.2.patched/git-rm.sh\n--- git-1.2.2/git-rm.sh\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/git-rm.sh\t2006-02-21 23:25:47.000000000 +0100\n@@ -0,0 +1,65 @@\n+#!/bin/sh\n+\n+USAGE='<file>...'\n+SUBDIRECTORY_OK='Yes'\n+. git-sh-setup\n+\n+show_only=\n+verbose=\n+remove_files=\n+while : ; do\n+  case \"$1\" in\n+    -n)\n+\tshow_only=true\n+\t;;\n+    -v)\n+\tverbose=--verbose\n+\t;;\n+    -f)\n+\tremove_files=true\n+\t;;\n+    --)\n+\tbreak\n+\t;;\n+    -*)\n+\tusage\n+\t;;\n+    *)\n+\tbreak\n+\t;;\n+  esac\n+  shift\n+done\n+\n+# This is typo-proofing. If some paths match and some do not, we want\n+# to do nothing.\n+case \"$#\" in\n+0)\t;;\n+*)\n+\tgit-ls-files --error-unmatch -- \"$@\" >/dev/null || {\n+\t\techo >&2 \"Maybe you misspelled it?\"\n+\t\texit 1\n+\t}\n+\t;;\n+esac\n+\n+files=$(\n+    if test -f \"$GIT_DIR/info/exclude\" ; then\n+\tgit-ls-files \\\n+\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n+\t    --exclude-per-directory=.gitignore -- \"$@\"\n+    else\n+\tgit-ls-files \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+    fi | sort | uniq\n+)\n+\n+case \"$show_only\" in\n+true)\n+\techo $files\n+\t;;\n+*)\n+\t[[ \"$remove_files\" = \"true\" ]] && rm -f -- $files\n+\tgit-update-index --remove $verbose $files\n+\t;;\n+esac\n"},{"id":"16537","messageId":"20060221223254.GB20744@spearce.org","threadId":"3424","inReplyTo":"43FB9455.6010402@people.pl","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-02-21T22:32:54Z","receivedAt":"2006-02-21T22:32:54Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Krzysiek Pawlik <krzysiek.pawlik@people.pl> wrote:\n[...]\n> +while : ; do\n> +  case \"$1\" in\n> +    -n)\n> +\tshow_only=true\n> +\t;;\n> +    -v)\n> +\tverbose=--verbose\n> +\t;;\n> +    -f)\n> +\tremove_files=true\n> +\t;;\n> +    --)\n> +\tbreak\n> +\t;;\n> +    -*)\n> +\tusage\n> +\t;;\n> +    *)\n> +\tbreak\n> +\t;;\n> +  esac\n> +  shift\n> +done\n[...]\n\nYou are leaving -- in $@ for processing later, which means we'll\ntry to delete the file '--'.  :-)\n\nI think a shift before the break in the -- case would fix this.\n\n-- \nShawn.\n"},{"id":"16539","messageId":"43FB95F3.8010504@people.pl","threadId":"3424","inReplyTo":"20060221223254.GB20744@spearce.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Krzysiek Pawlik","fromEmail":"krzysiek.pawlik@people.pl","sentAt":"2006-02-21T22:36:35Z","receivedAt":"2006-02-21T22:36:35Z","isPatch":true,"sender":{"key":"krzysiek.pawlik@people.pl","avatar":"https://gravatar.com/avatar/05218c3d47410c496c83467dd36d83d4e4457f4825f00124575b50302bd952e2?d=mp&s=160"},"body":"Shawn Pearce wrote:\n> You are leaving -- in $@ for processing later, which means we'll\n> try to delete the file '--'.  :-)\n> \n> I think a shift before the break in the -- case would fix this.\n\nYay! Another stupid mistake from me ;) Thanks again :)\n\n-- \nKrzysiek Pawlik (Nelchael)\nRLU #322999 GPG Key ID: 0xBC555551\n\n\ndiff -Nru git-1.2.2/.gitignore git-1.2.2.patched/.gitignore\n--- git-1.2.2/.gitignore\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/.gitignore\t2006-02-21 22:56:23.000000000 +0100\n@@ -84,6 +84,7 @@\n git-rev-list\n git-rev-parse\n git-revert\n+git-rm\n git-send-email\n git-send-pack\n git-sh-setup\ndiff -Nru git-1.2.2/Documentation/git-rm.txt git-1.2.2.patched/Documentation/git-rm.txt\n--- git-1.2.2/Documentation/git-rm.txt\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/Documentation/git-rm.txt\t2006-02-21 23:00:13.000000000 +0100\n@@ -0,0 +1,80 @@\n+git-rm(1)\n+=========\n+\n+NAME\n+----\n+git-rm - Remove files from the index.\n+\n+SYNOPSIS\n+--------\n+'git-rm' [-n|-f] [-v] <file>...\n+\n+DESCRIPTION\n+-----------\n+A convenience wrapper for rm and git-update-index --remove. For those\n+coming from cvs, git-rm provides an operation similar to \"cvs rm -f\".\n+\n+\n+OPTIONS\n+-------\n+<file>...::\n+\tFiles to remove from the working tree and the index.\n+\n+-n::\n+        Don't actually remove the file(s), just show if they exist in\n+        the index.\n+\n+-f::\n+        Delete the file(s) before removing it.\n+\n+-v::\n+        Be verbose.\n+\n+\n+DISCUSSION\n+----------\n+\n+The list of <file> given to the command is fed to `git-ls-files`\n+command to list files that are registered in the index and\n+are not ignored/excluded by `$GIT_DIR/info/exclude` file or\n+`.gitignore` file in each directory.  This means two things:\n+\n+. You can put the name of a directory on the command line, and the\n+  command will remove all files in it and its subdirectories (the\n+  directories themselves are not removed);\n+\n+. Giving the name of a file that is not in the index does not\n+  remove that file.\n+\n+\n+EXAMPLES\n+--------\n+git-rm Documentation/\\\\*.txt::\n+\n+\tRemoves all `\\*.txt` files that are in the index under\n+\t`Documentation` directory and its subdirectories.\n++\n+Note that the asterisk `\\*` is quoted from the shell in this\n+example; this lets the command include the files from\n+subdirectories of `Documentation/` directory.\n+\n+git-rm git-*.sh::\n+\n+\tRemove all git-*.sh scripts that are in the index.\n+\tBecause this example lets the shell expand the asterisk\n+\t(i.e. you are listing the files explicitly), it does not\n+\tremove `subdir/git-foo.sh`.\n+\n+\n+Author\n+------\n+Written by Linus Torvalds <torvalds@osdl.org>\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff -Nru git-1.2.2/Makefile git-1.2.2.patched/Makefile\n--- git-1.2.2/Makefile\t2006-02-19 01:19:00.000000000 +0100\n+++ git-1.2.2.patched/Makefile\t2006-02-21 22:56:23.000000000 +0100\n@@ -107,7 +107,7 @@\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-prune.sh git-pull.sh git-push.sh git-rebase.sh \\\n \tgit-repack.sh git-request-pull.sh git-reset.sh \\\n-\tgit-resolve.sh git-revert.sh git-sh-setup.sh \\\n+\tgit-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \\\n \tgit-tag.sh git-verify-tag.sh git-whatchanged.sh \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\ndiff -Nru git-1.2.2/git-rm.sh git-1.2.2.patched/git-rm.sh\n--- git-1.2.2/git-rm.sh\t1970-01-01 01:00:00.000000000 +0100\n+++ git-1.2.2.patched/git-rm.sh\t2006-02-21 23:35:11.000000000 +0100\n@@ -0,0 +1,66 @@\n+#!/bin/sh\n+\n+USAGE='<file>...'\n+SUBDIRECTORY_OK='Yes'\n+. git-sh-setup\n+\n+show_only=\n+verbose=\n+remove_files=\n+while : ; do\n+  case \"$1\" in\n+    -n)\n+\tshow_only=true\n+\t;;\n+    -v)\n+\tverbose=--verbose\n+\t;;\n+    -f)\n+\tremove_files=true\n+\t;;\n+    --)\n+\tshift\n+\tbreak\n+\t;;\n+    -*)\n+\tusage\n+\t;;\n+    *)\n+\tbreak\n+\t;;\n+  esac\n+  shift\n+done\n+\n+# This is typo-proofing. If some paths match and some do not, we want\n+# to do nothing.\n+case \"$#\" in\n+0)\t;;\n+*)\n+\tgit-ls-files --error-unmatch -- \"$@\" >/dev/null || {\n+\t\techo >&2 \"Maybe you misspelled it?\"\n+\t\texit 1\n+\t}\n+\t;;\n+esac\n+\n+files=$(\n+    if test -f \"$GIT_DIR/info/exclude\" ; then\n+\tgit-ls-files \\\n+\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n+\t    --exclude-per-directory=.gitignore -- \"$@\"\n+    else\n+\tgit-ls-files \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+    fi | sort | uniq\n+)\n+\n+case \"$show_only\" in\n+true)\n+\techo $files\n+\t;;\n+*)\n+\t[[ \"$remove_files\" = \"true\" ]] && rm -f -- $files\n+\tgit-update-index --remove $verbose $files\n+\t;;\n+esac\n"},{"id":"16543","messageId":"87slqcs4y5.wl%cworth@cworth.org","threadId":"3424","inReplyTo":"43FB8F31.9090302@people.pl","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-21T22:49:22Z","receivedAt":"2006-02-21T22:49:22Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"On Tue, 21 Feb 2006 23:07:45 +0100, Krzysiek Pawlik wrote:\n> \n> I've modified it a little - it has now a '-f' option to delete files\n> (much like cvs rm behaviour).\n\nAs is, without -f, git-rm will instead act just like git-update-index.\n\nIf the -f option is desired we could get the correct behavior by using\nupdate-index --force-remove when not given -f and update-index\n--remove when given -f.\n\nThat's enough complexity to warrant a test case. I'll be back shortly\nwith that...\n\n-Carl\n"},{"id":"16545","messageId":"87r75ws48c.wl%cworth@cworth.org","threadId":"3424","inReplyTo":"87slqcs4y5.wl%cworth@cworth.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-21T23:04:51Z","receivedAt":"2006-02-21T23:04:51Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"This adds a git-rm command which provides convenience similar to\ngit-add, (and a bit more since it takes care of the rm as well if\ngiven -f).\n\nLike git-add, git-rm expands the given path names through\ngit-ls-files. This means it only acts on files listed in the\nindex. And it does act recursively on directories by default, (no -r\nneeded as in the case of rm itself). When it recurses, it does not\nremove empty directories that are left behind.\n\n---\n\n On Tue, 21 Feb 2006 14:49:22 -0800, Carl Worth wrote:\n > If the -f option is desired we could get the correct behavior by using\n > update-index --force-remove when not given -f and update-index\n > --remove when given -f.\n\n One good argument for having the -f behavior is that this way\n \"git rm file\" makes a good complement for \"git add file\". I know that\n someone (recently?) asked on the list for an \"unadd\" operation. This\n would definitely be a lot more convenient than \"git update-index\n --force-remove file\".\n\n > That's enough complexity to warrant a test case. I'll be back shortly\n > with that...\n\n Here it is. This is a complete patch from master, rather than\n the incremental version that's in my tree.\n\n .gitignore               |    1\n Documentation/git-rm.txt |   89\n +++++++++++++++++++++++++++++++++++++++++++++++\n Makefile                 |    2 -\n git-rm.sh                |   67 +++++++++++++++++++++++++++++++++++\n t/t3600-rm.sh            |   42 ++++++++++++++++++++++\n 5 files changed, 200 insertions(+), 1 deletion(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex d7e8d2a..94f66d5 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -84,6 +84,7 @@ git-resolve\n git-rev-list\n git-rev-parse\n git-revert\n+git-rm\n git-send-email\n git-send-pack\n git-sh-setup\ndiff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt\nnew file mode 100644\nindex 0000000..401bfb2\n--- /dev/null\n+++ b/Documentation/git-rm.txt\n@@ -0,0 +1,89 @@\n+git-rm(1)\n+=========\n+\n+NAME\n+----\n+git-rm - Remove files from the working tree and from the index.\n+\n+SYNOPSIS\n+--------\n+'git-rm' [-f] [-n] [-v] [--] <file>...\n+\n+DESCRIPTION\n+-----------\n+A convenience wrapper for git-update-index --remove. For those coming\n+from cvs, git-rm provides an operation similar to \"cvs rm\" or \"cvs\n+remove\".\n+\n+\n+OPTIONS\n+-------\n+<file>...::\n+\tFiles to remove from the index and optionally, from the\n+\tworking tree as well.\n+\n+-f::\n+\tRemove files from the working tree as well as from the index.\n+\n+-n::\n+        Don't actually remove the file(s), just show if they exist in\n+        the index.\n+\n+-v::\n+        Be verbose.\n+\n+--::\n+\tThis option can be used to separate command-line options from\n+\tthe list of files, (useful when filenames might be mistaken\n+\tfor command-line options).\n+\n+\n+DISCUSSION\n+----------\n+\n+The list of <file> given to the command is fed to `git-ls-files`\n+command to list files that are registered in the index and\n+are not ignored/excluded by `$GIT_DIR/info/exclude` file or\n+`.gitignore` file in each directory.  This means two things:\n+\n+. You can put the name of a directory on the command line, and the\n+  command will remove all files in it and its subdirectories (the\n+  directories themselves are never removed from the working tree);\n+\n+. Giving the name of a file that is not in the index does not\n+  remove that file.\n+\n+\n+EXAMPLES\n+--------\n+git-rm Documentation/\\\\*.txt::\n+\n+\tRemoves all `\\*.txt` files from the index that are under the\n+\t`Documentation` directory and any of its subdirectories. The\n+\tfiles are not removed from the working tree.\n++\n+Note that the asterisk `\\*` is quoted from the shell in this\n+example; this lets the command include the files from\n+subdirectories of `Documentation/` directory.\n+\n+git-rm -f git-*.sh::\n+\n+\tRemove all git-*.sh scripts that are in the index. The files\n+\tare removed from the index, and (because of the -f option),\n+\tfrom the working tree as well. Because this example lets the\n+\tshell expand the asterisk (i.e. you are listing the files\n+\texplicitly), it does not remove `subdir/git-foo.sh`.\n+\n+\n+Author\n+------\n+Written by Linus Torvalds <torvalds@osdl.org>\n+\n+Documentation\n+--------------\n+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff --git a/Makefile b/Makefile\nindex 317be3c..e98b056 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -109,7 +109,7 @@ SCRIPT_SH = \\\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-prune.sh git-pull.sh git-push.sh git-rebase.sh \\\n \tgit-repack.sh git-request-pull.sh git-reset.sh \\\n-\tgit-resolve.sh git-revert.sh git-sh-setup.sh \\\n+\tgit-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \\\n \tgit-tag.sh git-verify-tag.sh git-whatchanged.sh \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\ndiff --git a/git-rm.sh b/git-rm.sh\nnew file mode 100644\nindex 0000000..0a3f546\n--- /dev/null\n+++ b/git-rm.sh\n@@ -0,0 +1,67 @@\n+#!/bin/sh\n+\n+USAGE='[-f] [-n] [-v] [--] <file>...'\n+SUBDIRECTORY_OK='Yes'\n+. git-sh-setup\n+\n+index_remove_option=--force-remove\n+remove_files=\n+show_only=\n+verbose=\n+while : ; do\n+  case \"$1\" in\n+    -f)\n+\tremove_files=true\n+\tindex_remote_option=--force\n+\t;;\n+    -n)\n+\tshow_only=true\n+\t;;\n+    -v)\n+\tverbose=--verbose\n+\t;;\n+    --)\n+\tshift; break\n+\t;;\n+    -*)\n+\tusage\n+\t;;\n+    *)\n+\tbreak\n+\t;;\n+  esac\n+  shift\n+done\n+\n+# This is typo-proofing. If some paths match and some do not, we want\n+# to do nothing.\n+case \"$#\" in\n+0)\t;;\n+*)\n+\tgit-ls-files --error-unmatch -- \"$@\" >/dev/null || {\n+\t\techo >&2 \"Maybe you misspelled it?\"\n+\t\texit 1\n+\t}\n+\t;;\n+esac\n+\n+files=$(\n+    if test -f \"$GIT_DIR/info/exclude\" ; then\n+\tgit-ls-files \\\n+\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n+\t    --exclude-per-directory=.gitignore -- \"$@\"\n+    else\n+\tgit-ls-files \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+    fi | sort | uniq\n+)\n+\n+case \"$show_only\" in\n+true)\n+\techo $files\n+\t;;\n+*)\n+\t[[ \"$remove_files\" = \"true\" ]] && rm -- $files\n+\tgit-update-index $index_remove_option $verbose $files\n+\t;;\n+esac\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nnew file mode 100755\nindex 0000000..8415732\n--- /dev/null\n+++ b/t/t3600-rm.sh\n@@ -0,0 +1,42 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006 Carl D. Worth\n+#\n+\n+test_description='Test of the various options to git-rm.'\n+\n+. ./test-lib.sh\n+\n+# Setup some files to be removed\n+touch foo bar\n+git-add foo bar\n+# Need one to test --\n+touch -- -q\n+git update-index --add -- -q\n+git-commit -m \"add foo, bar, and -q\"\n+\n+test_expect_success \\\n+    'Pre-check that foo is in index before git-rm foo' \\\n+    'git-ls-files --error-unmatch foo'\n+\n+test_expect_success \\\n+    'Test that git-rm foo succeeds' \\\n+    'git-rm foo'\n+\n+test_expect_failure \\\n+    'Post-check that foo is not in index after git-rm foo' \\\n+    'git-ls-files --error-unmatch foo'\n+\n+test_expect_success \\\n+    'Test that \"git-rm -f bar\" works' \\\n+    'git-rm -f bar'\n+\n+test_expect_failure \\\n+    'Post-check that bar no longer exists' \\\n+    '[ -f bar ]'\n+\n+test_expect_success \\\n+    'Test that \"git-rm -- -q\" works to delete a file named -q' \\\n+    'git-rm -- -q'\n+\n+test_done\n"},{"id":"16565","messageId":"7vaccjst3x.fsf@assigned-by-dhcp.cox.net","threadId":"3424","inReplyTo":"87r75ws48c.wl%cworth@cworth.org","subject":"Re: [PATCH] Add new git-rm command with documentation","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-22T08:19:46Z","receivedAt":"2006-02-22T08:19:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Worth <cworth@cworth.org> writes:\n\n> +files=$(\n> +    if test -f \"$GIT_DIR/info/exclude\" ; then\n> +\tgit-ls-files \\\n> +\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n> +\t    --exclude-per-directory=.gitignore -- \"$@\"\n> +    else\n> +\tgit-ls-files \\\n> +\t--exclude-per-directory=.gitignore -- \"$@\"\n> +    fi | sort | uniq\n> +)\n\nNote you are not using -z, which means we will c-quote the funny\ncharacters in the output...\n\n> +case \"$show_only\" in\n> +true)\n> +\techo $files\n> +\t;;\n\nAnd here $files lack surrounding double quote.  For human\nconsumption it might be OK, but I somehow care about a bit of\ndetails like this.\n\n> +*)\n> +\t[[ \"$remove_files\" = \"true\" ]] && rm -- $files\n\nSame here. What happens to filenames with IFS letters in them?\n\"git-add\" does not use -z and xargs -0 without a good reason.\n\n> +\tgit-update-index $index_remove_option $verbose $files\n> +\t;;\n> +esac\n\nEven if rm -- $files were quoted correctly, and tried to remove\nthe right files, if some of the files failed to disappear for\nwhatever reason, what happens?\n"},{"id":"16596","messageId":"8764n7rl6s.wl%cworth@cworth.org","threadId":"3424","inReplyTo":"7vaccjst3x.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc.","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-23T00:08:27Z","receivedAt":"2006-02-23T00:08:27Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"New tests are added to the git-rm test case to cover this as well.\n\nSigned-off-by: Carl Worth <cworth@cworth.org>\n\n---\n\nOn Wed, 22 Feb 2006 00:19:46 -0800, Junio C Hamano wrote:\n>\n> Note you are not using -z, which means we will c-quote the funny\n> characters in the output...\n\nOh, I didn't expect C-language-style quoting. That's definitely not\ngoing to work.\n\n> > +*)\n> > +\t[[ \"$remove_files\" = \"true\" ]] && rm -- $files\n> \n> Same here. What happens to filenames with IFS letters in them?\n> \"git-add\" does not use -z and xargs -0 without a good reason.\n\nYeah, this is just me unleashing my shell-programming incompetence on\nthe world.\n\nThe attached patch addresses that problem with a rather blunt\nhammer. Let me know if anyone has a more elegant approach than what I\ndid here.\n\nOne thing I've lost is that the previous version had a sort|uniq on\nthe output of git-ls-files which is useful in the case of failed\nmerges and other ways in which git-ls-files reports the same file\nmultiple times. What might be nice is a --unique flag to git-ls-files\nthat git-rm could use, (but on first glance it doesn't look trivial to\nimplement as git-ls-files doesn't ever store or sort its entire list).\n\n> Even if rm -- $files were quoted correctly, and tried to remove\n> the right files, if some of the files failed to disappear for\n> whatever reason, what happens?\n\nMy intent with the previous patch was that, when git-rm is given -f,\nand the rm fails to remove a file, that the file is then not removed\nfrom the index. Of course, this was hopelessly broken due to two major\ntypos in the same line:\n\n\tindex_remote_option=--force\ninstead of:\n\tindex_remove_option=--remove\n\nwhich my tests were insufficient to catch.\n\nThis behavior should now work in the current patch as well as the\nproper handling of files with funny characters, (tests are included\nfor both).\n\nThe desired behavior when rm fails is debatable, so I'm open to\nopinions. One reason I liked this was that in the previous patch, rm\nwould prompt the user before deleting a read-only file, and if the\nuser said no, then git-rm would also not remove it from the index.\n\nThis did cause another minor problem in that there would then be no\nway to get git-rm to use \"rm -f\" when desired.\n\nIn the current patch, with my blunt hammer, there's another sub-shell\nbefore the rm which apparently steals its tty and causes it to not\nprompt at all. So that aspect may be moot.\n\n-Carl\n\nPS. What's the syntax/tool support for just replying to an existing\nmessage, and at the end inserting a patch with its own subject and\ncommit message? Here I've manually whacked the subject and put the\ncommit message above my reply (in the style of git-format-patch) but\nthat seem seems inelegant.\n\n git-rm.sh     |   37 ++++++++++++++++++++-----------------\n t/t3600-rm.sh |   30 ++++++++++++++++++++++--------\n 2 files changed, 42 insertions(+), 25 deletions(-)\n\n3d52c6d60047390d434f8737368adea77fa26310\ndiff --git a/git-rm.sh b/git-rm.sh\nindex 0a3f546..fa361bd 100755\n--- a/git-rm.sh\n+++ b/git-rm.sh\n@@ -4,7 +4,6 @@ USAGE='[-f] [-n] [-v] [--] <file>...'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n-index_remove_option=--force-remove\n remove_files=\n show_only=\n verbose=\n@@ -12,7 +11,6 @@ while : ; do\n   case \"$1\" in\n     -f)\n \tremove_files=true\n-\tindex_remote_option=--force\n \t;;\n     -n)\n \tshow_only=true\n@@ -45,23 +43,28 @@ case \"$#\" in\n \t;;\n esac\n \n-files=$(\n-    if test -f \"$GIT_DIR/info/exclude\" ; then\n-\tgit-ls-files \\\n-\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n-\t    --exclude-per-directory=.gitignore -- \"$@\"\n-    else\n-\tgit-ls-files \\\n+if test -f \"$GIT_DIR/info/exclude\"\n+then\n+\tgit-ls-files -z \\\n+\t--exclude-from=\"$GIT_DIR/info/exclude\" \\\n \t--exclude-per-directory=.gitignore -- \"$@\"\n-    fi | sort | uniq\n-)\n-\n-case \"$show_only\" in\n-true)\n-\techo $files\n+else\n+\tgit-ls-files -z \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+fi |\n+case \"$show_only,remove_files\" in\n+true,*)\n+\txargs -0 echo\n+\t;;\n+*,true)\n+\txargs -0 sh -c \"\n+\t\twhile [ \\$# -gt 0 ]; do\n+\t\t\tfile=\\$1; shift\n+\t\t\trm -- \\\"\\$file\\\" && git-update-index --remove $verbose \\\"\\$file\\\"\n+\t\tdone\n+\t\" inline\n \t;;\n *)\n-\t[[ \"$remove_files\" = \"true\" ]] && rm -- $files\n-\tgit-update-index $index_remove_option $verbose $files\n+\tgit-update-index --force-remove $verbose -z --stdin\n \t;;\n esac\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nindex 8415732..b87beb0 100755\n--- a/t/t3600-rm.sh\n+++ b/t/t3600-rm.sh\n@@ -7,13 +7,12 @@ test_description='Test of the various op\n \n . ./test-lib.sh\n \n-# Setup some files to be removed\n-touch foo bar\n-git-add foo bar\n-# Need one to test --\n-touch -- -q\n-git update-index --add -- -q\n-git-commit -m \"add foo, bar, and -q\"\n+# Setup some files to be removed, some with funny characters\n+touch -- foo bar baz 'space embedded' 'tab\tembedded' 'newline\n+embedded' -q\n+git-add -- foo bar baz 'space embedded' 'tab\tembedded' 'newline\n+embedded' -q\n+git-commit -m \"add files\"\n \n test_expect_success \\\n     'Pre-check that foo is in index before git-rm foo' \\\n@@ -36,7 +35,22 @@ test_expect_failure \\\n     '[ -f bar ]'\n \n test_expect_success \\\n-    'Test that \"git-rm -- -q\" works to delete a file named -q' \\\n+    'Test that \"git-rm -- -q\" works to delete a file that looks like an option' \\\n     'git-rm -- -q'\n \n+test_expect_success \\\n+    \"Test that \\\"git-rm -f\\\" can remove files with embedded space, tab, or newline characters.\" \\\n+    \"git-rm 'space embedded' 'tab\tembedded' 'newline\n+embedded\"\n+\n+chmod u-w .\n+test_expect_failure \\\n+    'Test that \"git-rm -f\" fails if its rm fails' \\\n+    'git-rm -f baz'\n+chmod u+w .\n+\n+test_expect_success \\\n+    'When the rm in \"git-rm -f\" fails, it should not remove the file from the index' \\\n+    'git-ls-files --error-unmatch baz'\n+\n test_done\n-- \n1.2.2.g01a2-dirty\n\n\n"},{"id":"16598","messageId":"873biasyew.wl%cworth@cworth.org","threadId":"3424","inReplyTo":"8764n7rl6s.wl%cworth@cworth.org","subject":"Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc.","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-02-23T00:37:27Z","receivedAt":"2006-02-23T00:37:27Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"New tests are added to the git-rm test case to cover this as well.\n\nSigned-off-by: Carl Worth <cworth@cworth.org>\n\n---\n\n Please ignore the previous patch. This is what I intended to send.\n\n (For as useful as the index is---and yes, I have found it very\n useful---I still find it easy to inadvertently commit stale data with\n it. I guess what might help me is a command to update into the index\n all files that are currently in the \"updated but not checked in (will\n commit)\" state as reported by git status. Does such a command exist?)\n\n -Carl\n\n git-rm.sh     |   37 ++++++++++++++++++++-----------------\n t/t3600-rm.sh |   52 +++++++++++++++++++++++++++++++++++-----------------\n 2 files changed, 55 insertions(+), 34 deletions(-)\n\n3bd80bae8dc2b004a3109018f0efb0007804b79d\ndiff --git a/git-rm.sh b/git-rm.sh\nindex 0a3f546..fda4541 100755\n--- a/git-rm.sh\n+++ b/git-rm.sh\n@@ -4,7 +4,6 @@ USAGE='[-f] [-n] [-v] [--] <file>...'\n SUBDIRECTORY_OK='Yes'\n . git-sh-setup\n \n-index_remove_option=--force-remove\n remove_files=\n show_only=\n verbose=\n@@ -12,7 +11,6 @@ while : ; do\n   case \"$1\" in\n     -f)\n \tremove_files=true\n-\tindex_remote_option=--force\n \t;;\n     -n)\n \tshow_only=true\n@@ -45,23 +43,28 @@ case \"$#\" in\n \t;;\n esac\n \n-files=$(\n-    if test -f \"$GIT_DIR/info/exclude\" ; then\n-\tgit-ls-files \\\n-\t    --exclude-from=\"$GIT_DIR/info/exclude\" \\\n-\t    --exclude-per-directory=.gitignore -- \"$@\"\n-    else\n-\tgit-ls-files \\\n+if test -f \"$GIT_DIR/info/exclude\"\n+then\n+\tgit-ls-files -z \\\n+\t--exclude-from=\"$GIT_DIR/info/exclude\" \\\n \t--exclude-per-directory=.gitignore -- \"$@\"\n-    fi | sort | uniq\n-)\n-\n-case \"$show_only\" in\n-true)\n-\techo $files\n+else\n+\tgit-ls-files -z \\\n+\t--exclude-per-directory=.gitignore -- \"$@\"\n+fi |\n+case \"$show_only,$remove_files\" in\n+true,*)\n+\txargs -0 echo\n+\t;;\n+*,true)\n+\txargs -0 sh -c \"\n+\t\twhile [ \\$# -gt 0 ]; do\n+\t\t\tfile=\\$1; shift\n+\t\t\trm -- \\\"\\$file\\\" && git-update-index --remove $verbose \\\"\\$file\\\"\n+\t\tdone\n+\t\" inline\n \t;;\n *)\n-\t[[ \"$remove_files\" = \"true\" ]] && rm -- $files\n-\tgit-update-index $index_remove_option $verbose $files\n+\tgit-update-index --force-remove $verbose -z --stdin\n \t;;\n esac\ndiff --git a/t/t3600-rm.sh b/t/t3600-rm.sh\nindex 8415732..cabfadd 100755\n--- a/t/t3600-rm.sh\n+++ b/t/t3600-rm.sh\n@@ -7,36 +7,54 @@ test_description='Test of the various op\n \n . ./test-lib.sh\n \n-# Setup some files to be removed\n-touch foo bar\n-git-add foo bar\n-# Need one to test --\n-touch -- -q\n-git update-index --add -- -q\n-git-commit -m \"add foo, bar, and -q\"\n+# Setup some files to be removed, some with funny characters\n+touch -- foo bar baz 'space embedded' 'tab\tembedded' 'newline\n+embedded' -q\n+git-add -- foo bar baz 'space embedded' 'tab\tembedded' 'newline\n+embedded' -q\n+git-commit -m \"add files\"\n \n test_expect_success \\\n-    'Pre-check that foo is in index before git-rm foo' \\\n-    'git-ls-files --error-unmatch foo'\n+    'Pre-check that foo exists and is in index before git-rm foo' \\\n+    '[ -f foo ] && git-ls-files --error-unmatch foo'\n \n test_expect_success \\\n     'Test that git-rm foo succeeds' \\\n     'git-rm foo'\n \n-test_expect_failure \\\n-    'Post-check that foo is not in index after git-rm foo' \\\n-    'git-ls-files --error-unmatch foo'\n+test_expect_success \\\n+    'Post-check that foo exists but is not in index after git-rm foo' \\\n+    '[ -f foo ] && ! git-ls-files --error-unmatch foo'\n+\n+test_expect_success \\\n+    'Pre-check that bar exists and is in index before \"git-rm -f bar\"' \\\n+    '[ -f bar ] && git-ls-files --error-unmatch bar'\n \n test_expect_success \\\n-    'Test that \"git-rm -f bar\" works' \\\n+    'Test that \"git-rm -f bar\" succeeds' \\\n     'git-rm -f bar'\n \n-test_expect_failure \\\n-    'Post-check that bar no longer exists' \\\n-    '[ -f bar ]'\n+test_expect_success \\\n+    'Post-check that bar does not exist and is not in index after \"git-rm -f bar\"' \\\n+    '! [ -f bar ] && ! git-ls-files --error-unmatch bar'\n \n test_expect_success \\\n-    'Test that \"git-rm -- -q\" works to delete a file named -q' \\\n+    'Test that \"git-rm -- -q\" succeeds (remove a file that looks like an option)' \\\n     'git-rm -- -q'\n \n+test_expect_success \\\n+    \"Test that \\\"git-rm -f\\\" succeeds with embedded space, tab, or newline characters.\" \\\n+    \"git-rm -f 'space embedded' 'tab\tembedded' 'newline\n+embedded'\"\n+\n+chmod u-w .\n+test_expect_failure \\\n+    'Test that \"git-rm -f\" fails if its rm fails' \\\n+    'git-rm -f baz'\n+chmod u+w .\n+\n+test_expect_success \\\n+    'When the rm in \"git-rm -f\" fails, it should not remove the file from the index' \\\n+    'git-ls-files --error-unmatch baz'\n+\n test_done\n-- \n1.2.2.g3d52-dirty\n\n"},{"id":"16599","messageId":"7vbqwylw64.fsf@assigned-by-dhcp.cox.net","threadId":"3424","inReplyTo":"873biasyew.wl%cworth@cworth.org","subject":"Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-23T01:07:47Z","receivedAt":"2006-02-23T01:07:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Worth <cworth@cworth.org> writes:\n\n>  Please ignore the previous patch. This is what I intended to send.\n\nAhh.  I was wondering...\n\n>  (For as useful as the index is---and yes, I have found it very\n>  useful---I still find it easy to inadvertently commit stale data with\n>  it. I guess what might help me is a command to update into the index\n>  all files that are currently in the \"updated but not checked in (will\n>  commit)\" state as reported by git status. Does such a command exist?)\n\nNo.  I do not do this myself, but this one-liner should work:\n\n\tgit diff --name-only \"$@\" | git update-index --stdin\n\n[from another message]\n\n> PS. What's the syntax/tool support for just replying to an existing\n> message, and at the end inserting a patch with its own subject and\n> commit message? Here I've manually whacked the subject and put the\n> commit message above my reply (in the style of git-format-patch) but\n> that seems inelegant.\n\nYMMV depending on the MUA you use, of course.\n\nI start [REPLY], have my MUA quote the original and write\nresponse while trimming excess quote, just as usual.  When I\nneed to add a patch, then I remove all that with \\C-w\n(kill-region), read a format-patch output into the same mail\nbuffer, and then \\C-y (yank) to paste the \"usual correspondence\"\npart below the three-dash lines.  Yes, it's all manual.  I\npresume it would be easy to write a few-liner Emacs macro to do\nthis though...\n"},{"id":"16671","messageId":"81b0412b0602240523l1b10c910q6e5d2e3cef82e306@mail.gmail.com","threadId":"3424","inReplyTo":"8764n7rl6s.wl%cworth@cworth.org","subject":"Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc.","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-02-24T13:23:08Z","receivedAt":"2006-02-24T13:23:08Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 2/23/06, Carl Worth <cworth@cworth.org> wrote:\n> +# Setup some files to be removed, some with funny characters\n> +touch -- foo bar baz 'space embedded' 'tab     embedded' 'newline\n> +embedded' -q\n> +git-add -- foo bar baz 'space embedded' 'tab   embedded' 'newline\n> +embedded' -q\n> +git-commit -m \"add files\"\n\nThis doesn't work on some exotic filesystems (ntfs and fat):\n\n*** t3600-rm.sh ***\ntouch: cannot touch `tab\\tembedded': No such file or directory\ntouch: cannot touch `newline\\nembedded': No such file or directory\nerror: pathspec 'tab    embedded' did not match any.\nerror: pathspec 'newline\nembedded' did not match any.\nMaybe you misspelled it?\nNothing to commit\n* FAIL 1: Pre-check that foo exists and is in index before git-rm foo\n        [ -f foo ] && git-ls-files --error-unmatch foo\n* FAIL 2: Test that git-rm foo succeeds\n        git-rm foo\n* FAIL 4: Pre-check that bar exists and is in index before \"git-rm -f bar\"\n        [ -f bar ] && git-ls-files --error-unmatch bar\n* FAIL 5: Test that \"git-rm -f bar\" succeeds\n        git-rm -f bar\n* FAIL 6: Post-check that bar does not exist and is not in index after\n\"git-rm -f bar\"\n        ! [ -f bar ] && ! git-ls-files --error-unmatch bar\n* FAIL 7: Test that \"git-rm -- -q\" succeeds (remove a file that looks\nlike an option)\n        git-rm -- -q\n* FAIL 8: Test that \"git-rm -f\" succeeds with embedded space, tab, or\nnewline characters.\n        git-rm -f 'space embedded' 'tab embedded' 'newline\n        embedded'\n* FAIL 10: When the rm in \"git-rm -f\" fails, it should not remove the\nfile from the index\n        git-ls-files --error-unmatch baz\n* failed 8 among 10 test(s)\n"},{"id":"16728","messageId":"7vu0ao6kip.fsf@assigned-by-dhcp.cox.net","threadId":"3424","inReplyTo":"81b0412b0602240523l1b10c910q6e5d2e3cef82e306@mail.gmail.com","subject":"Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-25T06:05:18Z","receivedAt":"2006-02-25T06:05:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> On 2/23/06, Carl Worth <cworth@cworth.org> wrote:\n>> +# Setup some files to be removed, some with funny characters\n>> +touch -- foo bar baz 'space embedded' 'tab     embedded' 'newline\n>> +embedded' -q\n>> +git-add -- foo bar baz 'space embedded' 'tab   embedded' 'newline\n>> +embedded' -q\n>> +git-commit -m \"add files\"\n>\n> This doesn't work on some exotic filesystems (ntfs and fat):\n\nSorry to have applied this without thinking.  Yes, we had\ndisabled a test that uses tab for this exact reason, but I have\nforgotten about it.\n"}]}