~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/NGit/NGit/BaseRepositoryBuilder.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
                                [4] == 'i' && @ref[5] == 'r' && @ref[6] == ':' && @ref[7] == ' ';
78
78
                }
79
79
 
 
80
                //
 
81
                //
 
82
                //
 
83
                //
 
84
                //
 
85
                //
 
86
                //
 
87
                /// <exception cref="System.IO.IOException"></exception>
 
88
                private static FilePath GetSymRef(FilePath workTree, FilePath dotGit)
 
89
                {
 
90
                        byte[] content = IOUtil.ReadFully(dotGit);
 
91
                        if (!IsSymRef(content))
 
92
                        {
 
93
                                throw new IOException(MessageFormat.Format(JGitText.Get().invalidGitdirRef, dotGit
 
94
                                        .GetAbsolutePath()));
 
95
                        }
 
96
                        int pathStart = 8;
 
97
                        int lineEnd = RawParseUtils.NextLF(content, pathStart);
 
98
                        if (content[lineEnd - 1] == '\n')
 
99
                        {
 
100
                                lineEnd--;
 
101
                        }
 
102
                        if (lineEnd == pathStart)
 
103
                        {
 
104
                                throw new IOException(MessageFormat.Format(JGitText.Get().invalidGitdirRef, dotGit
 
105
                                        .GetAbsolutePath()));
 
106
                        }
 
107
                        string gitdirPath = RawParseUtils.Decode(content, pathStart, lineEnd);
 
108
                        FilePath gitdirFile = new FilePath(gitdirPath);
 
109
                        if (gitdirFile.IsAbsolute())
 
110
                        {
 
111
                                return gitdirFile;
 
112
                        }
 
113
                        else
 
114
                        {
 
115
                                return new FilePath(workTree, gitdirPath).GetCanonicalFile();
 
116
                        }
 
117
                }
 
118
 
80
119
                private FS fs;
81
120
 
82
121
                private FilePath gitDir;
105
144
                /// <remarks>Configuration file of target repository, lazily loaded if required.</remarks>
106
145
                private Config config;
107
146
 
108
 
                //
109
 
                //
110
 
                //
111
 
                //
112
 
                //
113
 
                //
114
 
                //
115
147
                /// <summary>Set the file system abstraction needed by this repository.</summary>
116
148
                /// <remarks>Set the file system abstraction needed by this repository.</remarks>
117
149
                /// <param name="fs">the abstraction.</param>
660
692
                                                SetGitDir(dir);
661
693
                                                break;
662
694
                                        }
 
695
                                        else
 
696
                                        {
 
697
                                                if (dir.IsFile())
 
698
                                                {
 
699
                                                        try
 
700
                                                        {
 
701
                                                                SetGitDir(GetSymRef(current, dir));
 
702
                                                                break;
 
703
                                                        }
 
704
                                                        catch (IOException)
 
705
                                                        {
 
706
                                                        }
 
707
                                                }
 
708
                                        }
 
709
                                        // Continue searching if gitdir ref isn't found
663
710
                                        current = current.GetParentFile();
664
711
                                        if (current != null && ceilingDirectories != null && ceilingDirectories.Contains(
665
712
                                                current))
755
802
                                }
756
803
                                else
757
804
                                {
758
 
                                        byte[] content = IOUtil.ReadFully(dotGit);
759
 
                                        if (!IsSymRef(content))
760
 
                                        {
761
 
                                                throw new IOException(MessageFormat.Format(JGitText.Get().invalidGitdirRef, dotGit
762
 
                                                        .GetAbsolutePath()));
763
 
                                        }
764
 
                                        int pathStart = 8;
765
 
                                        int lineEnd = RawParseUtils.NextLF(content, pathStart);
766
 
                                        if (content[lineEnd - 1] == '\n')
767
 
                                        {
768
 
                                                lineEnd--;
769
 
                                        }
770
 
                                        if (lineEnd == pathStart)
771
 
                                        {
772
 
                                                throw new IOException(MessageFormat.Format(JGitText.Get().invalidGitdirRef, dotGit
773
 
                                                        .GetAbsolutePath()));
774
 
                                        }
775
 
                                        string gitdirPath = RawParseUtils.Decode(content, pathStart, lineEnd);
776
 
                                        FilePath gitdirFile = new FilePath(gitdirPath);
777
 
                                        if (gitdirFile.IsAbsolute())
778
 
                                        {
779
 
                                                SetGitDir(gitdirFile);
780
 
                                        }
781
 
                                        else
782
 
                                        {
783
 
                                                SetGitDir(new FilePath(GetWorkTree(), gitdirPath).GetCanonicalFile());
784
 
                                        }
 
805
                                        SetGitDir(GetSymRef(GetWorkTree(), dotGit));
785
806
                                }
786
807
                        }
787
808
                }