public static GitStatusSet GetStatusSet(string wcRoot)
        {
            // Prevent multiple GetStatusSet calls from running in parallel
            lock (getStatusLock) {
                GitStatusSet statusSet;
                // Don't hold statusSetDict during the whole operation; we don't want
                // to slow down other threads calling ClearCachedStatus()
                lock (statusSetDict) {
                    foreach (var pair in statusSetDict)
                    {
                        if (FileUtility.IsEqualFileName(pair.Key, wcRoot))
                        {
                            return(pair.Value);
                        }
                    }
                }

                statusSet = new GitStatusSet();
                GitGetFiles(wcRoot, statusSet);
                GitGetStatus(wcRoot, statusSet);
                lock (statusSetDict) {
                    statusSetDict.Add(new KeyValuePair <string, GitStatusSet>(wcRoot, statusSet));
                }
                return(statusSet);
            }
        }
        static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
        {
            string git = Git.FindGit();

            if (git == null)
            {
                return;
            }

            ProcessRunner runner = new ProcessRunner();

            runner.WorkingDirectory          = wcRoot;
            runner.LogStandardOutputAndError = false;
            runner.OutputLineReceived       += delegate(object sender, LineReceivedEventArgs e) {
                if (!string.IsNullOrEmpty(e.Line))
                {
                    statusSet.AddEntry(e.Line, GitStatus.OK);
                }
            };

            string command   = "ls-files";
            bool   hasErrors = false;

            runner.ErrorLineReceived += delegate(object sender, LineReceivedEventArgs e) {
                if (!hasErrors)
                {
                    hasErrors = true;
                    GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command);
                }
                GitMessageView.AppendLine(e.Line);
            };
            runner.Start(git, command);
            runner.WaitForExit();
        }
Exemple #3
0
		static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
		{
			string git = Git.FindGit();
			if (git == null)
				return;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = wcRoot;
			runner.LogStandardOutputAndError = false;
			runner.OutputLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!string.IsNullOrEmpty(e.Line)) {
					statusSet.AddEntry(e.Line, GitStatus.OK);
				}
			};
			
			string command = "ls-files";
			bool hasErrors = false;
			runner.ErrorLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!hasErrors) {
					hasErrors = true;
					GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command);
				}
				GitMessageView.AppendLine(e.Line);
			};
			runner.Start(git, command);
			runner.WaitForExit();
		}
Exemple #4
0
		static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
		{
			string git = Git.FindGit();
			if (git == null)
				return;
			
			using (ProcessRunner runner = new ProcessRunner()) {
				runner.WorkingDirectory = DirectoryName.Create(wcRoot);
				runner.RedirectStandardOutput = true;
				runner.RedirectStandardError = true;
				runner.Start(git, "ls-files");
				
				// process stderr in background
				var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);
				// process stderr on current thread:
				using (var reader = runner.OpenStandardOutputReader()) {
					string line;
					while ((line = reader.ReadLine()) != null) {
						if (line.Length > 0) {
							statusSet.AddEntry(line, GitStatus.OK);
						}
					}
				}
				errorTask.Wait();
			}
		}
Exemple #5
0
        static void GitGetFiles(string wcRoot, GitStatusSet statusSet)
        {
            string git = Git.FindGit();

            if (git == null)
            {
                return;
            }

            using (ProcessRunner runner = new ProcessRunner()) {
                runner.WorkingDirectory       = DirectoryName.Create(wcRoot);
                runner.RedirectStandardOutput = true;
                runner.RedirectStandardError  = true;
                runner.Start(git, "ls-files");

                // process stderr in background
                var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);
                // process stderr on current thread:
                using (var reader = runner.OpenStandardOutputReader()) {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.Length > 0)
                        {
                            statusSet.AddEntry(line, GitStatus.OK);
                        }
                    }
                }
                errorTask.Wait();
            }
        }
        public static GitStatus GetFileStatus(string fileName)
        {
            string wcroot = Git.FindWorkingCopyRoot(fileName);

            if (wcroot == null)
            {
                return(GitStatus.None);
            }
            GitStatusSet gss = GetStatusSet(wcroot);

            return(gss.GetStatus(Git.AdaptFileNameNoQuotes(wcroot, fileName)));
        }
		public static GitStatusSet GetStatusSet(string wcRoot)
		{
			lock (statusSetDict) {
				GitStatusSet statusSet;
				foreach (var pair in statusSetDict) {
					if (FileUtility.IsEqualFileName(pair.Key, wcRoot))
						return pair.Value;
				}
				
				statusSet = new GitStatusSet();
				GitGetFiles(wcRoot, statusSet);
				GitGetStatus(wcRoot, statusSet);
				statusSetDict.Add(new KeyValuePair<string, GitStatusSet>(wcRoot, statusSet));
				return statusSet;
			}
		}
        static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
        {
            string git = Git.FindGit();

            if (git == null)
            {
                return;
            }

            string command   = "status --porcelain --untracked-files=no";
            bool   hasErrors = false;

            ProcessRunner runner = new ProcessRunner();

            runner.WorkingDirectory          = wcRoot;
            runner.LogStandardOutputAndError = false;
            runner.OutputLineReceived       += delegate(object sender, LineReceivedEventArgs e) {
                if (!string.IsNullOrEmpty(e.Line))
                {
                    Match m = statusParseRegex.Match(e.Line);
                    if (m.Success)
                    {
                        statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
                    }
                    else
                    {
                        if (!hasErrors)
                        {
                            // in front of first output line, print the command line we invoked
                            hasErrors = true;
                            GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command);
                        }
                        GitMessageView.AppendLine("unknown output: " + e.Line);
                    }
                }
            };
            runner.ErrorLineReceived += delegate(object sender, LineReceivedEventArgs e) {
                if (!hasErrors)
                {
                    hasErrors = true;
                    GitMessageView.AppendLine(runner.WorkingDirectory + "> git " + command);
                }
                GitMessageView.AppendLine(e.Line);
            };
            runner.Start(git, command);
            runner.WaitForExit();
        }
        public static GitStatusSet GetStatusSet(string wcRoot)
        {
            lock (statusSetDict) {
                GitStatusSet statusSet;
                foreach (var pair in statusSetDict)
                {
                    if (FileUtility.IsEqualFileName(pair.Key, wcRoot))
                    {
                        return(pair.Value);
                    }
                }

                statusSet = new GitStatusSet();
                GitGetFiles(wcRoot, statusSet);
                GitGetStatus(wcRoot, statusSet);
                statusSetDict.Add(new KeyValuePair <string, GitStatusSet>(wcRoot, statusSet));
                return(statusSet);
            }
        }
Exemple #10
0
        static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
        {
            string git = Git.FindGit();

            if (git == null)
            {
                return;
            }

            ProcessRunner runner = new ProcessRunner();

            runner.WorkingDirectory       = DirectoryName.Create(wcRoot);
            runner.RedirectStandardOutput = true;
            runner.RedirectStandardError  = true;
            runner.Start(git, "status", "--porcelain", "--untracked-files=no");
            // process stderr in background
            var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);

            // process stderr on current thread:
            using (var reader = runner.OpenStandardOutputReader()) {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        Match m = statusParseRegex.Match(line);
                        if (m.Success)
                        {
                            statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
                        }
                        else
                        {
                            GitMessageView.AppendLine("unknown git status output: " + line);
                        }
                    }
                }
            }
            errorTask.Wait();
        }
        public GitStatus AddEntry(string path, GitStatus status)
        {
            if (string.IsNullOrEmpty(path) || path == ".")
            {
                this.status = status;
                return(status);
            }
            if (entries == null)
            {
                entries = new Dictionary <string, GitStatusSet>();
            }
            string entry;
            string subpath;
            int    pos = path.IndexOf('/');

            if (pos < 0)
            {
                entry   = path;
                subpath = null;
            }
            else
            {
                entry   = path.Substring(0, pos);
                subpath = path.Substring(pos + 1);
            }
            GitStatusSet subset;

            if (!entries.TryGetValue(entry, out subset))
            {
                entries[entry] = subset = new GitStatusSet();
            }
            status = subset.AddEntry(subpath, status);
            if (status == GitStatus.Added || status == GitStatus.Deleted || status == GitStatus.Modified)
            {
                this.status = GitStatus.Modified;
            }
            return(this.status);
        }
Exemple #12
0
		public static GitStatusSet GetStatusSet(string wcRoot)
		{
			// Prevent multiple GetStatusSet calls from running in parallel
			lock (getStatusLock) {
				GitStatusSet statusSet;
				// Don't hold statusSetDict during the whole operation; we don't want
				// to slow down other threads calling ClearCachedStatus()
				lock (statusSetDict) {
					foreach (var pair in statusSetDict) {
						if (FileUtility.IsEqualFileName(pair.Key, wcRoot))
							return pair.Value;
					}
				}
				
				statusSet = new GitStatusSet();
				GitGetFiles(wcRoot, statusSet);
				GitGetStatus(wcRoot, statusSet);
				lock (statusSetDict) {
					statusSetDict.Add(new KeyValuePair<string, GitStatusSet>(wcRoot, statusSet));
				}
				return statusSet;
			}
		}
		static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
		{
			string command = "git status --porcelain --untracked-files=no";
			bool hasErrors = false;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = wcRoot;
			runner.LogStandardOutputAndError = false;
			runner.OutputLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!string.IsNullOrEmpty(e.Line)) {
					Match m = statusParseRegex.Match(e.Line);
					if (m.Success) {
						statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
					} else {
						if (!hasErrors) {
							hasErrors = true;
							GitMessageView.AppendLine(runner.WorkingDirectory + "> " + command);
						}
						GitMessageView.AppendLine("unknown output: " + e.Line);
					}
				}
			};
			runner.ErrorLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!hasErrors) {
					hasErrors = true;
					GitMessageView.AppendLine(runner.WorkingDirectory + "> " + command);
				}
				GitMessageView.AppendLine(e.Line);
			};
			runner.Start("cmd", "/c " + command);
			runner.WaitForExit();
		}
		public GitStatus AddEntry(string path, GitStatus status)
		{
			if (string.IsNullOrEmpty(path) || path == ".") {
				this.status = status;
				return status;
			}
			if (entries == null)
				entries = new Dictionary<string, GitStatusSet>();
			string entry;
			string subpath;
			int pos = path.IndexOf('/');
			if (pos < 0) {
				entry = path;
				subpath = null;
			} else {
				entry = path.Substring(0, pos);
				subpath = path.Substring(pos + 1);
			}
			GitStatusSet subset;
			if (!entries.TryGetValue(entry, out subset))
				entries[entry] = subset = new GitStatusSet();
			status = subset.AddEntry(subpath, status);
			if (status == GitStatus.Added || status == GitStatus.Deleted || status == GitStatus.Modified) {
				this.status = GitStatus.Modified;
			}
			return this.status;
		}
		static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
		{
			string command = "git status --porcelain --untracked-files=no";
			bool hasErrors = false;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = wcRoot;
			runner.LogStandardOutputAndError = false;
			string commandPrompt = wcRoot + ">@"; // C:\work\SD>@git.exe %*
			runner.OutputLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!string.IsNullOrEmpty(e.Line)) {
					Match m = statusParseRegex.Match(e.Line);
					if (m.Success) {
						statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
					} else if (!e.Line.StartsWith(commandPrompt, StringComparison.Ordinal)) {
						// Suppress "unknown output" produced by git.cmd when git is installed
						// in the PATH but the git unix tools aren't
						
						if (!hasErrors) {
							// in front of first output line, print the command line we invoked
							hasErrors = true;
							GitMessageView.AppendLine(runner.WorkingDirectory + "> " + command);
						}
						GitMessageView.AppendLine("unknown output: " + e.Line);
					}
				}
			};
			runner.ErrorLineReceived += delegate(object sender, LineReceivedEventArgs e) {
				if (!hasErrors) {
					hasErrors = true;
					GitMessageView.AppendLine(runner.WorkingDirectory + "> " + command);
				}
				GitMessageView.AppendLine(e.Line);
			};
			runner.Start("cmd", "/c " + command);
			runner.WaitForExit();
		}
Exemple #16
0
		static void GitGetStatus(string wcRoot, GitStatusSet statusSet)
		{
			string git = Git.FindGit();
			if (git == null)
				return;
			
			ProcessRunner runner = new ProcessRunner();
			runner.WorkingDirectory = DirectoryName.Create(wcRoot);
			runner.RedirectStandardOutput = true;
			runner.RedirectStandardError = true;
			runner.Start(git, "status", "--porcelain", "--untracked-files=no");
			// process stderr in background
			var errorTask = DisplayErrorStreamAsync(runner, GitMessageView.Category);
			// process stderr on current thread:
			using (var reader = runner.OpenStandardOutputReader()) {
				string line;
				while ((line = reader.ReadLine()) != null) {
					if (line.Length > 0) {
						Match m = statusParseRegex.Match(line);
						if (m.Success) {
							statusSet.AddEntry(m.Groups[2].Value, StatusFromText(m.Groups[1].Value));
						} else {
							GitMessageView.AppendLine("unknown git status output: " + line);
						}
					}
				}
			}
			errorTask.Wait();
		}