mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccoll...@apache.org
Subject [1/2] incubator-mynewt-newt git commit: newt - The repo compat. check was wrong.
Date Wed, 14 Dec 2016 20:20:10 GMT
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 5bc0923e4 -> e7971e974


newt - The repo compat. check was wrong.

The previous method of checking if the user has a recent-enough version
of each repo wasn't strict enough.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/7ceb81f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/7ceb81f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/7ceb81f1

Branch: refs/heads/develop
Commit: 7ceb81f11eeef3a4141c219297b0e16328ab9df9
Parents: 5bc0923
Author: Christopher Collins <ccollins@apache.org>
Authored: Wed Dec 14 12:17:26 2016 -0800
Committer: Christopher Collins <ccollins@apache.org>
Committed: Wed Dec 14 12:17:26 2016 -0800

----------------------------------------------------------------------
 newt/repo/repo.go | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/7ceb81f1/newt/repo/repo.go
----------------------------------------------------------------------
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index fe4a5bc..c02d6e6 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -577,21 +577,32 @@ func (r *Repo) HasMinCommit() (bool, error) {
 
 	cmd := []string{
 		"git",
-		"rev-list",
-		r.minCommit.Hash + "..HEAD",
+		"merge-base",
+		r.minCommit.Hash,
+		"HEAD",
 	}
-
-	o, err := util.ShellCommand(cmd, nil)
+	mergeBase, err := util.ShellCommand(cmd, nil)
 	if err != nil {
 		return false, util.ChildNewtError(err)
 	}
-
-	if len(o) == 0 {
+	if len(mergeBase) == 0 {
 		// No output means the commit does not exist in the current branch.
 		return false, nil
 	}
 
-	return true, nil
+	cmd = []string{
+		"git",
+		"rev-parse",
+		"--verify",
+		r.minCommit.Hash,
+	}
+	revParse, err := util.ShellCommand(cmd, nil)
+	if err != nil {
+		return false, util.ChildNewtError(err)
+	}
+
+	// The commit exists in HEAD if the two commands produced identical output.
+	return string(mergeBase) == string(revParse), nil
 }
 
 func (r *Repo) Init(repoName string, rversreq string, d downloader.Downloader) error {


Mime
View raw message