1
1
* 2467_gitfs:
  changed README.extfs
  Ticket #2467 (gitfs)
Этот коммит содержится в:
Ilia Maslakov 2011-07-16 13:57:49 +00:00
родитель e697f01eba bdc7fc76cb
Коммит 9814c73b87
6 изменённых файлов: 260 добавлений и 1 удалений

Просмотреть файл

@ -104,6 +104,12 @@
# Maybe: Open/XOpen/GOpen/KOpen/... for Console/X/GNOME/KDE/etc.
### GIT Repo ###
# gitfs changeset
regex/^\[git\]
Open=%cd %p/changesetfs://
View=%cd %p/patchsetfs://
### Archives ###
# .tgz, .tpz, .tar.gz, .tar.z, .tar.Z, .ipk
@ -660,7 +666,6 @@ regex/\.xz$
Open=xz -dc %f | %var{PAGER:more}
View=%view{ascii} xz -dc %f 2>/dev/null
### Default ###
# Default target for anything not described above

Просмотреть файл

@ -42,11 +42,14 @@ EXTFS_OUT = \
a+ \
apt+ \
audio \
changesetfs \
patchsetfs \
deb \
deba \
debd \
dpkg+ \
iso9660 \
gitfs \
hp48+ \
lslR \
mailfs \

Просмотреть файл

@ -65,3 +65,8 @@ iso9660
# Amazon S3
s3+
# git frontend
gitfs - browse the git repo
changesetfs - list of versions of current file
patchsetfs - list of patches of current file

107
src/vfs/extfs/helpers/changesetfs Исполняемый файл
Просмотреть файл

@ -0,0 +1,107 @@
#!/bin/sh
LANG=C
export LANG
# --- GIT -----------------------------------------------------------------------
found_git_dir()
{
work_dir=$1
while [ -n "$work_dir" -a "$work_dir" != "/" ]; do
[ -d "${work_dir}/.git" ] && {
echo "${work_dir}/.git/"
return
}
work_dir=`dirname "$work_dir"`
done
echo ''
}
changesetfs_list_git()
{
WORK_DIR=$1; shift
fname=$1; shift
USER=$1; shift
DATE=$1; shift
GIT_DIR=`found_git_dir "$WORK_DIR"`
[ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
curr_year=`date +"%Y"`
git --git-dir="$GIT_DIR" log --abbrev=7 --pretty="format:%at %h %an" -- "$fname" | while read TIMESTAMP chset author
do
year=`date -d @"$TIMESTAMP" +"%Y"`
[ "$year" = "$curr_year" ] && {
DATE=`date -d @"$TIMESTAMP" +"%b %d %H:%M"`
} || {
DATE=`date -d @"$TIMESTAMP" +"%b %d %Y"`
}
NAME="$chset $author"
echo "-rw-rw-rw- 1 $USER 0 0 $DATE $NAME `basename $fname`"
done
}
changesetfs_copyout_git()
{
WORK_DIR=$1; shift
fname=$1; shift
orig_fname=$1;shift
output_fname=$1;shift
chset=`echo "$orig_fname"| cut -f 1 -d " "`
GIT_DIR=`found_git_dir "$WORK_DIR"`
[ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
filecommit=`git --git-dir="$GIT_DIR" show --raw --pretty=tformat:%h "$chset" -- "$fname"| \
tail -n1 | \
sed 's@^::[0-9]*\s*[0-9]*\s*[0-9]*\s*@@' | \
sed 's@^:[0-9]*\s*[0-9]*\s*@@' | \
cut -d'.' -f 1`
git --git-dir="$GIT_DIR" show "$filecommit" > "$output_fname"
}
# --- COMMON --------------------------------------------------------------------
changesetfs_list()
{
VCS_type=$1; shift
WORK_DIR=$1; shift
fname=$1; shift
DATE=`date +"%b %d %H:%M"`
USER=`whoami`
case "$VCS_type" in
git) changesetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;;
esac
}
changesetfs_copyout()
{
VCS_type=$1; shift
WORK_DIR=$1; shift
fname=$1; shift
case "$VCS_type" in
git) changesetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;;
esac
}
# --- MAIN ----------------------------------------------------------------------
command=$1; shift
tmp_file=$1; shift
WORK_DIR=`head -n1 $tmp_file`
fname=`tail -n2 $tmp_file | head -n1`
VCS_type=`tail -n1 $tmp_file`
case "$command" in
list) changesetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;;
copyout) changesetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;;
*) exit 1 ;;
esac
exit 0

37
src/vfs/extfs/helpers/gitfs Исполняемый файл
Просмотреть файл

@ -0,0 +1,37 @@
#!/bin/sh
LANG=C
export LANG
umask 077
prefix='[git]'
gitfs_list()
{
DATE=`date +"%b %d %H:%M"`
GIT_DIR="$2/.git"
user=`whoami`
git ls-files -v -c -m -d | sort -k 2 | uniq -f 1 | while read status fname
do
[ "$status" = "H" ] && status=" "
[ "$status" = "C" ] && status="*"
echo "-r--r--r-- 1 $user 0 0 $DATE `dirname $fname`/$prefix$status`basename $fname`"
done
}
gitfs_copyout()
{
echo -e "$2" > "$4"
b=`echo "$prefix"| wc -c`
b=`expr "$b" + 1`
# remove prefix from file name
echo "`dirname "$3"`/`basename "$3" | tail -c+"$b"`" >> "$4"
echo "git" >> "$4"
}
case "$1" in
list) gitfs_list "$@" ;;
copyout) gitfs_copyout "$@" ;;
*) exit 1 ;;
esac
exit 0

102
src/vfs/extfs/helpers/patchsetfs Исполняемый файл
Просмотреть файл

@ -0,0 +1,102 @@
#!/bin/sh
LANG=C
export LANG
# --- GIT -----------------------------------------------------------------------
found_git_dir()
{
work_dir=$1
while [ -n "$work_dir" -a "$work_dir" != "/" ]; do
[ -d "${work_dir}/.git" ] && {
echo "${work_dir}/.git/"
return
}
work_dir=`dirname "$work_dir"`
done
echo ''
}
patchsetfs_list_git()
{
WORK_DIR=$1; shift
fname=$1; shift
USER=$1; shift
DATE=$1; shift
GIT_DIR=`found_git_dir "$WORK_DIR"`
[ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
curr_year=`date +"%Y"`
git --git-dir="$GIT_DIR" log --abbrev=7 --pretty="format:%at %h %an" -- "$fname" | while read TIMESTAMP chset author
do
year=`date -d @"$TIMESTAMP" +"%Y"`
[ "$year" = "$curr_year" ] && {
DATE=`date -d @"$TIMESTAMP" +"%b %d %H:%M"`
} || {
DATE=`date -d @"$TIMESTAMP" +"%b %d %Y"`
}
NAME="$chset $author"
echo "-rw-rw-rw- 1 $USER 0 0 $DATE $NAME.diff"
done
}
patchsetfs_copyout_git()
{
WORK_DIR=$1; shift
fname=$1; shift
orig_fname=$1;shift
output_fname=$1;shift
chset=`echo "$orig_fname"| cut -f 1 -d " "`
GIT_DIR=`found_git_dir "$WORK_DIR"`
[ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
git --git-dir="$GIT_DIR" show "$chset" -- "$fname" > "$output_fname"
}
# --- COMMON --------------------------------------------------------------------
patchsetfs_list()
{
VCS_type=$1; shift
WORK_DIR=$1; shift
fname=$1; shift
DATE=`date +"%b %d %H:%M"`
USER=`whoami`
case "$VCS_type" in
git) patchsetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;;
esac
}
patchsetfs_copyout()
{
VCS_type=$1; shift
WORK_DIR=$1; shift
fname=$1; shift
case "$VCS_type" in
git) patchsetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;;
esac
}
# --- MAIN ----------------------------------------------------------------------
command=$1; shift
tmp_file=$1; shift
WORK_DIR=`head -n1 $tmp_file`
fname=`tail -n2 $tmp_file | head -n1`
VCS_type=`tail -n1 $tmp_file`
case "$command" in
list) patchsetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;;
copyout) patchsetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;;
*) exit 1 ;;
esac
exit 0