git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carl Baldwin <cnb@fc.hp.com>
To: Junio C Hamano <junkio@cox.net>
Cc: Carl Baldwin <cnb@fc.hp.com>,
	git@vger.kernel.org, Daniel Barkalow <barkalow@iabervon.org>
Subject: Re: [RFC] Removing deleted files after checkout
Date: Tue, 23 Aug 2005 16:21:51 -0600	[thread overview]
Message-ID: <20050823222151.GA15321@hpsvcnb.fc.hp.com> (raw)
In-Reply-To: <7vvf1wnwtl.fsf@assigned-by-dhcp.cox.net>

Ok, the following is what I came up with based on your response.  This
is .git/hooks/update.  It mostly works in my situation.  See below for
my discussion on what didn't work.

#!/bin/sh

export PATH=/usr/local/bin:/usr/bin:/bin

# cd to the root of the project directory (assume one dir up from GIT_DIR)
cd $GIT_DIR/..
unset GIT_DIR

if expr "$2" : '0*$' >/dev/null; then
    git-read-tree --reset $3 &&
        git-checkout-cache -q -f -u -a
else
    git-read-tree -m -u $2 $3
fi

exit 0

# --- snip ---

The thing that this doesn't do is remove empty directories when the last
file is deleted.  I once expressed the opinion in a previous thread that
directories should be added and removed explicitly in git.  (Thus
allowing an empty directory to be added).  If this were to happen then
this case would get handled correctly.  However, if git stays with the
status quo then I think that git-read-tree -u should be changed to
remove the empty directory.  This would make it consistent.

What do you think?  Ideas?

Carl

On Tue, Aug 23, 2005 at 02:54:30PM -0700, Junio C Hamano wrote:
> Daniel Barkalow <barkalow@iabervon.org> writes:
> 
> >> > If you don't use -f, git-checkout-script removes deleted files. Using -f
> >> > tells it to ignore the old index, which means that it can't tell the
> >> > difference between removed files and files that weren't tracked at all.
> 
> Yes and no.  "git checkout" assumes that the index file and the
> working tree somewhat resembles what is in .git/HEAD commit.
> Since push operation updates .git/HEAD commit without touching
> the index file, that assumption does not hold.
> 
> The update hook gets old commit name and new commit name, so you
> should be able to do (untested):
> 
>     git-read-tree -m -u $old_commit $new_commit
> 
> there, of course after making sure that you had old_commit (the
> first time push happens to a new ref you would not have that one).
> 

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Carl Baldwin                        Systems VLSI Laboratory
 Hewlett Packard Company
 MS 88                               work: 970 898-1523
 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com
 Fort Collins, CO 80525              home: Carl@ecBaldwin.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  reply	other threads:[~2005-08-23 22:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-23 16:21 [RFC] Removing deleted files after checkout Carl Baldwin
2005-08-23 19:43 ` Daniel Barkalow
2005-08-23 20:50   ` Carl Baldwin
2005-08-23 21:27     ` Daniel Barkalow
2005-08-23 21:40       ` Carl Baldwin
2005-08-23 22:12         ` Daniel Barkalow
2005-08-23 21:54       ` Junio C Hamano
2005-08-23 22:21         ` Carl Baldwin [this message]
2005-08-23 22:34           ` Daniel Barkalow
2005-08-24  0:02             ` Junio C Hamano

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=20050823222151.GA15321@hpsvcnb.fc.hp.com \
    --to=cnb@fc.hp.com \
    --cc=barkalow@iabervon.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).