git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysiek Pawlik <krzysiek.pawlik@people.pl>
To: Carl Worth <cworth@cworth.org>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH] Add new git-rm command with documentation
Date: Tue, 21 Feb 2006 23:07:45 +0100	[thread overview]
Message-ID: <43FB8F31.9090302@people.pl> (raw)
In-Reply-To: <87u0ass7tj.wl%cworth@cworth.org>


[-- Attachment #1.1: Type: text/plain, Size: 376 bytes --]

Carl Worth wrote:
> This adds a git-rm command which provides convenience similar to
> git-add

I've modified it a little - it has now a '-f' option to delete files
(much like cvs rm behaviour). It makes it a bit safer ;) I've fixed the
`rm` - it wouldn't work for example for file named '--help'.

-- 
Krzysiek Pawlik (Nelchael)
RLU #322999 GPG Key ID: 0xBC555551

[-- Attachment #1.2: git-rm.patch --]
[-- Type: text/plain, Size: 4254 bytes --]

diff -Nru git-1.2.2/.gitignore git-1.2.2.patched/.gitignore
--- git-1.2.2/.gitignore	2006-02-19 01:19:00.000000000 +0100
+++ git-1.2.2.patched/.gitignore	2006-02-21 22:56:23.000000000 +0100
@@ -84,6 +84,7 @@
 git-rev-list
 git-rev-parse
 git-revert
+git-rm
 git-send-email
 git-send-pack
 git-sh-setup
diff -Nru git-1.2.2/Documentation/git-rm.txt git-1.2.2.patched/Documentation/git-rm.txt
--- git-1.2.2/Documentation/git-rm.txt	1970-01-01 01:00:00.000000000 +0100
+++ git-1.2.2.patched/Documentation/git-rm.txt	2006-02-21 23:00:13.000000000 +0100
@@ -0,0 +1,80 @@
+git-rm(1)
+=========
+
+NAME
+----
+git-rm - Remove files from the index.
+
+SYNOPSIS
+--------
+'git-rm' [-n|-f] [-v] <file>...
+
+DESCRIPTION
+-----------
+A convenience wrapper for rm and git-update-index --remove. For those
+coming from cvs, git-rm provides an operation similar to "cvs rm -f".
+
+
+OPTIONS
+-------
+<file>...::
+	Files to remove from the working tree and the index.
+
+-n::
+        Don't actually remove the file(s), just show if they exist in
+        the index.
+
+-f::
+        Delete the file(s) before removing it.
+
+-v::
+        Be verbose.
+
+
+DISCUSSION
+----------
+
+The list of <file> given to the command is fed to `git-ls-files`
+command to list files that are registered in the index and
+are not ignored/excluded by `$GIT_DIR/info/exclude` file or
+`.gitignore` file in each directory.  This means two things:
+
+. You can put the name of a directory on the command line, and the
+  command will remove all files in it and its subdirectories (the
+  directories themselves are not removed);
+
+. Giving the name of a file that is not in the index does not
+  remove that file.
+
+
+EXAMPLES
+--------
+git-rm Documentation/\\*.txt::
+
+	Removes all `\*.txt` files that are in the index under
+	`Documentation` directory and its subdirectories.
++
+Note that the asterisk `\*` is quoted from the shell in this
+example; this lets the command include the files from
+subdirectories of `Documentation/` directory.
+
+git-rm git-*.sh::
+
+	Remove all git-*.sh scripts that are in the index.
+	Because this example lets the shell expand the asterisk
+	(i.e. you are listing the files explicitly), it does not
+	remove `subdir/git-foo.sh`.
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff -Nru git-1.2.2/Makefile git-1.2.2.patched/Makefile
--- git-1.2.2/Makefile	2006-02-19 01:19:00.000000000 +0100
+++ git-1.2.2.patched/Makefile	2006-02-21 22:56:23.000000000 +0100
@@ -107,7 +107,7 @@
 	git-merge-one-file.sh git-parse-remote.sh \
 	git-prune.sh git-pull.sh git-push.sh git-rebase.sh \
 	git-repack.sh git-request-pull.sh git-reset.sh \
-	git-resolve.sh git-revert.sh git-sh-setup.sh \
+	git-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \
 	git-tag.sh git-verify-tag.sh git-whatchanged.sh \
 	git-applymbox.sh git-applypatch.sh git-am.sh \
 	git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
diff -Nru git-1.2.2/git-rm.sh git-1.2.2.patched/git-rm.sh
--- git-1.2.2/git-rm.sh	1970-01-01 01:00:00.000000000 +0100
+++ git-1.2.2.patched/git-rm.sh	2006-02-21 23:02:13.000000000 +0100
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+USAGE='<file>...'
+SUBDIRECTORY_OK='Yes'
+. git-sh-setup
+
+show_only=
+verbose=
+remove_files=
+while : ; do
+  case "$1" in
+    -n)
+	show_only=true
+	;;
+    -v)
+	verbose=--verbose
+	;;
+	-f)
+	remove_files=true
+	;;
+    -*)
+	usage
+	;;
+    *)
+	break
+	;;
+  esac
+  shift
+done
+
+# This is typo-proofing. If some paths match and some do not, we want
+# to do nothing.
+case "$#" in
+0)	;;
+*)
+	git-ls-files --error-unmatch -- "$@" >/dev/null || {
+		echo >&2 "Maybe you misspelled it?"
+		exit 1
+	}
+	;;
+esac
+
+files=$(
+    if test -f "$GIT_DIR/info/exclude" ; then
+	git-ls-files \
+	    --exclude-from="$GIT_DIR/info/exclude" \
+	    --exclude-per-directory=.gitignore -- "$@"
+    else
+	git-ls-files \
+	--exclude-per-directory=.gitignore -- "$@"
+    fi | sort | uniq
+)
+
+case "$show_only" in
+true)
+	echo $files
+	;;
+*)
+	[[ "$remove_files" = "true" ]] && rm -f -- $files
+	git-update-index --remove $verbose $files
+	;;
+esac

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

  reply	other threads:[~2006-02-21 22:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21 21:47 [PATCH] Add new git-rm command with documentation Carl Worth
2006-02-21 22:07 ` Krzysiek Pawlik [this message]
2006-02-21 22:14   ` Shawn Pearce
2006-02-21 22:29     ` Krzysiek Pawlik
2006-02-21 22:32       ` Shawn Pearce
2006-02-21 22:36         ` Krzysiek Pawlik
2006-02-21 22:49   ` Carl Worth
2006-02-21 23:04     ` Carl Worth
2006-02-22  8:19       ` Junio C Hamano
2006-02-23  0:08         ` [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc Carl Worth
2006-02-23  0:37           ` Carl Worth
2006-02-23  1:07             ` Junio C Hamano
2006-02-24 13:23           ` Alex Riesen
2006-02-25  6:05             ` Junio C Hamano
2006-02-21 22:15 ` [PATCH] Add new git-rm command with documentation Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43FB8F31.9090302@people.pl \
    --to=krzysiek.pawlik@people.pl \
    --cc=cworth@cworth.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).