diff options
author | Joey Hess <joey@kitenet.net> | 2011-01-13 14:11:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-01-13 14:27:19 -0400 |
commit | bbc4dc023152fea97c1fa7d338417d1b3f9a1607 (patch) | |
tree | db961becb8b17801418f0e9e650f2a628209495f /commit.d/40git-rm | |
parent | 27ca6c9eb668c9ab55cf65f8e620893589536c84 (diff) |
Rewrote 50git-rm
This avoids using git ls-files, and thus avoids encoding problems with
filenames.
Using git add . -u stages all deleted files for deletion.
It also avoids the problem with git rm deleting empty directories.
It might be better to just use git commit -a, but I've taken the
conservative approach.
There are a few other git ls-files uses in etckeeper that I have not fixed,
but they are only shown to the user, and shouldn't cause a crash as this did.
Unfortunatly, git does expose the nasty C-style encoding of such characters
in filenames to the user all over (eg, git commit, git log ..), so fixing
etckeeper to not also expose them is probably a waste of time. And
core.quotepath can be unset by users who want to clean that up.
Bug report: https://bugzilla.altlinux.org/show_bug.cgi?id=24903
Diffstat (limited to 'commit.d/40git-rm')
-rwxr-xr-x | commit.d/40git-rm | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/commit.d/40git-rm b/commit.d/40git-rm index 26f492a..ae70e1f 100755 --- a/commit.d/40git-rm +++ b/commit.d/40git-rm @@ -1,27 +1,8 @@ #!/bin/sh set -e -IFS=' -' - if [ "$VCS" = git ] && [ -d .git ]; then - for file in $(git ls-files --deleted); do - if [ ! -d "$file" ]; then - # git removes directories when the last file - # in them is removed, but empty directories - # may be significant in /etc. Touch a flag file - # to prevent git from removing the directory. - dir="$(dirname "$file")" - flagfile="" - if [ -d "$dir" ] && - [ -n "$(find "$dir" -maxdepth 0 -empty)" ]; then - flagfile="$dir/.etckeeper-keep-empty" - touch "$flagfile" - fi - git rm --quiet "$file" - if [ -n "$flagfile" ]; then - rm -f "$flagfile" - fi - fi - done + if ! git add . -u; then + echo "etckeeper warning: git add -u failed" >&2 + fi fi |