Telling if a Git commit is a Merge/Revert commit -
i writing script requires checking whether particular commit merge/revert commit or not, , wondering if there git trick that.
what came far (and don't want depend on commit message here) check hash^2
, see if don't error, there better way?
figuring out if merge easy. that's commits more 1 parent. check that, can do, example
$ git cat-file -p $commit_id
if there's more 1 `parent' line in output, found merge.
for reverts it's not easy. reverts normal commits happen apply diff of previous commit in reverse, removing changes commit introduced. there're not special otherwise.
if revert created git revert $commit
, git generates commit message indication revert , commit reverted. however, it's quite possible reverts in other ways, or change commit message of commit generated git revert
.
looking generated revert commit message might enough heuristic you're trying achieve. if not, you'd have through other commits, comparing diffs against each other, looking of 1 exact reverse operation of another. isn't solution. enough reverts different reverse of commit they're reverting, example accomodate code changes happened between commit , revert.
Comments
Post a Comment