Ejemplo n.º 1
0
 public RefUpdate(RefDatabase refDb, Ref r, FileInfo f)
 {
     db = refDb;
     this._ref = r;
     this.OldObjectId = r.ObjectId;
     looseFile = f;
     this.Result = RefUpdateResult.NotAttempted;
 }
Ejemplo n.º 2
0
 public RefUpdate(RefDatabase refDb, Ref r, FileInfo f)
 {
     _db = refDb;
     _ref = r;
     OldObjectId = r.ObjectId;
     _looseFile = f;
     Result = RefUpdateResult.NotAttempted;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository"/> class.
        /// </summary>
        /// <param name="gitDirectory">The git directory.</param>
        /// <param name="workingDirectory">The working directory.</param>
        public Repository(DirectoryInfo gitDirectory, DirectoryInfo workingDirectory)
        {
            this.Directory = gitDirectory;
            this.WorkingDirectory = workingDirectory;
            objectDatabase = new ObjectDirectory(FS.resolve(gitDirectory, "objects"));
            _objectsDirs = new List<DirectoryInfo>();
            _objectsDirs = ReadObjectsDirs(Path.Combine(gitDirectory.FullName, "objects"), ref _objectsDirs);

            this.Config = new RepositoryConfig(this);
            _refDb = new RefDatabase(this);
            //_packs = new List<PackFile>();

            bool isExisting = _objectsDirs[0].Exists;
            if (isExisting)
            {
                this.Config.Load();
                string repositoryFormatVersion = this.Config.GetString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    throw new IOException("Unknown repository format \""
                            + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
            else
            {
                this.Config.Create();
            }
            //if (isExisting)
            //    ScanForPacks();
        }
Ejemplo n.º 4
0
 public ExtendedRefWriter(IEnumerable<Ref> refs, RefDatabase db)
     : base(refs)
 {
     _refDb = db;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository"/> class.
        /// </summary>
        /// <param name="gitDirectory">The git directory.</param>
        /// <param name="workingDirectory">The working directory.</param>
        private Repository(DirectoryInfo gitDirectory, DirectoryInfo workingDirectory)
        {
            _useCnt = 1;
            _objectsDirs = new List<DirectoryInfo>();

            Directory = gitDirectory;
            WorkingDirectory = workingDirectory;
            _objectDatabase = new ObjectDirectory(FS.resolve(gitDirectory, "objects"));
            _objectsDirs = new List<DirectoryInfo>();
            _objectsDirs = ReadObjectsDirs(Path.Combine(gitDirectory.FullName, "objects"), ref _objectsDirs);

            Config = new RepositoryConfig(this);
            _refDb = new RefDatabase(this);

            bool isExisting = _objectsDirs[0].Exists;
            if (isExisting)
            {
                try
                {
                    Config.load();
                }
                catch (ConfigInvalidException e1)
                {
                    throw new IOException("Unknown repository format", e1);
                }

                string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    throw new IOException("Unknown repository format \""
                                          + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
            else
            {
                Create();
            }
        }
Ejemplo n.º 6
0
        /**
         * Construct a representation of a Git repository.
         *
         * @param d
         *            GIT_DIR (the location of the repository metadata).
         * @throws IOException
         *             the repository appears to already exist but cannot be
         *             accessed.
         */
        public Repository(DirectoryInfo gitDirectory)
        {
            Directory = gitDirectory;
            _refDb = new RefDatabase(this);
            _objectDatabase = new ObjectDirectory(new DirectoryInfo(FS.resolve(gitDirectory, "objects").FullName));

            var userConfig = SystemReader.getInstance().openUserConfig();

            try
            {
                userConfig.load();
            }
            catch (ConfigInvalidException e1)
            {
                throw new IOException("User config file "
                    + userConfig.getFile().FullName + " invalid: "
                    + e1, e1);
            }

            Config = new RepositoryConfig(userConfig, (FileInfo)FS.resolve(gitDirectory, "config"));

            WorkingDirectory = gitDirectory.Parent;

            if (_objectDatabase.exists())
            {
                try
                {
                    Config.load();
                }
                catch (ConfigInvalidException e1)
                {
                    throw new IOException("Unknown repository format", e1);
                }

                string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    throw new IOException("Unknown repository format \""
                                          + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
        }