* [PATCH] Add new git-rm command with documentation @ 2006-02-21 21:47 Carl Worth 2006-02-21 22:07 ` Krzysiek Pawlik 2006-02-21 22:15 ` [PATCH] Add new git-rm command with documentation Johannes Schindelin 0 siblings, 2 replies; 15+ messages in thread From: Carl Worth @ 2006-02-21 21:47 UTC (permalink / raw) To: Junio C Hamano; +Cc: git [-- Attachment #1: Type: text/plain, Size: 5162 bytes --] This adds a git-rm command which provides convenience similar to git-add, (and a bit more since it takes care of the rm as well). Like git-add, git-rm expands the given path names through git-ls-files. This means it only acts on files listed in the index. And it does act recursively on directories by default, (no -r needed as in the case of rm itself). When it recurses, it does not remove empty directories that are left behind. --- It wouldn't be too hard to make this act more like rm in requiring -r before recursing into directories. Let me know what people think about this. As before, if you'd prefer to fetch/pull this, you should be able to from: git://git.freedesktop.org/~cworth/git This time on the git-rm branch, (again merged into cworth for what that's worth). -Carl PS. I didn't change the Linus and Junio attribution since all of the code and documentation here is just minor changes from git-add. .gitignore | 1 + Documentation/git-rm.txt | 77 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 2 + git-rm.sh | 58 +++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 1 deletions(-) create mode 100644 Documentation/git-rm.txt create mode 100644 git-rm.sh cf3ff7a87defa6ced7e6a8b6d719a9f237a08314 diff --git a/.gitignore b/.gitignore index d7e8d2a..94f66d5 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ git-resolve git-rev-list git-rev-parse git-revert +git-rm git-send-email git-send-pack git-sh-setup diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt new file mode 100644 index 0000000..6095df8 --- /dev/null +++ b/Documentation/git-rm.txt @@ -0,0 +1,77 @@ +git-rm(1) +========= + +NAME +---- +git-rm - Remove files from the working tree and from the index. + +SYNOPSIS +-------- +'git-rm' [-n] [-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. + +-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 --git a/Makefile b/Makefile index 317be3c..e98b056 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ SCRIPT_SH = \ 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 --git a/git-rm.sh b/git-rm.sh new file mode 100644 index 0000000..840c458 --- /dev/null +++ b/git-rm.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +USAGE='<file>...' +SUBDIRECTORY_OK='Yes' +. git-sh-setup + +show_only= +verbose= +while : ; do + case "$1" in + -n) + show_only=true + ;; + -v) + verbose=--verbose + ;; + -*) + 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 + ;; +*) + rm $files + git-update-index --remove $verbose $files + ;; +esac -- 1.2.2.g73be-dirty [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 21:47 [PATCH] Add new git-rm command with documentation Carl Worth @ 2006-02-21 22:07 ` Krzysiek Pawlik 2006-02-21 22:14 ` Shawn Pearce 2006-02-21 22:49 ` Carl Worth 2006-02-21 22:15 ` [PATCH] Add new git-rm command with documentation Johannes Schindelin 1 sibling, 2 replies; 15+ messages in thread From: Krzysiek Pawlik @ 2006-02-21 22:07 UTC (permalink / raw) To: Carl Worth; +Cc: Junio C Hamano, git [-- 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 --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:07 ` Krzysiek Pawlik @ 2006-02-21 22:14 ` Shawn Pearce 2006-02-21 22:29 ` Krzysiek Pawlik 2006-02-21 22:49 ` Carl Worth 1 sibling, 1 reply; 15+ messages in thread From: Shawn Pearce @ 2006-02-21 22:14 UTC (permalink / raw) To: Krzysiek Pawlik; +Cc: Carl Worth, git How about supporting -- to break out of the option loop? The rest of the script will support files named --help just fine but the option parser will just spit out usage information. [...] > +while : ; do > + case "$1" in > + -n) > + show_only=true > + ;; > + -v) > + verbose=--verbose > + ;; > + -f) > + remove_files=true > + ;; > + -*) > + usage > + ;; > + *) > + break > + ;; > + esac > + shift > +done [...] Also I don't think the -f option's whitespace matches the others... -- Shawn. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:14 ` Shawn Pearce @ 2006-02-21 22:29 ` Krzysiek Pawlik 2006-02-21 22:32 ` Shawn Pearce 0 siblings, 1 reply; 15+ messages in thread From: Krzysiek Pawlik @ 2006-02-21 22:29 UTC (permalink / raw) To: Shawn Pearce; +Cc: cworth, git [-- Attachment #1.1: Type: text/plain, Size: 408 bytes --] Shawn Pearce wrote: > How about supporting -- to break out of the option loop? The rest > of the script will support files named --help just fine but the > option parser will just spit out usage information. Yeah... forgot to add this. > Also I don't think the -f option's whitespace matches the others... Thanks, fixed :) -- Krzysiek Pawlik (Nelchael) RLU #322999 GPG Key ID: 0xBC555551 [-- Attachment #1.2: git-rm.patch --] [-- Type: text/plain, Size: 4279 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:25:47.000000000 +0100 @@ -0,0 +1,65 @@ +#!/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 + ;; + --) + 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 #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 191 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:29 ` Krzysiek Pawlik @ 2006-02-21 22:32 ` Shawn Pearce 2006-02-21 22:36 ` Krzysiek Pawlik 0 siblings, 1 reply; 15+ messages in thread From: Shawn Pearce @ 2006-02-21 22:32 UTC (permalink / raw) To: Krzysiek Pawlik; +Cc: cworth, git Krzysiek Pawlik <krzysiek.pawlik@people.pl> wrote: [...] > +while : ; do > + case "$1" in > + -n) > + show_only=true > + ;; > + -v) > + verbose=--verbose > + ;; > + -f) > + remove_files=true > + ;; > + --) > + break > + ;; > + -*) > + usage > + ;; > + *) > + break > + ;; > + esac > + shift > +done [...] 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. -- Shawn. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:32 ` Shawn Pearce @ 2006-02-21 22:36 ` Krzysiek Pawlik 0 siblings, 0 replies; 15+ messages in thread From: Krzysiek Pawlik @ 2006-02-21 22:36 UTC (permalink / raw) To: Shawn Pearce; +Cc: cworth, git [-- Attachment #1.1: Type: text/plain, Size: 326 bytes --] 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 [-- Attachment #1.2: git-rm.patch --] [-- Type: text/plain, Size: 4287 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: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 #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 191 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:07 ` Krzysiek Pawlik 2006-02-21 22:14 ` Shawn Pearce @ 2006-02-21 22:49 ` Carl Worth 2006-02-21 23:04 ` Carl Worth 1 sibling, 1 reply; 15+ messages in thread From: Carl Worth @ 2006-02-21 22:49 UTC (permalink / raw) To: Krzysiek Pawlik; +Cc: Junio C Hamano, git [-- Attachment #1: Type: text/plain, Size: 487 bytes --] On Tue, 21 Feb 2006 23:07:45 +0100, Krzysiek Pawlik wrote: > > I've modified it a little - it has now a '-f' option to delete files > (much like cvs rm behaviour). As is, without -f, git-rm will instead act just like git-update-index. If the -f option is desired we could get the correct behavior by using update-index --force-remove when not given -f and update-index --remove when given -f. That's enough complexity to warrant a test case. I'll be back shortly with that... -Carl [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 22:49 ` Carl Worth @ 2006-02-21 23:04 ` Carl Worth 2006-02-22 8:19 ` Junio C Hamano 0 siblings, 1 reply; 15+ messages in thread From: Carl Worth @ 2006-02-21 23:04 UTC (permalink / raw) To: Krzysiek Pawlik; +Cc: Junio C Hamano, git [-- Attachment #1: Type: text/plain, Size: 7068 bytes --] This adds a git-rm command which provides convenience similar to git-add, (and a bit more since it takes care of the rm as well if given -f). Like git-add, git-rm expands the given path names through git-ls-files. This means it only acts on files listed in the index. And it does act recursively on directories by default, (no -r needed as in the case of rm itself). When it recurses, it does not remove empty directories that are left behind. --- On Tue, 21 Feb 2006 14:49:22 -0800, Carl Worth wrote: > If the -f option is desired we could get the correct behavior by using > update-index --force-remove when not given -f and update-index > --remove when given -f. One good argument for having the -f behavior is that this way "git rm file" makes a good complement for "git add file". I know that someone (recently?) asked on the list for an "unadd" operation. This would definitely be a lot more convenient than "git update-index --force-remove file". > That's enough complexity to warrant a test case. I'll be back shortly > with that... Here it is. This is a complete patch from master, rather than the incremental version that's in my tree. .gitignore | 1 Documentation/git-rm.txt | 89 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 2 - git-rm.sh | 67 +++++++++++++++++++++++++++++++++++ t/t3600-rm.sh | 42 ++++++++++++++++++++++ 5 files changed, 200 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d7e8d2a..94f66d5 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,7 @@ git-resolve git-rev-list git-rev-parse git-revert +git-rm git-send-email git-send-pack git-sh-setup diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt new file mode 100644 index 0000000..401bfb2 --- /dev/null +++ b/Documentation/git-rm.txt @@ -0,0 +1,89 @@ +git-rm(1) +========= + +NAME +---- +git-rm - Remove files from the working tree and from the index. + +SYNOPSIS +-------- +'git-rm' [-f] [-n] [-v] [--] <file>... + +DESCRIPTION +----------- +A convenience wrapper for git-update-index --remove. For those coming +from cvs, git-rm provides an operation similar to "cvs rm" or "cvs +remove". + + +OPTIONS +------- +<file>...:: + Files to remove from the index and optionally, from the + working tree as well. + +-f:: + Remove files from the working tree as well as from the index. + +-n:: + Don't actually remove the file(s), just show if they exist in + the index. + +-v:: + Be verbose. + +--:: + This option can be used to separate command-line options from + the list of files, (useful when filenames might be mistaken + for command-line options). + + +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 never removed from the working tree); + +. 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 from the index that are under the + `Documentation` directory and any of its subdirectories. The + files are not removed from the working tree. ++ +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 -f git-*.sh:: + + Remove all git-*.sh scripts that are in the index. The files + are removed from the index, and (because of the -f option), + from the working tree as well. 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 --git a/Makefile b/Makefile index 317be3c..e98b056 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ SCRIPT_SH = \ 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 --git a/git-rm.sh b/git-rm.sh new file mode 100644 index 0000000..0a3f546 --- /dev/null +++ b/git-rm.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +USAGE='[-f] [-n] [-v] [--] <file>...' +SUBDIRECTORY_OK='Yes' +. git-sh-setup + +index_remove_option=--force-remove +remove_files= +show_only= +verbose= +while : ; do + case "$1" in + -f) + remove_files=true + index_remote_option=--force + ;; + -n) + show_only=true + ;; + -v) + verbose=--verbose + ;; + --) + 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 -- $files + git-update-index $index_remove_option $verbose $files + ;; +esac diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh new file mode 100755 index 0000000..8415732 --- /dev/null +++ b/t/t3600-rm.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright (c) 2006 Carl D. Worth +# + +test_description='Test of the various options to git-rm.' + +. ./test-lib.sh + +# Setup some files to be removed +touch foo bar +git-add foo bar +# Need one to test -- +touch -- -q +git update-index --add -- -q +git-commit -m "add foo, bar, and -q" + +test_expect_success \ + 'Pre-check that foo is in index before git-rm foo' \ + 'git-ls-files --error-unmatch foo' + +test_expect_success \ + 'Test that git-rm foo succeeds' \ + 'git-rm foo' + +test_expect_failure \ + 'Post-check that foo is not in index after git-rm foo' \ + 'git-ls-files --error-unmatch foo' + +test_expect_success \ + 'Test that "git-rm -f bar" works' \ + 'git-rm -f bar' + +test_expect_failure \ + 'Post-check that bar no longer exists' \ + '[ -f bar ]' + +test_expect_success \ + 'Test that "git-rm -- -q" works to delete a file named -q' \ + 'git-rm -- -q' + +test_done [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 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 0 siblings, 1 reply; 15+ messages in thread From: Junio C Hamano @ 2006-02-22 8:19 UTC (permalink / raw) To: Carl Worth, Krzysiek Pawlik; +Cc: git Carl Worth <cworth@cworth.org> writes: > +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 > +) Note you are not using -z, which means we will c-quote the funny characters in the output... > +case "$show_only" in > +true) > + echo $files > + ;; And here $files lack surrounding double quote. For human consumption it might be OK, but I somehow care about a bit of details like this. > +*) > + [[ "$remove_files" = "true" ]] && rm -- $files Same here. What happens to filenames with IFS letters in them? "git-add" does not use -z and xargs -0 without a good reason. > + git-update-index $index_remove_option $verbose $files > + ;; > +esac Even if rm -- $files were quoted correctly, and tried to remove the right files, if some of the files failed to disappear for whatever reason, what happens? ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc. 2006-02-22 8:19 ` Junio C Hamano @ 2006-02-23 0:08 ` Carl Worth 2006-02-23 0:37 ` Carl Worth 2006-02-24 13:23 ` Alex Riesen 0 siblings, 2 replies; 15+ messages in thread From: Carl Worth @ 2006-02-23 0:08 UTC (permalink / raw) To: Junio C Hamano; +Cc: Krzysiek Pawlik, git [-- Attachment #1: Type: text/plain, Size: 5729 bytes --] New tests are added to the git-rm test case to cover this as well. Signed-off-by: Carl Worth <cworth@cworth.org> --- On Wed, 22 Feb 2006 00:19:46 -0800, Junio C Hamano wrote: > > Note you are not using -z, which means we will c-quote the funny > characters in the output... Oh, I didn't expect C-language-style quoting. That's definitely not going to work. > > +*) > > + [[ "$remove_files" = "true" ]] && rm -- $files > > Same here. What happens to filenames with IFS letters in them? > "git-add" does not use -z and xargs -0 without a good reason. Yeah, this is just me unleashing my shell-programming incompetence on the world. The attached patch addresses that problem with a rather blunt hammer. Let me know if anyone has a more elegant approach than what I did here. One thing I've lost is that the previous version had a sort|uniq on the output of git-ls-files which is useful in the case of failed merges and other ways in which git-ls-files reports the same file multiple times. What might be nice is a --unique flag to git-ls-files that git-rm could use, (but on first glance it doesn't look trivial to implement as git-ls-files doesn't ever store or sort its entire list). > Even if rm -- $files were quoted correctly, and tried to remove > the right files, if some of the files failed to disappear for > whatever reason, what happens? My intent with the previous patch was that, when git-rm is given -f, and the rm fails to remove a file, that the file is then not removed from the index. Of course, this was hopelessly broken due to two major typos in the same line: index_remote_option=--force instead of: index_remove_option=--remove which my tests were insufficient to catch. This behavior should now work in the current patch as well as the proper handling of files with funny characters, (tests are included for both). The desired behavior when rm fails is debatable, so I'm open to opinions. One reason I liked this was that in the previous patch, rm would prompt the user before deleting a read-only file, and if the user said no, then git-rm would also not remove it from the index. This did cause another minor problem in that there would then be no way to get git-rm to use "rm -f" when desired. In the current patch, with my blunt hammer, there's another sub-shell before the rm which apparently steals its tty and causes it to not prompt at all. So that aspect may be moot. -Carl PS. What's the syntax/tool support for just replying to an existing message, and at the end inserting a patch with its own subject and commit message? Here I've manually whacked the subject and put the commit message above my reply (in the style of git-format-patch) but that seem seems inelegant. git-rm.sh | 37 ++++++++++++++++++++----------------- t/t3600-rm.sh | 30 ++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 25 deletions(-) 3d52c6d60047390d434f8737368adea77fa26310 diff --git a/git-rm.sh b/git-rm.sh index 0a3f546..fa361bd 100755 --- a/git-rm.sh +++ b/git-rm.sh @@ -4,7 +4,6 @@ USAGE='[-f] [-n] [-v] [--] <file>...' SUBDIRECTORY_OK='Yes' . git-sh-setup -index_remove_option=--force-remove remove_files= show_only= verbose= @@ -12,7 +11,6 @@ while : ; do case "$1" in -f) remove_files=true - index_remote_option=--force ;; -n) show_only=true @@ -45,23 +43,28 @@ case "$#" in ;; 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 \ +if test -f "$GIT_DIR/info/exclude" +then + git-ls-files -z \ + --exclude-from="$GIT_DIR/info/exclude" \ --exclude-per-directory=.gitignore -- "$@" - fi | sort | uniq -) - -case "$show_only" in -true) - echo $files +else + git-ls-files -z \ + --exclude-per-directory=.gitignore -- "$@" +fi | +case "$show_only,remove_files" in +true,*) + xargs -0 echo + ;; +*,true) + xargs -0 sh -c " + while [ \$# -gt 0 ]; do + file=\$1; shift + rm -- \"\$file\" && git-update-index --remove $verbose \"\$file\" + done + " inline ;; *) - [[ "$remove_files" = "true" ]] && rm -- $files - git-update-index $index_remove_option $verbose $files + git-update-index --force-remove $verbose -z --stdin ;; esac diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 8415732..b87beb0 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -7,13 +7,12 @@ test_description='Test of the various op . ./test-lib.sh -# Setup some files to be removed -touch foo bar -git-add foo bar -# Need one to test -- -touch -- -q -git update-index --add -- -q -git-commit -m "add foo, bar, and -q" +# Setup some files to be removed, some with funny characters +touch -- foo bar baz 'space embedded' 'tab embedded' 'newline +embedded' -q +git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline +embedded' -q +git-commit -m "add files" test_expect_success \ 'Pre-check that foo is in index before git-rm foo' \ @@ -36,7 +35,22 @@ test_expect_failure \ '[ -f bar ]' test_expect_success \ - 'Test that "git-rm -- -q" works to delete a file named -q' \ + 'Test that "git-rm -- -q" works to delete a file that looks like an option' \ 'git-rm -- -q' +test_expect_success \ + "Test that \"git-rm -f\" can remove files with embedded space, tab, or newline characters." \ + "git-rm 'space embedded' 'tab embedded' 'newline +embedded" + +chmod u-w . +test_expect_failure \ + 'Test that "git-rm -f" fails if its rm fails' \ + 'git-rm -f baz' +chmod u+w . + +test_expect_success \ + 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \ + 'git-ls-files --error-unmatch baz' + test_done -- 1.2.2.g01a2-dirty [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc. 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 1 sibling, 1 reply; 15+ messages in thread From: Carl Worth @ 2006-02-23 0:37 UTC (permalink / raw) To: Junio C Hamano; +Cc: Krzysiek Pawlik, git [-- Attachment #1: Type: text/plain, Size: 4575 bytes --] New tests are added to the git-rm test case to cover this as well. Signed-off-by: Carl Worth <cworth@cworth.org> --- Please ignore the previous patch. This is what I intended to send. (For as useful as the index is---and yes, I have found it very useful---I still find it easy to inadvertently commit stale data with it. I guess what might help me is a command to update into the index all files that are currently in the "updated but not checked in (will commit)" state as reported by git status. Does such a command exist?) -Carl git-rm.sh | 37 ++++++++++++++++++++----------------- t/t3600-rm.sh | 52 +++++++++++++++++++++++++++++++++++----------------- 2 files changed, 55 insertions(+), 34 deletions(-) 3bd80bae8dc2b004a3109018f0efb0007804b79d diff --git a/git-rm.sh b/git-rm.sh index 0a3f546..fda4541 100755 --- a/git-rm.sh +++ b/git-rm.sh @@ -4,7 +4,6 @@ USAGE='[-f] [-n] [-v] [--] <file>...' SUBDIRECTORY_OK='Yes' . git-sh-setup -index_remove_option=--force-remove remove_files= show_only= verbose= @@ -12,7 +11,6 @@ while : ; do case "$1" in -f) remove_files=true - index_remote_option=--force ;; -n) show_only=true @@ -45,23 +43,28 @@ case "$#" in ;; 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 \ +if test -f "$GIT_DIR/info/exclude" +then + git-ls-files -z \ + --exclude-from="$GIT_DIR/info/exclude" \ --exclude-per-directory=.gitignore -- "$@" - fi | sort | uniq -) - -case "$show_only" in -true) - echo $files +else + git-ls-files -z \ + --exclude-per-directory=.gitignore -- "$@" +fi | +case "$show_only,$remove_files" in +true,*) + xargs -0 echo + ;; +*,true) + xargs -0 sh -c " + while [ \$# -gt 0 ]; do + file=\$1; shift + rm -- \"\$file\" && git-update-index --remove $verbose \"\$file\" + done + " inline ;; *) - [[ "$remove_files" = "true" ]] && rm -- $files - git-update-index $index_remove_option $verbose $files + git-update-index --force-remove $verbose -z --stdin ;; esac diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 8415732..cabfadd 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -7,36 +7,54 @@ test_description='Test of the various op . ./test-lib.sh -# Setup some files to be removed -touch foo bar -git-add foo bar -# Need one to test -- -touch -- -q -git update-index --add -- -q -git-commit -m "add foo, bar, and -q" +# Setup some files to be removed, some with funny characters +touch -- foo bar baz 'space embedded' 'tab embedded' 'newline +embedded' -q +git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline +embedded' -q +git-commit -m "add files" test_expect_success \ - 'Pre-check that foo is in index before git-rm foo' \ - 'git-ls-files --error-unmatch foo' + 'Pre-check that foo exists and is in index before git-rm foo' \ + '[ -f foo ] && git-ls-files --error-unmatch foo' test_expect_success \ 'Test that git-rm foo succeeds' \ 'git-rm foo' -test_expect_failure \ - 'Post-check that foo is not in index after git-rm foo' \ - 'git-ls-files --error-unmatch foo' +test_expect_success \ + 'Post-check that foo exists but is not in index after git-rm foo' \ + '[ -f foo ] && ! git-ls-files --error-unmatch foo' + +test_expect_success \ + 'Pre-check that bar exists and is in index before "git-rm -f bar"' \ + '[ -f bar ] && git-ls-files --error-unmatch bar' test_expect_success \ - 'Test that "git-rm -f bar" works' \ + 'Test that "git-rm -f bar" succeeds' \ 'git-rm -f bar' -test_expect_failure \ - 'Post-check that bar no longer exists' \ - '[ -f bar ]' +test_expect_success \ + 'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \ + '! [ -f bar ] && ! git-ls-files --error-unmatch bar' test_expect_success \ - 'Test that "git-rm -- -q" works to delete a file named -q' \ + 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \ 'git-rm -- -q' +test_expect_success \ + "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \ + "git-rm -f 'space embedded' 'tab embedded' 'newline +embedded'" + +chmod u-w . +test_expect_failure \ + 'Test that "git-rm -f" fails if its rm fails' \ + 'git-rm -f baz' +chmod u+w . + +test_expect_success \ + 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \ + 'git-ls-files --error-unmatch baz' + test_done -- 1.2.2.g3d52-dirty [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc. 2006-02-23 0:37 ` Carl Worth @ 2006-02-23 1:07 ` Junio C Hamano 0 siblings, 0 replies; 15+ messages in thread From: Junio C Hamano @ 2006-02-23 1:07 UTC (permalink / raw) To: Carl Worth; +Cc: git Carl Worth <cworth@cworth.org> writes: > Please ignore the previous patch. This is what I intended to send. Ahh. I was wondering... > (For as useful as the index is---and yes, I have found it very > useful---I still find it easy to inadvertently commit stale data with > it. I guess what might help me is a command to update into the index > all files that are currently in the "updated but not checked in (will > commit)" state as reported by git status. Does such a command exist?) No. I do not do this myself, but this one-liner should work: git diff --name-only "$@" | git update-index --stdin [from another message] > PS. What's the syntax/tool support for just replying to an existing > message, and at the end inserting a patch with its own subject and > commit message? Here I've manually whacked the subject and put the > commit message above my reply (in the style of git-format-patch) but > that seems inelegant. YMMV depending on the MUA you use, of course. I start [REPLY], have my MUA quote the original and write response while trimming excess quote, just as usual. When I need to add a patch, then I remove all that with \C-w (kill-region), read a format-patch output into the same mail buffer, and then \C-y (yank) to paste the "usual correspondence" part below the three-dash lines. Yes, it's all manual. I presume it would be easy to write a few-liner Emacs macro to do this though... ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc. 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-24 13:23 ` Alex Riesen 2006-02-25 6:05 ` Junio C Hamano 1 sibling, 1 reply; 15+ messages in thread From: Alex Riesen @ 2006-02-24 13:23 UTC (permalink / raw) To: Carl Worth; +Cc: Junio C Hamano, Krzysiek Pawlik, git On 2/23/06, Carl Worth <cworth@cworth.org> wrote: > +# Setup some files to be removed, some with funny characters > +touch -- foo bar baz 'space embedded' 'tab embedded' 'newline > +embedded' -q > +git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline > +embedded' -q > +git-commit -m "add files" This doesn't work on some exotic filesystems (ntfs and fat): *** t3600-rm.sh *** touch: cannot touch `tab\tembedded': No such file or directory touch: cannot touch `newline\nembedded': No such file or directory error: pathspec 'tab embedded' did not match any. error: pathspec 'newline embedded' did not match any. Maybe you misspelled it? Nothing to commit * FAIL 1: Pre-check that foo exists and is in index before git-rm foo [ -f foo ] && git-ls-files --error-unmatch foo * FAIL 2: Test that git-rm foo succeeds git-rm foo * FAIL 4: Pre-check that bar exists and is in index before "git-rm -f bar" [ -f bar ] && git-ls-files --error-unmatch bar * FAIL 5: Test that "git-rm -f bar" succeeds git-rm -f bar * FAIL 6: Post-check that bar does not exist and is not in index after "git-rm -f bar" ! [ -f bar ] && ! git-ls-files --error-unmatch bar * FAIL 7: Test that "git-rm -- -q" succeeds (remove a file that looks like an option) git-rm -- -q * FAIL 8: Test that "git-rm -f" succeeds with embedded space, tab, or newline characters. git-rm -f 'space embedded' 'tab embedded' 'newline embedded' * FAIL 10: When the rm in "git-rm -f" fails, it should not remove the file from the index git-ls-files --error-unmatch baz * failed 8 among 10 test(s) ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] git-rm: Fix to properly handle files with spaces, tabs, newlines, etc. 2006-02-24 13:23 ` Alex Riesen @ 2006-02-25 6:05 ` Junio C Hamano 0 siblings, 0 replies; 15+ messages in thread From: Junio C Hamano @ 2006-02-25 6:05 UTC (permalink / raw) To: Alex Riesen; +Cc: git, Carl Worth, Krzysiek Pawlik "Alex Riesen" <raa.lkml@gmail.com> writes: > On 2/23/06, Carl Worth <cworth@cworth.org> wrote: >> +# Setup some files to be removed, some with funny characters >> +touch -- foo bar baz 'space embedded' 'tab embedded' 'newline >> +embedded' -q >> +git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline >> +embedded' -q >> +git-commit -m "add files" > > This doesn't work on some exotic filesystems (ntfs and fat): Sorry to have applied this without thinking. Yes, we had disabled a test that uses tab for this exact reason, but I have forgotten about it. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Add new git-rm command with documentation 2006-02-21 21:47 [PATCH] Add new git-rm command with documentation Carl Worth 2006-02-21 22:07 ` Krzysiek Pawlik @ 2006-02-21 22:15 ` Johannes Schindelin 1 sibling, 0 replies; 15+ messages in thread From: Johannes Schindelin @ 2006-02-21 22:15 UTC (permalink / raw) To: Carl Worth; +Cc: Junio C Hamano, git Hi, On Tue, 21 Feb 2006, Carl Worth wrote: > PS. I didn't change the Linus and Junio attribution since all of the > code and documentation here is just minor changes from git-add. If that is so, why not reuse the same binary (a la git-whatchanged and git-show)? Ciao, Dscho ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2006-02-25 6:05 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-02-21 21:47 [PATCH] Add new git-rm command with documentation Carl Worth 2006-02-21 22:07 ` Krzysiek Pawlik 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
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).