Git的提交原子? [英] Is Git's commit atomic?

查看:423
本文介绍了Git的提交原子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新挂钩可以拒绝部分提交并允许其他人。

receive_pack.c中的update()运行在一个循环中,然后在提交期间多次调用更新钩子。每次更新钩子被调用时,它都会返回失败,看起来允许一些refs被更新,如果被拒绝的话一些更新不会被更新。



Git的更新钩子功能允许可能是提交成功的一部分,有些失败意味着Git的提交不是原子性的?



或者我在这里丢失了什么?谢谢。

解决方案

是提交是原子的。不可能拒绝部分提交。



在单个推送过程中可能会多次调用更新挂钩(不是
提交)如果多个分支同时被推送。这允许
接受某些分支的更新,同时拒绝更新给其他分支,但是每个
接受的更新仍将指向推送
存储库的完整提交。


An update hook can reject parts of a commit and allow others.

update() in receive_pack.c runs in a loop which then calls the update hook possibly multiple times during a commit. Each time the update hook is called, it can return failure, seemingly allowing some refs to be updated and some not updated if rejected.

Does Git's feature of an update hook allowing possibly part of a commit to succeed and some fail mean that Git's commit is not atomic?

Or what am I missing here? Thanks.

解决方案

Yes commits are atomic. It is not possible to reject part of a commit.

The update hook may be called multiple times during a single push (not commit) if multiple branches are being pushed at the same time. This allows accepting updates to some branches while rejecting updates to others, but each accepted update will still point to a complete commit from the pushing repository.

这篇关于Git的提交原子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆