Disable the localized output of utilities such as - ls, git, etc..
[midnight-commander.git] / src / vfs / extfs / helpers / patchsetfs
blob9bbe9f97d32f3e0e43b0bea8b76015a8f4ffb8ed
1 #!/bin/sh
3 LANG=C
4 export LANG
5 LC_TIME=C
6 export LC_TIME
8 # --- GIT -----------------------------------------------------------------------
10 found_git_dir()
12 work_dir=$1
13 while [ -n "$work_dir" -a "$work_dir" != "/" ]; do
14 [ -d "${work_dir}/.git" ] && {
15 echo "${work_dir}/.git/"
16 return
18 work_dir=`dirname "$work_dir"`
19 done
20 echo ''
23 patchsetfs_list_git()
25 WORK_DIR=$1; shift
26 fname=$1; shift
27 USER=$1; shift
28 DATE=$1; shift
30 GIT_DIR=`found_git_dir "$WORK_DIR"`
31 [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
32 curr_year=`date +"%Y"`
34 git --git-dir="$GIT_DIR" log --abbrev=7 --pretty="format:%at %h %an" -- "$fname" | while read TIMESTAMP chset author
36 year=`date -d @"$TIMESTAMP" +"%Y"`
37 [ "$year" = "$curr_year" ] && {
38 DATE=`date -d @"$TIMESTAMP" +"%b %d %H:%M"`
39 } || {
40 DATE=`date -d @"$TIMESTAMP" +"%b %d %Y"`
42 NAME="$chset $author"
43 echo "-rw-rw-rw- 1 $USER 0 0 $DATE $NAME.diff"
44 done
47 patchsetfs_copyout_git()
49 WORK_DIR=$1; shift
50 fname=$1; shift
51 orig_fname=$1;shift
52 output_fname=$1;shift
54 chset=`echo "$orig_fname"| cut -f 1 -d " "`
56 GIT_DIR=`found_git_dir "$WORK_DIR"`
57 [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR
59 git --git-dir="$GIT_DIR" show "$chset" -- "$fname" > "$output_fname"
62 # --- COMMON --------------------------------------------------------------------
64 patchsetfs_list()
66 VCS_type=$1; shift
67 WORK_DIR=$1; shift
68 fname=$1; shift
70 DATE=`date +"%b %d %H:%M"`
71 USER=`whoami`
73 case "$VCS_type" in
74 git) patchsetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;;
75 esac
78 patchsetfs_copyout()
80 VCS_type=$1; shift
81 WORK_DIR=$1; shift
82 fname=$1; shift
84 case "$VCS_type" in
85 git) patchsetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;;
86 esac
90 # --- MAIN ----------------------------------------------------------------------
92 command=$1; shift
93 tmp_file=$1; shift
95 WORK_DIR=`head -n1 $tmp_file`
96 fname=`tail -n2 $tmp_file | head -n1`
97 VCS_type=`tail -n1 $tmp_file`
99 case "$command" in
100 list) patchsetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;;
101 copyout) patchsetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;;
102 *) exit 1 ;;
103 esac
104 exit 0