3

我想预接收挂钩可能会有所帮助。
我认为

#!/bin/sh
read old_sha1 new_sha1 refname
git diff $old_sha1..$new_sha1 may 

帮助找出冲突标记。
但是如何使用正则表达式或其他来判断此提交中是否存在未解决的冲突?冲突呈现如下:

<<<<<<< HEAD
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> d7785deagea4342532g2q632y321632g23h23
4

1 回答 1

9
#!/bin/bash
read old_sha new_sha refname
if git diff "$old_sha" "$new_sha" | grep -qE '^[+]?(<<<<<|>>>>>)'; then
    echo "Saw a conflict marker in $(basename "$refname")."
    exit 1
fi
于 2012-07-06T08:08:25.693 回答