コード例 #1
0
ファイル: Repository.cs プロジェクト: drothmaler/GitSharp
        /// <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();
            }
        }
コード例 #2
0
ファイル: CoreConfig.cs プロジェクト: mneedham/GitSharp
 public CoreConfig(RepositoryConfig repoConfig)
 {
     this.Compression = repoConfig.GetInt("core", "compression", Constants.DefaultCompression);
     this.PackIndexVersion = repoConfig.GetInt("pack", "indexversion", 0);
 }
コード例 #3
0
ファイル: RepositoryTestCase.cs プロジェクト: ArildF/GitSharp
 public void setUserGitConfig(RepositoryConfig userGitConfig)
 {
     this.userGitConfig = userGitConfig;
 }
コード例 #4
0
ファイル: RepositoryTestCase.cs プロジェクト: ArildF/GitSharp
        public virtual void setUp()
        {
            //super.setUp();
            configure();
            string name = GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
            recursiveDelete(trashParent, true, name, false); // Cleanup old failed stuff
            trash = new DirectoryInfo(trashParent + "/trash" + DateTime.Now.Ticks + "." + (testcount++));
            trash_git = new DirectoryInfo(trash + "/.git");

            var userGitConfigFile = new FileInfo(trash_git + "/usergitconfig").FullName;
            var userGitConfig = new RepositoryConfig(null, new FileInfo(userGitConfigFile));
            fakeSystemReader.setUserGitConfig(userGitConfig);

            db = new Repository(trash_git);
            db.Create();

            string[] packs = {
                "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
                "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371",
                "pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
                "pack-546ff360fe3488adb20860ce3436a2d6373d2796",
                "pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
                "pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
            };
            DirectoryInfo packDir = new DirectoryInfo(db.ObjectsDirectory + "/pack");

            foreach (var packname in packs)
            {
                new FileInfo("Resources/" + packname + ".pack").CopyTo(packDir + "/" + packname + ".pack", true);
                new FileInfo("Resources/" + packname + ".idx").CopyTo(packDir + "/" + packname + ".idx", true);
            }

            new FileInfo("Resources/packed-refs").CopyTo(trash_git.FullName + "/packed-refs", true);

            fakeSystemReader.values.Clear();
            fakeSystemReader.values[Constants.OS_USER_NAME_KEY] = Constants.OS_USER_NAME_KEY;
            fakeSystemReader.values[Constants.GIT_AUTHOR_NAME_KEY] = Constants.GIT_AUTHOR_NAME_KEY;
            fakeSystemReader.values[Constants.GIT_AUTHOR_EMAIL_KEY] = Constants.GIT_AUTHOR_EMAIL_KEY;
            fakeSystemReader.values[Constants.GIT_COMMITTER_NAME_KEY] = Constants.GIT_COMMITTER_NAME_KEY;
            fakeSystemReader.values[Constants.GIT_COMMITTER_EMAIL_KEY] = Constants.GIT_COMMITTER_EMAIL_KEY;
        }
コード例 #5
0
ファイル: WindowCachConfig.cs プロジェクト: ArildF/GitSharp
 /**
  * Update properties by setting fields from the configuration.
  * <p>
  * If a property is not defined in the configuration, then it is left
  * unmodified.
  *
  * @param rc configuration to read properties from.
  */
 public void fromConfig( RepositoryConfig rc)
 {
     setPackedGitOpenFiles(rc.GetInt("core", null, "packedgitopenfiles", getPackedGitOpenFiles()));
     setPackedGitLimit(rc.GetInt("core", null, "packedgitlimit", getPackedGitLimit()));
     setPackedGitWindowSize(rc.GetInt("core", null, "packedgitwindowsize", getPackedGitWindowSize()));
     setPackedGitMMAP(rc.GetBoolean("core", null, "packedgitmmap", isPackedGitMMAP()));
     setDeltaBaseCacheLimit(rc.GetInt("core", null, "deltabasecachelimit", getDeltaBaseCacheLimit()));
 }
コード例 #6
0
ファイル: Repository.cs プロジェクト: Squelch/GitSharp
        /**
         * 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\".");
                }
            }
        }