summaryrefslogtreecommitdiffstats
path: root/git_superproject.py
diff options
context:
space:
mode:
authorRaman Tenneti <rtenneti@google.com>2021-02-08 13:27:41 -0800
committerRaman Tenneti <rtenneti@google.com>2021-02-08 23:43:34 +0000
commitce64e3d47b97e54cc7fac3d7577cd53f1857de26 (patch)
tree54d26423d4356bb54160cafd4686fcce19f2fa87 /git_superproject.py
parent8d43dea6ea4b7d1664632e555e207f617e54657b (diff)
downloadgit-repo-ce64e3d47b97e54cc7fac3d7577cd53f1857de26.tar.gz
superproject: Pass branch to git ls-tree.
Tested the code with the following commands. $ ./run_tests -v Bug: [google internal] b/179702819 Bug: https://crbug.com/gerrit/13709 Bug: https://crbug.com/gerrit/13707 Tested-by: Raman Tenneti <rtenneti@google.com> Change-Id: I7d2b609ac2f927c94701757aa1502ba236afe7c0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296342 Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_superproject.py')
-rw-r--r--git_superproject.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/git_superproject.py b/git_superproject.py
index 57a3a533..378ede25 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -112,11 +112,14 @@ class Superproject(object):
112 return False 112 return False
113 return True 113 return True
114 114
115 def _LsTree(self): 115 def _LsTree(self, branch='HEAD'):
116 """Returns the data from 'git ls-tree -r HEAD'. 116 """Returns the data from 'git ls-tree -r <branch>'.
117 117
118 Works only in git repositories. 118 Works only in git repositories.
119 119
120 Args:
121 branch: The branchname to be passed as argument to git ls-tree.
122
120 Returns: 123 Returns:
121 data: data returned from 'git ls-tree -r HEAD' instead of None. 124 data: data returned from 'git ls-tree -r HEAD' instead of None.
122 """ 125 """
@@ -125,7 +128,8 @@ class Superproject(object):
125 file=sys.stderr) 128 file=sys.stderr)
126 return None 129 return None
127 data = None 130 data = None
128 cmd = ['ls-tree', '-z', '-r', 'HEAD'] 131 cmd = ['ls-tree', '-z', '-r', branch]
132
129 p = GitCommand(None, 133 p = GitCommand(None,
130 cmd, 134 cmd,
131 cwd=self._work_git, 135 cwd=self._work_git,
@@ -165,7 +169,7 @@ class Superproject(object):
165 if not self._Clone(url, branch): 169 if not self._Clone(url, branch):
166 raise GitError('git clone failed for url: %s' % url) 170 raise GitError('git clone failed for url: %s' % url)
167 171
168 data = self._LsTree() 172 data = self._LsTree(branch)
169 if not data: 173 if not data:
170 raise GitError('git ls-tree failed for url: %s' % url) 174 raise GitError('git ls-tree failed for url: %s' % url)
171 175