我注意到EGit记录rest操作的reflog的方式与Git Bash记录rest操作的方式不同。
28eab8d HEAD@{0}: commit: l
959126f HEAD@{1}: 959126fc7fbf887b3bdb5bd931f50c611f48bf71: updating HEAD
f073b25 HEAD@{2}: commit: l
959126f HEAD@{3}: reset: moving to HEAD~1
b0114f6 HEAD@{4}: commit: l
959126f HEAD@{5}: 959126fc7fbf887b3bdb5bd931f50c611f48bf71: updating HEADHEAD@{1}和HEAD@{5}由EGIT记录,而HEAD{3}由Git Bash记录。
此外,它们记录分支名称更改的方式似乎有所不同:
28eab8d9329f936c1642a591317bbe5be3fed7c1 28eab8d9329f936c1642a591317bbe5be3fed7c1 user <user@user.com> 1423771813 -0500 Branch: renamed refs/heads/test to refs/heads/testtt
28eab8d9329f936c1642a591317bbe5be3fed7c1 28eab8d9329f936c1642a591317bbe5be3fed7c1 user <user@user.com> 1423771870 -0500 Branch: renamed refs/heads/testtt to refs/heads/test
0000000000000000000000000000000000000000 28eab8d9329f936c1642a591317bbe5be3fed7c1 user <user@user.com> 1423771941 -0500 Branch: renamed test to testttt
0000000000000000000000000000000000000000 28eab8d9329f936c1642a591317bbe5be3fed7c1 user <user@user.com> 1423772021 -0500 Branch: renamed testttt to test第一行来自Git Bash,最下面的行来自EGit。此外,EGit对HEAD reflog进行了相同的更改,而Git Bash什么也不做。
最大的问题是Git Bash不会显示超过400的行,所以在Git Bash中我看不到日志。
我想我可以把一些重写日志的脚本拼凑在一起,但我想知道是否有一些设置或版本是错误的。
我使用的是Egit 3.4.1和Git Bash 1.8.5.2.msysgit.0
发布于 2015-02-13 06:09:03
以下脚本将修复由EGit引起的问题。将其命名为/bin/git-sanitize-reflog或您喜欢的任何名称。如果你感到紧张,提前做好备份。
#!/bin/bash
resetFix='s/([a-f0-9]{6})[a-f0-9]{34}: updating HEAD/reset: moving to $1/'
touch tempfile
for log in $(find $(git rev-parse --git-dir)/logs/$1 -type f)
do
if [[ $log != "$(git rev-parse --git-dir)/HEAD" ]]
then
perl -pe 's/^0{40} ([a-f0-9]{40})/$1 $1/' $log |
perl -pe 's/Branch: renamed (?!refs\/heads\/)(.*) to (?!refs\/heads\/)(.*)/Branch: renamed refs\/heads\/$1 to refs\/heads\/$2/' |
perl -pe "$resetFix" > tempfile
if [[ $(cat tempfile | wc -l) -ne $(cat $log | wc -l) ]]
then
exit -1
fi
else
HEAD_grep='^0{40}.*Branch: renamed'
egrep -v $HEAD_grep $log |
perl -pe "$resetFix" > tempfile
if [[ $(wc -l tempfile) -ne $(expr $(cat $log | wc -l) - $(egrep $HEAD_grep $log | wc -l)) ]]
then
exit -1
fi
fi
cat tempfile > $log
echo Sanitized $log
done
rm tempfilehttps://stackoverflow.com/questions/28487084
复制相似问题