本文主要是介绍Linux 根据提交记录生成补丁及新旧文件对比,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#!/bin/bash#解决/bin/bash^M: bad interpreter: Text file busy
#sed -i 's/\r$//' test1.shCMD1=$1
CMD2=$2
CMD3=$3
echo "CMD1 > $CMD1"
echo "CMD2 > $CMD2"
echo "CMD3 > $CMD3"
# 运行时的入参 CMD1提交记录1 CMD2提交记录2 CMD3输出目录 ../diff/$CMD3if [ "$CMD1" == "" ];thenecho "<<<<<<<<<<<<<<<<<<<<<< error"exit 0
fiif [ "$CMD2" == "" ];thenecho "<<<<<<<<<<<<<<<<<<<<<< error"exit 0
fiif [ "$CMD3" == "" ];thenCMD3="supplier"
fimkdir -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目录
参考链接:
git导出差异文件及目录结构 - 我是橘子 - 博客园 (cnblogs.com)
这篇关于Linux 根据提交记录生成补丁及新旧文件对比的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!