[英]Tracking file permissions in Git. Error running git-cache-meta: “find: you have too many ')'”
I'm currently trying to implement this recommendation to be able preserve file permissions while doing Git clones. 我目前正在尝试实施此建议 ,以便在执行Git克隆时能够保留文件权限。 However, when I run the command, I receive this error. 但是,当我运行命令时,我收到此错误。
$ git-cache-meta.sh --store
find: you have too many ')'
A previous error was in regards to having too many files being listed by Git (I have around 2.5GB worth of files which I am tracking which I understand is pushing the limits of a single Git project already). 先前的错误是关于Git列出的文件过多(我跟踪的文件大约有2.5GB,据我了解,这已经使单个Git项目的极限受到了限制)。
Is there something I had done wrong of the initialization of the shell script (I used the main code listed here : 我对shell脚本的初始化做错了什么吗(我使用了此处列出的主要代码:
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 $1 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: $0 --store|--stdout|--apply"; exit 1;;
23. esac
but I did not use any of the revisions, which seemed to be addressing separate problems). 但我没有使用任何修订版,这些修订版似乎正在解决单独的问题)。 Several of the reported errors on that page seemed to be in regards to specific characters in a file name, but looking through, I can't find any '(' or ')' that might raise the error I'm getting. 该页面上报告的一些错误似乎与文件名中的特定字符有关,但从头到尾,我找不到任何可能引起错误的'('或')'。
If it is related to trying to track too many files however, are there any recommendations as to maintain file permissions and owner meta-data while deploying it in Git? 但是,如果与尝试跟踪太多文件有关,那么是否有任何建议在将文件部署到Git时维护文件权限和所有者元数据?
Try this: 尝试这个:
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 $1 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
This assumes none of your filenames contain a newline. 假设您的文件名都不包含换行符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.