From 884b16c882863f1eb5144a4bf7d1739bdf99a271 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 13 Dec 2018 12:43:27 +0200 Subject: Factor git-status code from bdep-ci to git_status() --- bdep/git.hxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'bdep/git.hxx') diff --git a/bdep/git.hxx b/bdep/git.hxx index 8ef9397..91a9fd9 100644 --- a/bdep/git.hxx +++ b/bdep/git.hxx @@ -71,6 +71,28 @@ namespace bdep const char* opt = nullptr, const char* what = "remote repository URL", const char* cfg = nullptr); + + // Repository status. + // + struct git_repository_status + { + string commit; // Current commit or empty if initial. + string branch; // Local branch or empty if detached. + string upstream; // Upstream in / form or empty if not set. + + // Note that unmerged and untracked entries are considered as unstaged. + // + bool staged = false; // Repository has staged changes. + bool unstaged = false; // Repository has unstaged changes. + + // Note that we can be both ahead and behind. + // + bool ahead = false; // Local branch is ahead of upstream. + bool behind = false; // Local branch is behind of upstream. + }; + + git_repository_status + git_status (const dir_path& repo); } #include -- cgit v1.1