threads / discuss / 17059

git-cache-meta -- simple file meta data caching and applying

Subject: git-cache-meta -- simple file meta data caching and applying

## tl;dr

6 messages between Jan 9, 2009 and Jan 10, 2009.

replies: 5people: 3as markdown or json

jidanni@jidanni.org· Jan 9, 2009, 00:13 UTC · lore
Gentlemen, I have whipped up this:
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
: ${GIT_CACHE_META_FILE=.git_cache_meta}
case $@ in
    --store|--stdout)
	case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
	find $(git ls-files) \
	    \( -user ${USER?} -o -printf 'chowm %u %p\n' \) \
	    \( -group $USER -o -printf 'chgrp %g %p\n' \) \
	    \( \( -type l -o -perm 755 -o -perm 644 \) -o -printf 'chmod %#m %p\n' \);;
    --apply) sh -e $GIT_CACHE_META_FILE;;
    *) 1>&2 echo "Usage: $0 --store|--stdout|--apply"; exit 1;;
esac
Jay Soffian· Jan 9, 2009, 00:22 UTC · re: jidanni@jidanni.org · lore

Re: git-cache-meta -- simple file meta data caching and applying

On Thu, Jan 8, 2009 at 7:13 PM,  <jidanni@jidanni.org> wrote:
Show 16 quoted lines
> Gentlemen, I have whipped up this:
>
> #!/bin/sh -e
> #git-cache-meta -- simple file meta data caching and applying.
> #Simpler than etckeeper, metastore, setgitperms, etc.
> : ${GIT_CACHE_META_FILE=.git_cache_meta}
> case $@ in
>    --store|--stdout)
>        case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
>        find $(git ls-files) \
>            \( -user ${USER?} -o -printf 'chowm %u %p\n' \) \
>            \( -group $USER -o -printf 'chgrp %g %p\n' \) \
>            \( \( -type l -o -perm 755 -o -perm 644 \) -o -printf 'chmod %#m %p\n' \);;
>    --apply) sh -e $GIT_CACHE_META_FILE;;
>    *) 1>&2 echo "Usage: $0 --store|--stdout|--apply"; exit 1;;
> esac

It doesn't handle paths which contain white-space. "chown" is typo'd as "chowm". To be useful, the contribution might also include instructions on how it should be used with git, and perhaps also reasoning for why someone would want to use it in place of etckeeper, metastore, setgitperms, etc.

j.
Jay Soffian· Jan 9, 2009, 00:28 UTC · re: Jay Soffian · lore

Re: git-cache-meta -- simple file meta data caching and applying

On Thu, Jan 8, 2009 at 7:22 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
Show 5 quoted lines
> It doesn't handle paths which contain white-space. "chown" is typo'd
> as "chowm". To be useful, the contribution might also include
> instructions on how it should be used with git, and perhaps also
> reasoning for why someone would want to use it in place of etckeeper,
> metastore, setgitperms, etc.

It will also blow-up if the output of "git ls-files" exceeds limitations on number of arguments. Also, might be worth mentioning it requires GNU find.

j.
jidanni@jidanni.org· Jan 9, 2009, 02:50 UTC · re: Jay Soffian · lore

Re: git-cache-meta -- simple file meta data caching and applying

Fixed. Manly the program aims to be tiny. Perhaps I should include a full example of using it with git-bundle.

#!/bin/sh -e
#git-cache-meta -- file meta data caching for possible use with
#git-bundle, git-fast-export, git-archive, hooks, as a simple
#alternative to etckeeper, metastore, setgitperms. Requires GNU Find.
: ${GIT_CACHE_META_FILE=.git_cache_meta}
case $@ in
    --store|--stdout)
	case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
	git ls-files|xargs -I{} find {} \
	    \( -user ${USER?} -o -printf 'chown %u "%p"\n' \) \
	    \( -group $USER   -o -printf 'chgrp %g "%p"\n' \) \
	    \( \( -type l -o -perm 755 -o -perm 644 \) \
			      -o -printf 'chmod %#m "%p"\n' \);;
    --apply) sh -e $GIT_CACHE_META_FILE;;
    *) 1>&2 echo "Usage: $0 --store|--stdout|--apply"; exit 1;;
esac
Boyd Stephen Smith Jr.· Jan 9, 2009, 04:29 UTC · re: jidanni@jidanni.org · lore

Re: git-cache-meta -- simple file meta data caching and applying

On Thursday 08 January 2009, jidanni@jidanni.org wrote about 'git-cache-meta -- simple file meta data caching and applying':

Show 5 quoted lines
>Gentlemen, I have whipped up this:
>
>#!/bin/sh -e
>#git-cache-meta -- simple file meta data caching and applying.
>#Simpler than etckeeper, metastore, setgitperms, etc.

You *might* look at pristine-tar from Debian. It's specifically designed to be able to generate the .orig.tar.gz that Debian packages are based on from a VCS checkout, but it's code might be useful.

I do like your script though. It's simple and the output is plain text so it is easy to have your VCS maintain it.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
jidanni@jidanni.org· Jan 10, 2009, 17:43 UTC · re: Boyd Stephen Smith Jr. · lore

[PATCH] git-cache-meta -- file owner and permissions caching, minimalist approach

Signed-off-by: jidanni <jidanni@jidanni.org>
---
 contrib/metadata/git-cache-meta |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100755 contrib/metadata/git-cache-meta
diff --git a/contrib/metadata/git-cache-meta b/contrib/metadata/git-cache-meta
new file mode 100755
index 0000000..5e1b740
--- /dev/null
+++ b/contrib/metadata/git-cache-meta
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+# git-cache-meta -- file owner and permissions caching, minimalist approach
+: ${GIT_CACHE_META_FILE=.git_cache_meta} #simpler not to git-add it
+case $@ in
+    --store|--stdout)
+	case $1 in --store) exec > $GIT_CACHE_META_FILE; esac
+	git ls-files|xargs -I{} find {} \
+	    \( -user ${USER?} -o -printf "chown %u '%p'\n" \) \
+	    \( -group $USER -o -printf "chgrp %g '%p'\n" \) \
+	    \( \( -type l -o -perm 755 -o -perm 644 \) \
+			-o -printf "chmod %#m '%p'\n" \);;#requires GNU Find
+    --apply) sh -e $GIT_CACHE_META_FILE;;
+    *) 1>&2 cat <<EOF; exit 1;;
+Usage: $0 --store|--stdout|--apply #Example:
+# git bundle create mybundle.bdl master; git-cache-meta --store
+# scp mybundle.bdl .git_cache_meta machine2: #then on machine2:
+# git init; git pull mybundle.bdl master; git-cache-meta --apply
+EOF
+esac
-- 
1.6.0.6

← back to recent threads