Skip to contentSkip to conversation

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

PATCH New [email protected] 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

On Thursday 08 January 2009, [email protected] wrote about 'git-cache-meta -- simple file meta data caching and applying':

Quoted 5 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.

Signature · 4 lines
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
[email protected]                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Thu, Jan 8, 2009 at 7:13 PM, <[email protected]> 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)

Quoted 8 lines
       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.

#4 lore raw
Quoted 5 lines · Jay Soffian

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.

#5 lore raw

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

#2 lore raw

PATCH 1/1 git-cache-meta -- file owner and permissions caching, minimalist approach

In reply to Boyd Stephen Smith Jr.
---
 contrib/metadata/git-cache-meta |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100755 contrib/metadata/git-cache-meta
contrib/metadata/git-cache-meta new file +19 -0
new file mode 100755
index 0000000..5e1b740
@@ -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
Signature · 1 line
1.6.0.6