git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Junio C Hamano <junkio@cox.net>
Cc: "David Kågedal" <davidk@lysator.liu.se>, git@vger.kernel.org
Subject: Re: Removing files
Date: Thu, 11 Jan 2007 15:19:55 -0800	[thread overview]
Message-ID: <20070111231955.GB13564@localdomain> (raw)
In-Reply-To: <7vejq12nlu.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> wrote:
> David Kågedal <davidk@lysator.liu.se> writes:
> 
> > I'm wondering what the best way to commit the removal of a file is.
> 
>  $ rm -f foo
>  $ git-commit -a
> 
> > git status shows:
> >
> >   $ git status
> >   # On branch refs/heads/messages
> >   # Changed but not added:
> >   #   (use "git add <file>..." to incrementally add content to commit)
> >   #
> >   #       deleted:    foo
> 
> Suggesting "git add" to record the deletion feels insane.  Is
> this what we still do?  I think there have been much work 
> in this area recently so the wordings might have already fixed.
> 
> > Ok, so that didn't work.  Let's try rm instead:
> >
> >   $ git rm foo
> >   fatal: pathspec 'foo' did not match any files
> >
> 
> The above message is from an older version of git-rm, but the
> one that will be in v1.5.0 is not any better.  It errs out with
> "No such file or directory".  A workaround using today's tool is
> to do "git rm --cached fo"
> 
> I think the right fix is to suggest "git add/rm" in status
> output and make "git rm" not barf if the user has already
> removed the file from the working tree.

Would having a command like 'hg addremove' make things easier?  I've
been using the below script since my early days of using git, but I
don't think I've ever published it.  If you want I can create a
patch against git.git

-----------------------------------------------------------------------
#!/bin/sh
# like the addremove command in mercurial

if test "x$1" = "x-h"
then
	echo "Usage: git-addrm [<path>]"
	exit 0
fi
SUBDIRECTORY_OK=1
. git-sh-setup || die "Not a git archive"

EXCLUDE_ARGS=--exclude-per-directory=.gitignore

if test -f "$GIT_DIR/info/exclude"
then
	EXCLUDE_ARGS="$EXCLUDE_ARGS --exclude-from=$GIT_DIR/info/exclude"
fi

set -e
git-ls-files -z --deleted $EXCLUDE_ARGS "$@"| \
	git-update-index --remove -z --stdin
git-ls-files -z --others $EXCLUDE_ARGS "$@" | \
	git-update-index --add -z --stdin
-----------------------------------------------------------------------

-- 
Eric Wong

  reply	other threads:[~2007-01-11 23:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-11 20:10 Removing files David Kågedal
2007-01-11 21:36 ` Alex Riesen
2007-01-11 22:25   ` Seth Falcon
2007-01-11 22:41 ` Junio C Hamano
2007-01-11 23:19   ` Eric Wong [this message]
2007-01-11 23:36   ` Junio C Hamano
2007-01-11 23:37   ` [PATCH] git-status: wording update to deal with deleted files Junio C Hamano
2007-01-11 23:56     ` Carl Worth
2007-01-12  0:13       ` Junio C Hamano
2007-01-12  1:28         ` Carl Worth
2007-01-12 19:48           ` Jakub Narebski
2007-01-12  0:07     ` Jeff King
2007-01-12 22:13     ` Juergen Ruehle
2007-01-11 23:41 ` Removing files Carl Worth
2007-01-12  0:17   ` Jeff King

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=20070111231955.GB13564@localdomain \
    --to=normalperson@yhbt.net \
    --cc=davidk@lysator.liu.se \
    --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).