On Tue, Apr 15, 2008 at 03:19:30PM -0400, Jeff King wrote: > > Not complicated at all. Put that description in-tree in a known location > > (say, "help-branch") in-tree and your propagation problem is solved. > > > > And have a scriptlet in $HOME/bin/git-help-branch to grep from that file. > > It is perhaps a little slow if you want to do things like adding the > help text to branch name decorations in log output. Maybe instead of a > flat file, you could parallel the ref name hierarchy in a tree? I.e., It occurred to me that you actually meant "just stick it in a file in your actual work tree", not on a separate branch (for some reason, reading the name "help-branch" made me think you meant a ref). So that is obviously the very simple solution. But for fun, and because maybe somebody could learn something, here is a script implementing my approach. I dunno if it is worth including in contrib. -- >8 -- contrib: add git-refinfo This is a cute hack to show one possible way of storing ref descriptions. It might be useful to somebody. It also serves as a relatively short and simple example of how to script git. Signed-off-by: Jeff King <peff@xxxxxxxx> --- contrib/examples/git-refinfo.sh | 87 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 87 insertions(+), 0 deletions(-) create mode 100755 contrib/examples/git-refinfo.sh diff --git a/contrib/examples/git-refinfo.sh b/contrib/examples/git-refinfo.sh new file mode 100755 index 0000000..b79a20f --- /dev/null +++ b/contrib/examples/git-refinfo.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# +# git-refinfo: a ref-description mechanism +# +# git-refinfo maintains a mapping of refnames to descriptions; +# it stores the mapping as a version-controlled tree. Each +# path in the tree represents a ref name, and the contents of +# that path are the description. +# +# That means you can either use git-refinfo to set or examine +# ref descriptions, or you can simply "git checkout refinfo" +# and view and edit the files directly. + +REFINFO=refs/heads/refinfo +SUBDIRECTORY_OK=Yes +USAGE=' +git-refinfo set [<ref>] <description> +git-refinfo get [<ref> ...]' +. git-sh-setup + +die_usage() { + echo >&2 "usage: $USAGE" + exit 1 +} + +full_ref() { + git show-ref "$1" | sed -e 's/^[^ ]* //' -e '1q' +} + +heads() { + git show-ref --heads | sed 's/.*refs\/heads\///' +} + +do_get() { + ref=`full_ref "$1"` + case "$ref" in + '') desc= ;; + *) desc=`git cat-file blob "$REFINFO:$ref" 2>/dev/null` ;; + esac + printf '%s\t%s\n' "$1" "$desc" +} + +do_set() { + ref=`full_ref "$1"` + case "$ref" in + '') + case "$1" in + refs/*) ref=$1 ;; + heads/*) ref=refs/$1 ;; + *) ref=refs/heads/* ;; + esac + ;; + esac + GIT_INDEX_FILE=$GIT_DIR/refinfo-index; export GIT_INDEX_FILE + rm -f $GIT_INDEX + old=`git rev-parse --verify $REFINFO 2>/dev/null` + case "$old" in + '') parents= ;; + *) parents="-p $old"; git read-tree $REFINFO ;; + esac + blob=`printf '%s\n' "$2" | git hash-object -w --stdin` + git update-index --add --cacheinfo 0644 $blob "$ref" + tree=`git write-tree` + commit=`echo "update $1" | git commit-tree $tree $parents` + git update-ref -m refinfo $REFINFO $commit $old +} + +case "$1" in +set) + shift + case "$#" in + 1) do_set "`git symbolic-ref HEAD`" "$1" ;; + 2) do_set "$1" "$2" ;; + *) die_usage ;; + esac + ;; +get) + shift + case "$#" in + 0) for i in `heads`; do do_get "$i"; done ;; + *) for i in "$@"; do do_get "$i"; done ;; + esac + ;; +*) + die_usage +esac +exit 0 -- 1.5.5.63.g4e41c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html