When you have to replace an already published branch with its rebased version, you would have to --force, but then you risk losing work, if any, that was pushed by somebody else while you are working on rebasing, as your earlier decision that replacing the old one with its rebase is OK was based on the assumption that there is nothing else going on. Unfortunately, --force is blind, and did not offer this "... but fail if the tip has moved from what I expect". And here is a series to remedy it. It lets you specify what the expected current values of refs you are attempting to update, and if you are lazy, the value is taken from your remote tracking branch for the ref you are attempting to update. I am not married to the "lockref" name, but I think the semantics implemented here is what we discussed to do in the earlier discussion. cf. http://thread.gmane.org/gmane.comp.version-control.git/229430 This may still be rough at edges, but a basic testset seems to pass. I haven't bothered to check the smart-http transport; help is greatly appreciated. Junio C Hamano (7): cache.h: move remote/connect API out of it builtin/push.c: use OPT_BOOL, not OPT_BOOLEAN push: beginning of compare-and-swap "force/delete safety" remote.c: add command line option parser for --lockref push --lockref: implement logic to populate old_sha1_expect[] t5533: test "push --lockref" push: document --lockref Documentation/git-push.txt | 26 +++++++ builtin/fetch-pack.c | 2 + builtin/push.c | 18 ++++- builtin/receive-pack.c | 1 + builtin/send-pack.c | 26 +++++++ cache.h | 62 ---------------- connect.c | 1 + connect.h | 13 ++++ fetch-pack.c | 1 + fetch-pack.h | 1 + refs.c | 8 --- remote.c | 149 +++++++++++++++++++++++++++++++++++++- remote.h | 83 +++++++++++++++++++++ send-pack.c | 2 + t/t5533-push-cas.sh | 176 +++++++++++++++++++++++++++++++++++++++++++++ transport-helper.c | 6 ++ transport.c | 13 ++++ transport.h | 5 ++ upload-pack.c | 1 + 19 files changed, 519 insertions(+), 75 deletions(-) create mode 100644 connect.h create mode 100755 t/t5533-push-cas.sh -- 1.8.3.2-875-g76c723c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html