Updated Russian translation.
[midnight-commander.git] / src / vfs / extfs / helpers / patchsetfs
blob0998590274e3b9cbd83a06c05e09a688809bd091
1 #!/bin/sh
3 LANG=C
4 export LANG
6 # --- GIT -----------------------------------------------------------------------
8 found_git_dir()
10 work_dir=$1
11 while [ -n "$work_dir" -a "$work_dir" != "/" ]; do
12 [ -d "${work_dir}/.git" ] && {
13 echo "${work_dir}/.git/"
14 return
16 work_dir=`dirname "$work_dir"`
17 done
18 echo ''
21 patchsetfs_list_git()
23 WORK_DIR=$1; shift
24 fname=$1; shift
25 USER=$1; shift
26 DATE=$1; shift
28 GIT_DIR=`found_git_dir "$WORK_DIR"`
29 [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
30 curr_year=`date +"%Y"`
32 git --git-dir="$GIT_DIR" log --abbrev=7 --pretty="format:%at %h %an" -- "$fname" | while read TIMESTAMP chset author
34 year=`date -d @"$TIMESTAMP" +"%Y"`
35 [ "$year" = "$curr_year" ] && {
36 DATE=`date -d @"$TIMESTAMP" +"%b %d %H:%M"`
37 } || {
38 DATE=`date -d @"$TIMESTAMP" +"%b %d %Y"`
40 NAME="$chset $author"
41 echo "-rw-rw-rw- 1 $USER 0 0 $DATE $NAME.diff"
42 done
45 patchsetfs_copyout_git()
47 WORK_DIR=$1; shift
48 fname=$1; shift
49 orig_fname=$1;shift
50 output_fname=$1;shift
52 chset=`echo "$orig_fname"| cut -f 1 -d " "`
54 GIT_DIR=`found_git_dir "$WORK_DIR"`
55 [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
57 git --git-dir="$GIT_DIR" show "$chset" -- "$fname" > "$output_fname"
60 # --- COMMON --------------------------------------------------------------------
62 patchsetfs_list()
64 VCS_type=$1; shift
65 WORK_DIR=$1; shift
66 fname=$1; shift
68 DATE=`date +"%b %d %H:%M"`
69 USER=`whoami`
71 case "$VCS_type" in
72 git) patchsetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;;
73 esac
76 patchsetfs_copyout()
78 VCS_type=$1; shift
79 WORK_DIR=$1; shift
80 fname=$1; shift
82 case "$VCS_type" in
83 git) patchsetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;;
84 esac
88 # --- MAIN ----------------------------------------------------------------------
90 command=$1; shift
91 tmp_file=$1; shift
93 WORK_DIR=`head -n1 $tmp_file`
94 fname=`tail -n2 $tmp_file | head -n1`
95 VCS_type=`tail -n1 $tmp_file`
97 case "$command" in
98 list) patchsetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;;
99 copyout) patchsetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;;
100 *) exit 1 ;;
101 esac
102 exit 0