[PATCH 1/2] fix: correctly handle upstream ff merges on fetch

5 views
Skip to first unread message

Felix Moessbauer

unread,
Jun 13, 2024, 3:04:57 AMJun 13
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer, Jan Kircher
In case both branch and commit are specified, kas checks if the commit
is contained in the branch. Further, only when a ref was not present in
the local clone, a fetch from remote was executed. This logic however
breaks on upstream fast-forward merges, as these do not create a new
commit id, but instead just move the branch head.

This commit adds a check if we also have the requested commit sha on the
requested branch locally and if not continues to the fetching step
(instead of the short circuit).

Fixes: #122
Reported-by: Jan Kircher <jan.k...@leica-microsystems.com>
Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
kas/repos.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/kas/repos.py b/kas/repos.py
index fd0bc3817..262c44808 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -337,7 +337,16 @@ class RepoImpl(Repo):
self.commit or self.tag or self.branch
or self.refspec,
output.strip())
- return retc
+ # if branch is specified, check if it contains the commit
+ # also in our local clone
+ depth = get_context().repo_clone_depth
+ if self.branch and self.commit and not depth:
+ (_, output) = await run_cmd_async(
+ self.branch_contains_ref(), cwd=self.path, fail=False)
+ if output.strip():
+ return retc
+ else:
+ return retc

# Try to fetch if commit/tag/branch/refspec is missing or if --update
# argument was passed
--
2.39.2

Reply all
Reply to author
Forward
0 new messages