{"thread":{"id":"3798","subject":"[PATCH] Add git-clean command","startedAt":"2006-04-05T06:00:48Z","lastAt":"2006-04-05T06:25:52Z","messageCount":2,"participants":["Pavel Roskin","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"18364","messageId":"20060405060048.6694.65940.stgit@dv.roinet.com","threadId":"3798","inReplyTo":null,"subject":"[PATCH] Add git-clean command","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2006-04-05T06:00:48Z","receivedAt":"2006-04-05T06:00:48Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"This command removes untracked files from the working tree.  This\nimplementation is based on cg-clean with some simplifications.  The\ndocumentation is included.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n---\n\n .gitignore                  |    1 +\n Documentation/git-clean.txt |   50 +++++++++++++++++++++++++++\n Makefile                    |    2 +\n git-clean.sh                |   80 +++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 132 insertions(+), 1 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex 75891c3..b5959d6 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -15,6 +15,7 @@ git-checkout\n git-checkout-index\n git-cherry\n git-cherry-pick\n+git-clean\n git-clone\n git-clone-pack\n git-commit\ndiff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt\nnew file mode 100644\nindex 0000000..e91b2ed\n--- /dev/null\n+++ b/Documentation/git-clean.txt\n@@ -0,0 +1,50 @@\n+git-clean(1)\n+============\n+\n+NAME\n+----\n+git-clean - Remove untracked files from the working tree\n+\n+SYNOPSIS\n+--------\n+[verse]\n+'git-clean' [-d | -D] [-n] [-q] [-x]\n+\n+DESCRIPTION\n+-----------\n+Removes files unknown to git.  This allows to clean the working tree\n+from files that are not under version control.  If the '-x' option is\n+specified, ignored files are also removed, allowing to remove all\n+build products.\n+\n+OPTIONS\n+-------\n+-d::\n+\tRemove untracked directories in addition to untracked files.\n+\n+-n::\n+\tDon't actually remove anything, just show what would be done.\n+\n+-q::\n+\tBe quiet, only report errors, but not the files that are\n+\tsuccessfully removed.\n+\n+-x::\n+\tDon't use the ignore rules.  This allows removing all untracked\n+\tfiles, including build products.  This can be used (possibly in\n+\tconjunction with gitlink:git-reset[1]) to create a pristine\n+\tworking directory to test a clean build.\n+\n+-X::\n+\tRemove only files ignored by git.  This may be useful to rebuild\n+\teverything from scratch, but keep manually created files.\n+\n+\n+Author\n+------\n+Written by Pavel Roskin <proski@gnu.org>\n+\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\ndiff --git a/Makefile b/Makefile\nindex 145099a..3367b8c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -114,7 +114,7 @@ ### --- END CONFIGURATION SECTION ---\n \n SCRIPT_SH = \\\n \tgit-add.sh git-bisect.sh git-branch.sh git-checkout.sh \\\n-\tgit-cherry.sh git-clone.sh git-commit.sh \\\n+\tgit-cherry.sh git-clean.sh git-clone.sh git-commit.sh \\\n \tgit-count-objects.sh git-diff.sh git-fetch.sh \\\n \tgit-format-patch.sh git-log.sh git-ls-remote.sh \\\n \tgit-merge-one-file.sh git-parse-remote.sh \\\ndiff --git a/git-clean.sh b/git-clean.sh\nnew file mode 100755\nindex 0000000..b200868\n--- /dev/null\n+++ b/git-clean.sh\n@@ -0,0 +1,80 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005-2006 Pavel Roskin\n+#\n+\n+USAGE=\"[-d] [-n] [-q] [-x | -X]\"\n+LONG_USAGE='Clean untracked files from the working directory\n+\t-d\tremove directories as well\n+\t-n \tdon'\\''t remove anything, just show what would be done\n+\t-q\tbe quiet, only report errors\n+\t-x\tremove ignored files as well\n+\t-X\tremove only ignored files as well'\n+SUBDIRECTORY_OK=Yes\n+. git-sh-setup\n+\n+ignored=\n+ignoredonly=\n+cleandir=\n+quiet=\n+rmf=\"rm -f\"\n+rmrf=\"rm -rf\"\n+rm_refuse=\"echo Not removing\"\n+echo1=\"echo\"\n+\n+while case \"$#\" in 0) break ;; esac\n+do\n+\tcase \"$1\" in\n+\t-d)\n+\t\tcleandir=1\n+\t\t;;\n+\t-n)\n+\t\tquiet=1\n+\t\trmf=\"echo Would remove\"\n+\t\trmrf=\"echo Would remove\"\n+\t\trm_refuse=\"echo Would not remove\"\n+\t\techo1=\":\"\n+\t\t;;\n+\t-q)\n+\t\tquiet=1\n+\t\t;;\n+\t-x)\n+\t\tignored=1\n+\t\t;;\n+\t-X)\n+\t\tignoredonly=1\n+\t\t;;\n+\t*)\n+\t\tusage\n+\tesac\n+\tshift\n+done\n+\n+case \"$ignored,$ignoredonly\" in\n+\t1,1) usage;;\n+esac\n+\n+if [ -z \"$ignored\" ]; then\n+\texcl=\"--exclude-per-directory=.gitignore\"\n+\tif [ -f \"$GIT_DIR/info/exclude\" ]; then\n+\t\texcl_info=\"--exclude-from=$GIT_DIR/info/exclude\"\n+\tfi\n+\tif [ \"$ignoredonly\" ]; then\n+\t\texcl=\"$excl --ignored\"\n+\tfi\n+fi\n+\n+git-ls-files --others --directory $excl ${excl_info:+\"$excl_info\"} |\n+while read -r file; do\n+\tif [ -d \"$file\" -a ! -L \"$file\" ]; then\n+\t\tif [ -z \"$cleandir\" ]; then\n+\t\t\t$rm_refuse \"$file\"\n+\t\t\tcontinue\n+\t\tfi\n+\t\t$echo1 \"Removing $file\"\n+\t\t$rmrf \"$file\"\n+\telse\n+\t\t$echo1 \"Removing $file\"\n+\t\t$rmf \"$file\"\n+\tfi\n+done\n"},{"id":"18367","messageId":"e0vntc$slu$1@sea.gmane.org","threadId":"3798","inReplyTo":"20060405060048.6694.65940.stgit@dv.roinet.com","subject":"Re: [PATCH] Add git-clean command","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-04-05T06:25:52Z","receivedAt":"2006-04-05T06:25:52Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Pavel Roskin wrote:\n\n> +SYNOPSIS\n> +--------\n> +[verse]\n> +'git-clean' [-d | -D] [-n] [-q] [-x]\n\nShouldn't it be\n> +'git-clean' [-d] [-n] [-q] [-x | -X]\nlike in below?\n\n> +USAGE=\"[-d] [-n] [-q] [-x | -X]\"\n\n-- \nJakub Narebski\nWarsaw, Poland\n"}]}