Hello, I recently started using git to revision control the source for my web-page. I wrote a post-update hook to checkout the files when I push to the 'live' repository. In this particular context I decided that it was important to me to remove deleted files after checking out the new HEAD. I accomplished this by running git-ls-files before and after the checkout. Is there a better way? Could there be some way built into git to easily find out what files dissappear when replacing the current index with one from a new tree? Is there already? The behavior of git should NOT change to delete these files but I would argue that some way should exist to query what files disappeared if removing them is desired. Here is some code that I wrote for this. It feels a bit hackish to me but I couldn't think of anything better. Comments and criticism are welcome. #!/bin/sh # HEAD changed so checkout the new HEAD deleted any files that should no longer # be around. oldlist=$(tempfile) newlist=$(tempfile) removedlist=$(tempfile) git-ls-files | sort -r > $oldlist git-checkout-script -f git-ls-files | sort -r > $newlist diff -u $oldlist $newlist | tail -n +4 | sed -n 's/^-//p' > $removedlist # Remove each file cat $removedlist | xargs -rl rm -f # Remove the directories if empty cat $removedlist | xargs -rl dirname | xargs -rl rmdir -p --ignore-fail-on-non-empty rm -f $oldlist $newlist $removedlist # --- snip --- If you are interested I attached the full post-update hook script that I actually use to do this. Again, comments are welcome. Thanks, Carl -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This archive was generated by hypermail 2.1.8 : 2005-08-24 02:22:40 EST