{"push_id":662924762,"size":23,"distinct_size":23,"ref":"refs/heads/verify-lock-strbuf-err","head":"5242174ff5c43787629c849eefaaf3dae0b51be8","before":"22aca1b3ac10af7188dccf033b44a36926f04d4b","commits":[{"sha":"433efcad9d3c0c0b30f01b3de2cfa51a854befb3","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"t1404: new tests of ref D/F conflicts within transactions\n\nAdd some tests of reference D/F conflicts (by which I mean the fact\nthat references like \"refs/foo\" and \"refs/foo/bar\" are not allowed to\ncoexist) in the context of reference transactions.\n\nThe test of creating two conflicting references in the same\ntransaction fails, leaving the transaction half-completed. This will\nbe fixed later in this patch series.\n\nPlease note that the error messages emitted in the case of conflicts\nare not very user-friendly. In particular, when the conflicts involve\nloose references, then the errors are reported as\n\n    error: there are still refs under 'refs/foo'\n    fatal: Cannot lock the ref 'refs/foo'.\n\nor\n\n    error: unable to resolve reference refs/foo/bar: Not a directory\n    fatal: Cannot lock the ref 'refs/foo/bar'.\n\nThis is because lock_ref_sha1_basic() fails while trying to lock the\nnew reference, before it even gets to the is_refname_available()\ncheck. This situation will also be improved later in this patch\nseries.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/433efcad9d3c0c0b30f01b3de2cfa51a854befb3"},{"sha":"49e818762aaf08791504d4de2076027e7d275844","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"is_refname_available(): revamp the comments\n\nChange the comments to a running example of running the function with\nrefname set to \"refs/foo/bar\". Add some more explanation of the logic.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/49e818762aaf08791504d4de2076027e7d275844"},{"sha":"9ef6eaa287b12ff9469c7775507f107b86f9a8c8","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"is_refname_available(): avoid shadowing \"dir\" variable\n\nThe function had a \"dir\" parameter that was shadowed by a local \"dir\"\nvariable within a code block. Use the former in place of the latter.\n(This is consistent with \"dir\"'s use elsewhere in the function.)\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/9ef6eaa287b12ff9469c7775507f107b86f9a8c8"},{"sha":"6075f3076e8a7fea0a132d459d1e21e771cdd880","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"is_refname_available(): convert local variable \"dirname\" to strbuf\n\nThis change wouldn't be worth it by itself, but in a moment we will\nuse the strbuf for more string juggling.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/6075f3076e8a7fea0a132d459d1e21e771cdd880"},{"sha":"8bfac19ab4844a63e2f660fcaf4fec4fbe08e47f","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"entry_matches(): inline function\n\nIt wasn't pulling its weight. And in a moment we will need similar\ntests that take a refname rather than a ref_entry as parameter, which\nwould have made entry_matches() even less useful.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/8bfac19ab4844a63e2f660fcaf4fec4fbe08e47f"},{"sha":"385e8af5a2d1056b75428eea810bce65d2c83363","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"report_refname_conflict(): inline function\n\nIt wasn't pulling its weight. And we are about to need code similar to\nthis where no ref_entry is available and with more diverse error\nmessages. Rather than try to generalize the function, just inline it.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/385e8af5a2d1056b75428eea810bce65d2c83363"},{"sha":"521331cc9f71515e214d0821a35cafd5c03eaad3","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"struct nonmatching_ref_data: store a refname instead of a ref_entry\n\nNow that we don't need a ref_entry to pass to\nreport_refname_conflict(), it is sufficient to store the refname of\nthe conflicting reference.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/521331cc9f71515e214d0821a35cafd5c03eaad3"},{"sha":"61da59699263afcbf8f1e3c66763237fe35ba670","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"is_refname_available(): use dirname in first loop\n\nIn the first loop (over prefixes of refname), use dirname to keep\ntrack of the current prefix. This is not an improvement in itself, but\nin a moment we will start using dirname for a role where a\nNUL-terminated string is needed.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/61da59699263afcbf8f1e3c66763237fe35ba670"},{"sha":"07f9c881d6acef35b7dc8e5c783e63b1cac71084","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"ref_transaction_commit(): use a string_list for detecting duplicates\n\nDetect duplicates by storing the reference names in a string_list and\nsorting that, instead of sorting the ref_updates directly.\n\n* In a moment the string_list will be used for another purpose, too.\n\n* This removes the need for the custom comparison function\n  ref_update_compare().\n\n* This means that we can carry out the updates in the order that the\n  user specified them instead of reordering them. This might be handy\n  someday if, we want to permit multiple updates to a single reference\n  as long as they are compatible with each other.\n\nNote: we can't use string_list_remove_duplicates() to check for\nduplicates, because we need to know the name of the reference that\nappeared multiple times, to be used in the error message.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/07f9c881d6acef35b7dc8e5c783e63b1cac71084"},{"sha":"e911104c84f2efd64aded6831bd7e6625c8a0fab","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"refs: check for D/F conflicts among refs created in a transaction\n\nIf two references that D/F conflict (e.g., \"refs/foo\" and\n\"refs/foo/bar\") are created in a single transaction, the old code\ndiscovered the problem only after the \"commit\" phase of\nref_transaction_commit() had already begun. This could leave some\nreferences updated and others not, which violates the promise of\natomicity.\n\nInstead, check for such conflicts during the \"locking\" phase:\n\n* Teach is_refname_available() to take an \"extras\" parameter that can\n  contain extra reference names with which the specified refname must\n  not conflict.\n\n* Change lock_ref_sha1_basic() to take an \"extras\" parameter, which it\n  passes through to is_refname_available().\n\n* Change ref_transaction_commit() to pass \"affected_refnames\" to\n  lock_ref_sha1_basic() as its \"extras\" argument.\n\nThis change fixes a test case in t1404.\n\nThis code is a bit stricter than it needs to be. We could conceivably\nallow reference \"refs/foo/bar\" to be created in the same transaction\nas \"refs/foo\" is deleted (or vice versa). But that would be\ncomplicated to implement, because it is not possible to lock\n\"refs/foo/bar\" while \"refs/foo\" exists as a loose reference, but on\nthe other hand we don't want to delete some references before adding\nothers (because that could leave a gap during which required objects\nare unreachable). There is also a complication that reflog files'\npaths can conflict.\n\nAny less-strict implementation would probably require tricks like the\npacking of all references before the start of the real transaction, or\nthe use of temporary intermediate reference names.\n\nSo for now let's accept too-strict checks. Some reference update\ntransactions will be rejected unnecessarily, but they will be rejected\nin their entirety rather than leaving the repository in an\nintermediate state, as would happen now.\n\nPlease note that there is still one kind of D/F conflict that is *not*\nhandled correctly. If two processes are running at the same time, and\none tries to create \"refs/foo\" at the same time that the other tries\nto create \"refs/foo/bar\", then they can race with each other. Both\nprocesses can obtain their respective locks (\"refs/foo.lock\" and\n\"refs/foo/bar.lock\"), proceed to the \"commit\" phase of\nref_transaction_commit(), and then the slower process will discover\nthat it cannot rename its lockfile into place (after possibly having\ncommitted changes to other references). There appears to be no way to\nfix this race without changing the locking policy, which in turn would\nrequire a change to *all* Git clients.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/e911104c84f2efd64aded6831bd7e6625c8a0fab"},{"sha":"5baf37d383ff80e913da1cc99a325a9baadc844c","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"verify_refname_available(): rename function\n\nRename is_refname_available() to verify_refname_available() and change\nits return value from 1 for success to 0 for success, to be consistent\nwith our error-handling convention. In a moment it will also get a\n\"struct strbuf *err\" parameter.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/5baf37d383ff80e913da1cc99a325a9baadc844c"},{"sha":"1146f17e2ce6054b502a46bafc102312c60a8380","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"verify_refname_available(): report errors via a \"struct strbuf *err\"\n\nIt shouldn't be spewing errors directly to stderr.\n\nFor now, change its callers to spew the errors to stderr.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/1146f17e2ce6054b502a46bafc102312c60a8380"},{"sha":"4a32b2e08be8daf965949956e8ea16718797a031","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"lock_ref_sha1_basic(): report errors via a \"struct strbuf *err\"\n\nFor now, change the callers to spew the error to stderr like before.\nBut soon we will change them to incorporate the reason for the failure\ninto their own error messages.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/4a32b2e08be8daf965949956e8ea16718797a031"},{"sha":"5b2d8d6f2184381b76c13504a2f5ec8a62cd584e","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"lock_ref_sha1_basic(): improve diagnostics for ref D/F conflicts\n\nIf there is a failure to lock a reference that is likely caused by a\nD/F conflict (e.g., trying to lock \"refs/foo/bar\" when reference\n\"refs/foo\" already exists), invoke verify_refname_available() to try\nto generate a more helpful error message.\n\nThat function might not detect an error. For example, some\nnon-reference file might be blocking the deletion of an\notherwise-empty directory tree, or there might be a race with another\nprocess that just deleted the offending reference. In such cases,\ngenerate the strerror-based error message like before.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/5b2d8d6f2184381b76c13504a2f5ec8a62cd584e"},{"sha":"abeef9c85657fddf98f01c8479f1437719e95864","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"rename_ref(): integrate lock_ref_sha1_basic() errors into ours\n\nNow that lock_ref_sha1_basic() gives us back its error messages via a\nstrbuf, incorporate its error message into our error message rather\nthan emitting two separate error messages.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/abeef9c85657fddf98f01c8479f1437719e95864"},{"sha":"cbaabcbc6fa9568269d6baeccb0a621cd0413c6c","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"ref_transaction_commit(): provide better error messages\n\nNow that lock_ref_sha1_basic() gives us back its error messages via a\nstrbuf, incorporate its error message into our error message rather\nthan emitting one error messages to stderr immediately and returning a\nsecond to our caller.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/cbaabcbc6fa9568269d6baeccb0a621cd0413c6c"},{"sha":"3553944aa8ca05fef7c24c5aa98c7de4bb3167d5","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"ref_transaction_commit(): delete extra \"the\" from error message\n\nWhile we are in the area, let's remove a superfluous definite article\nfrom the error message that is emitted when the reference cannot be\nlocked. This improves how it reads and makes it a bit shorter.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/3553944aa8ca05fef7c24c5aa98c7de4bb3167d5"},{"sha":"c628edfddbf37eefab810a3107a2c32b45abaedc","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"reflog_expire(): integrate lock_ref_sha1_basic() errors into ours\n\nNow that lock_ref_sha1_basic() gives us back its error messages via a\nstrbuf, incorporate its error message into our error message rather\nthan emitting two separate error messages.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/c628edfddbf37eefab810a3107a2c32b45abaedc"},{"sha":"bcea021045669e583a9b98083c8ad6e04f333099","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"verify_lock(): return 0/-1 rather than struct ref_lock *\n\nIts return value wasn't conveying any extra information, but it made\nthe reader wonder whether the ref_lock that it returned might be\ndifferent than the one that was passed to it. So change the function\nto the traditional \"return 0 on success or a negative value on error\".\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/bcea021045669e583a9b98083c8ad6e04f333099"},{"sha":"87348f2657c8af1d06b872ed450635d48d365615","author":{"email":"c24c152f145c57791e809b126db9e61bd1c1782d@alum.mit.edu","name":"Michael Haggerty"},"message":"verify_lock(): on errors, let the caller unlock the lock\n\nThe caller already knows how to do it, so always do it in the same\nplace.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>","distinct":true,"url":"https://api.github.com/repos/mhagger/git/commits/87348f2657c8af1d06b872ed450635d48d365615"}]}