在 Git 中跟踪文件权限。错误 运行 git-缓存元数据:"find: you have too many ')'"
Tracking file permissions in Git. Error running git-cache-meta: "find: you have too many ')'"
我目前正在尝试实施 this recommendation 以便能够在执行 Git 克隆时保留文件权限。但是,当我 运行 命令时,我收到此错误。
$ git-cache-meta.sh --store
find: you have too many ')'
之前的一个错误是关于 Git 列出了太多文件(我有大约 2.5GB 的文件正在跟踪,据我所知这正在推动单个 Git项目已经)。
shell脚本的初始化是不是我哪里做错了(我使用的主要代码是here:
1. #!/bin/sh -e
2.
3. #git-cache-meta -- simple file meta data caching and applying.
4. #Simpler than etckeeper, metastore, setgitperms, etc.
5. #from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
6. #modified by n1k
7. # - save all files metadata not only from other users
8. # - save numeric uid and gid
9.
10. # 2012-03-05 - added filetime, andris9
11.
12. : ${GIT_CACHE_META_FILE=.git_cache_meta}
13. case $@ in
14. --store|--stdout)
15. case in --store) exec > $GIT_CACHE_META_FILE; esac
16. find $(git ls-files)\
17. \( -printf 'chown %U %p\n' \) \
18. \( -printf 'chgrp %G %p\n' \) \
19. \( -printf 'touch -c -d "%AY-%Am-%Ad %AH:%AM:%AS" %p\n' \) \
20. \( -printf 'chmod %#m %p\n' \) ;;
21. --apply) sh -e $GIT_CACHE_META_FILE;;
22. *) 1>&2 echo "Usage: [=15=] --store|--stdout|--apply"; exit 1;;
23. esac
但我没有使用任何修订版,它们似乎解决了不同的问题)。该页面上报告的几个错误似乎与文件名中的特定字符有关,但仔细查看,我找不到任何可能引发错误的“(”或“)”。
如果它与尝试跟踪太多文件有关,那么在 Git 中部署它时是否有任何关于维护文件权限和所有者元数据的建议?
试试这个:
function get_metadata {
git ls-files |
xargs stat -c $'%a\t%U\t%G\t%x\t%n' |
while IFS=$'\t' read -r perm user grp date name; do
echo chown "$user" "$name"
echo chgrp "$grp" "$name"
echo chmod "$perm" "$name"
echo touch -c -d "'$date'" "$name"
done
}
case in
--stdout) get_metadata ;;
--store) get_metadata > "$GIT_CACHE_META_FILE" ;;
--apply)
[[ -f "$GIT_CACHE_META_FILE" ]] &&
sh "$GIT_CACHE_META_FILE"
;;
*) echo "usage: ..." ;;
esac
这假设 none 个文件名包含换行符。
我目前正在尝试实施 this recommendation 以便能够在执行 Git 克隆时保留文件权限。但是,当我 运行 命令时,我收到此错误。
$ git-cache-meta.sh --store
find: you have too many ')'
之前的一个错误是关于 Git 列出了太多文件(我有大约 2.5GB 的文件正在跟踪,据我所知这正在推动单个 Git项目已经)。
shell脚本的初始化是不是我哪里做错了(我使用的主要代码是here:
1. #!/bin/sh -e
2.
3. #git-cache-meta -- simple file meta data caching and applying.
4. #Simpler than etckeeper, metastore, setgitperms, etc.
5. #from http://www.kerneltrap.org/mailarchive/git/2009/1/9/4654694
6. #modified by n1k
7. # - save all files metadata not only from other users
8. # - save numeric uid and gid
9.
10. # 2012-03-05 - added filetime, andris9
11.
12. : ${GIT_CACHE_META_FILE=.git_cache_meta}
13. case $@ in
14. --store|--stdout)
15. case in --store) exec > $GIT_CACHE_META_FILE; esac
16. find $(git ls-files)\
17. \( -printf 'chown %U %p\n' \) \
18. \( -printf 'chgrp %G %p\n' \) \
19. \( -printf 'touch -c -d "%AY-%Am-%Ad %AH:%AM:%AS" %p\n' \) \
20. \( -printf 'chmod %#m %p\n' \) ;;
21. --apply) sh -e $GIT_CACHE_META_FILE;;
22. *) 1>&2 echo "Usage: [=15=] --store|--stdout|--apply"; exit 1;;
23. esac
但我没有使用任何修订版,它们似乎解决了不同的问题)。该页面上报告的几个错误似乎与文件名中的特定字符有关,但仔细查看,我找不到任何可能引发错误的“(”或“)”。
如果它与尝试跟踪太多文件有关,那么在 Git 中部署它时是否有任何关于维护文件权限和所有者元数据的建议?
试试这个:
function get_metadata {
git ls-files |
xargs stat -c $'%a\t%U\t%G\t%x\t%n' |
while IFS=$'\t' read -r perm user grp date name; do
echo chown "$user" "$name"
echo chgrp "$grp" "$name"
echo chmod "$perm" "$name"
echo touch -c -d "'$date'" "$name"
done
}
case in
--stdout) get_metadata ;;
--store) get_metadata > "$GIT_CACHE_META_FILE" ;;
--apply)
[[ -f "$GIT_CACHE_META_FILE" ]] &&
sh "$GIT_CACHE_META_FILE"
;;
*) echo "usage: ..." ;;
esac
这假设 none 个文件名包含换行符。