Re: [PATCH] Add new git-rm command with documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shawn Pearce wrote:
> You are leaving -- in $@ for processing later, which means we'll
> try to delete the file '--'.  :-)
> 
> I think a shift before the break in the -- case would fix this.

Yay! Another stupid mistake from me ;) Thanks again :)

-- 
Krzysiek Pawlik (Nelchael)
RLU #322999 GPG Key ID: 0xBC555551
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@xxxxxxxx>
+
+Documentation
+--------------
+Documentation by Junio C Hamano and the git-list <git@xxxxxxxxxxxxxxx>.
+
+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:35:11.000000000 +0100
@@ -0,0 +1,66 @@
+#!/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
+	;;
+    --)
+	shift
+	break
+	;;
+    -*)
+	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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]