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

6 messages from 2009-01-09 to 2009-01-10. Participants: jidanni@jidanni.org, Jay Soffian, Boyd Stephen Smith Jr..
Thread: https://gitlist.dev/t/17059

## jidanni@jidanni.org, 2009-01-09 00:13

Subject: git-cache-meta -- simple file meta data caching and applying
Message-ID: <87hc49jq04.fsf@jidanni.org>
URL: https://gitlist.dev/e/87hc49jq04.fsf%40jidanni.org

```
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, 2009-01-09 00:22

Subject: Re: git-cache-meta -- simple file meta data caching and applying
Message-ID: <76718490901081622q618c43d0t333882cbe44f6b30@mail.gmail.com>
URL: https://gitlist.dev/e/76718490901081622q618c43d0t333882cbe44f6b30%40mail.gmail.com
In-Reply-To: <87hc49jq04.fsf@jidanni.org>

```
On Thu, Jan 8, 2009 at 7:13 PM,  <jidanni@jidanni.org> wrote:
> 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, 2009-01-09 00:28

Subject: Re: git-cache-meta -- simple file meta data caching and applying
Message-ID: <76718490901081628x62da43bcia5cdbb160b0ff24a@mail.gmail.com>
URL: https://gitlist.dev/e/76718490901081628x62da43bcia5cdbb160b0ff24a%40mail.gmail.com
In-Reply-To: <76718490901081622q618c43d0t333882cbe44f6b30@mail.gmail.com>

```
On Thu, Jan 8, 2009 at 7:22 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> 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, 2009-01-09 02:50

Subject: Re: git-cache-meta -- simple file meta data caching and applying
Message-ID: <878wpljiq9.fsf@jidanni.org>
URL: https://gitlist.dev/e/878wpljiq9.fsf%40jidanni.org
In-Reply-To: <76718490901081628x62da43bcia5cdbb160b0ff24a@mail.gmail.com>

```
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., 2009-01-09 04:29

Subject: Re: git-cache-meta -- simple file meta data caching and applying
Message-ID: <200901082229.46433.bss@iguanasuicide.net>
URL: https://gitlist.dev/e/200901082229.46433.bss%40iguanasuicide.net
In-Reply-To: <87hc49jq04.fsf@jidanni.org>

```
On Thursday 08 January 2009, jidanni@jidanni.org wrote 
about 'git-cache-meta -- simple file meta data caching and applying':
>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, 2009-01-10 17:43

Subject: [PATCH] git-cache-meta -- file owner and permissions caching, minimalist approach
Message-ID: <87eizb12gu.fsf_-_@jidanni.org>
URL: https://gitlist.dev/e/87eizb12gu.fsf_-_%40jidanni.org
In-Reply-To: <200901082229.46433.bss@iguanasuicide.net>

```
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

```
