赞
踩
- #!/bin/bash
-
- #解决/bin/bash^M: bad interpreter: Text file busy
- #sed -i 's/\r$//' test1.sh
-
- CMD1=$1
- CMD2=$2
- CMD3=$3
- echo "CMD1 > $CMD1"
- echo "CMD2 > $CMD2"
- echo "CMD3 > $CMD3"
- # 运行时的入参 CMD1提交记录1 CMD2提交记录2 CMD3输出目录 ../diff/$CMD3
-
- if [ "$CMD1" == "" ];then
- echo "<<<<<<<<<<<<<<<<<<<<<< error"
- exit 0
- fi
-
- if [ "$CMD2" == "" ];then
- echo "<<<<<<<<<<<<<<<<<<<<<< error"
- exit 0
- fi
-
- if [ "$CMD3" == "" ];then
- CMD3="supplier"
- fi
-
- mkdir -p ../diff/$CMD3/old
- mkdir -p ../diff/$CMD3/new
- echo "mkdir"
-
- git log $CMD1 -1 --name-only |grep '/'| awk '{print $1}' > ../diff/list.txt
- # 查看$CMD1提交记录的文件列表
-
- xargs -a ../diff/list.txt cp --parents -t ../diff/$CMD3/old
- xargs -a ../diff/list.txt cp --parents -t ../diff/$CMD3/new
- echo "cp files"
-
- git diff $CMD2 $CMD1 > ../diff/$CMD3/list.diff
- echo "new list.diff"
- # 根据$CMD1提交记录对比前一条提交记录$CMD2生成差异文件
-
- cd ../diff/$CMD3/old
- patch -R -p1 <../list.diff
- echo "patch list.diff"
- # 打补丁
-
- echo "<<<<<<<<<<<<<<<<<<<<<< finish"
- exit 0
-
-
-
-
-
根据两个提交记录CMD1和CMD2生成差异文件list.diff,并根据CMD1的修改文件列表复制修改前的文件到old目录,修改后的文件到new目录
参考链接:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。