[英]Tracking file permissions in Git. Error running git-cache-meta: “find: you have too many ')'”
我目前正在嘗試實施此建議 ,以便在執行Git克隆時能夠保留文件權限。 但是,當我運行命令時,我收到此錯誤。
$ git-cache-meta.sh --store
find: you have too many ')'
先前的錯誤是關於Git列出的文件過多(我跟蹤的文件大約有2.5GB,據我了解,這已經使單個Git項目的極限受到了限制)。
我對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
但我沒有使用任何修訂版,這些修訂版似乎正在解決單獨的問題)。 該頁面上報告的一些錯誤似乎與文件名中的特定字符有關,但從頭到尾,我找不到任何可能引起錯誤的'('或')'。
但是,如果與嘗試跟蹤太多文件有關,那么是否有任何建議在將文件部署到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 $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
假設您的文件名都不包含換行符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.