public override RefUpdateResult Store(LockFile @lock, RefUpdateResult status) { GitSharp.Ref.Storage storage = ref_update._ref.StorageFormat; if (storage == GitSharp.Ref.Storage.New) return status; if (storage.IsPacked) ref_update.db.removePackedRef(ref_update._ref.Name); int levels = Count(ref_update._ref.Name, '/') - 2; // Delete logs _before_ unlocking DirectoryInfo gitDir = ref_update.db.Repository.Directory; DirectoryInfo logDir = new DirectoryInfo(gitDir+"/"+ Constants.LOGS); deleteFileAndEmptyDir(new FileInfo(logDir + "/" + ref_update._ref.Name), levels); // We have to unlock before (maybe) deleting the parent directories @lock.Unlock(); if (storage.IsLoose) deleteFileAndEmptyDir(ref_update.looseFile, levels); return status; }
private RefUpdateResult updateImpl(RevWalk.RevWalk walk, StoreBase store) { LockFile @lock; RevObject newObj; RevObject oldObj; @lock = new LockFile(looseFile); if ([email protected]()) return RefUpdateResult.LockFailure; try { OldObjectId = db.IdOf(Name); if (expValue != null) { ObjectId o; o = OldObjectId != null ? OldObjectId : ObjectId.ZeroId; if (!expValue.Equals(o)) return RefUpdateResult.LockFailure; } if (OldObjectId == null) return store.Store(@lock, RefUpdateResult.New); newObj = safeParse(walk, newValue); oldObj = safeParse(walk, OldObjectId); if (newObj == oldObj) return store.Store(@lock, RefUpdateResult.NoChange); if (newObj is RevCommit && oldObj is RevCommit) { if (walk.isMergedInto((RevCommit)oldObj, (RevCommit)newObj)) return store.Store(@lock, RefUpdateResult.FastForward); } if (IsForceUpdate) return store.Store(@lock, RefUpdateResult.Forced); return RefUpdateResult.Rejected; } finally { @lock.Unlock(); } }
public void save() { byte[] o = Constants.encode(toText()); LockFile lf = new LockFile(getFile()); if (!lf.Lock()) throw new IOException("Cannot lock " + getFile()); try { lf.Write(o); if (!lf.Commit()) throw new IOException("Cannot commit write to " + getFile()); } finally { lf.Unlock(); } }
public override RefUpdateResult Store(LockFile @lock, RefUpdateResult status) { var storage = RefUpdate._ref.StorageFormat; if (storage == Ref.Storage.New) { return status; } if (storage.IsPacked) { RefUpdate._db.RemovePackedRef(RefUpdate._ref.Name); } int levels = Count(RefUpdate._ref.Name, '/') - 2; // Delete logs _before_ unlocking DirectoryInfo gitDir = RefUpdate._db.Repository.Directory; var logDir = new DirectoryInfo(gitDir + "/" + Constants.LOGS); DeleteFileAndEmptyDir(new FileInfo(logDir + "/" + RefUpdate._ref.Name), levels); // We have to unlock before (maybe) deleting the parent directories @lock.Unlock(); if (storage.IsLoose) { DeleteFileAndEmptyDir(RefUpdate._looseFile, levels); } return status; }
private RefUpdateResult UpdateImpl(RevWalk.RevWalk walk, StoreBase store) { int lastSlash = Name.LastIndexOf('/'); if (lastSlash > 0) { if (Repository.getAllRefs().ContainsKey(Name.Slice(0, lastSlash))) { return RefUpdateResult.LockFailure; } } string rName = Name + "/"; foreach (Ref r in Repository.getAllRefs().Values) { if (r.Name.StartsWith(rName)) { return RefUpdateResult.LockFailure; } } var @lock = new LockFile(_looseFile); if ([email protected]()) { return RefUpdateResult.LockFailure; } try { OldObjectId = _db.IdOf(Name); if (_expValue != null) { ObjectId o = OldObjectId ?? ObjectId.ZeroId; if (!_expValue.Equals(o)) { return RefUpdateResult.LockFailure; } } if (OldObjectId == null) { return store.Store(@lock, RefUpdateResult.New); } RevObject newObj = SafeParse(walk, _newValue); RevObject oldObj = SafeParse(walk, OldObjectId); if (newObj == oldObj) { return store.Store(@lock, RefUpdateResult.NoChange); } if (newObj is RevCommit && oldObj is RevCommit) { if (walk.isMergedInto((RevCommit)oldObj, (RevCommit)newObj)) { return store.Store(@lock, RefUpdateResult.FastForward); } } if (IsForceUpdate) { return store.Store(@lock, RefUpdateResult.Forced); } return RefUpdateResult.Rejected; } finally { @lock.Unlock(); } }
private RefUpdateResult UpdateImpl(RevWalk.RevWalk walk, StoreBase store) { if (IsNameConflicting()) { return RefUpdateResult.LockFailure; } var @lock = new LockFile(_looseFile); if ([email protected]()) { return RefUpdateResult.LockFailure; } try { OldObjectId = _db.IdOf(Name); if (_expValue != null) { ObjectId o = OldObjectId ?? ObjectId.ZeroId; if (!AnyObjectId.equals(_expValue, o)) { return RefUpdateResult.LockFailure; } } if (OldObjectId == null) { return store.Store(@lock, RefUpdateResult.New); } RevObject newObj = SafeParse(walk, _newValue); RevObject oldObj = SafeParse(walk, OldObjectId); if (newObj == oldObj) { return store.Store(@lock, RefUpdateResult.NoChange); } if (newObj is RevCommit && oldObj is RevCommit) { if (walk.isMergedInto((RevCommit)oldObj, (RevCommit)newObj)) { return store.Store(@lock, RefUpdateResult.FastForward); } } if (IsForceUpdate) { return store.Store(@lock, RefUpdateResult.Forced); } return RefUpdateResult.Rejected; } finally { @lock.Unlock(); } }