public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Belisko Marek <marek.belisko@gmail.com>,
	Henning Schild <henning.schild@siemens.com>
Subject: [PATCH v2] Create from local branch before applying patches with git
Date: Sat, 21 Sep 2019 13:07:06 +0200	[thread overview]
Message-ID: <05b54135-7bbb-3093-274d-33b0bc3b82d8@siemens.com> (raw)

From: Jan Kiszka <jan.kiszka@siemens.com>

If refspec is pointing to an upstream branch name, the checkout for a
second run will not reset a repo back to the upstream commit. That is
because we applied the repo patches to a local branch that carries the
name of the upstream one.

Fix that by switching to local branch prior to applying any patches.

Reported-by: Belisko Marek <marek.belisko@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Changes in v2:
 - rebased over next
 - add hg support
 - use local branch also with git

 kas/repos.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/kas/repos.py b/kas/repos.py
index 4f74f4b..113a67f 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -247,9 +247,14 @@ class RepoImpl(Repo):
         """
             Applies patches to a repository asynchronously.
         """
-        if self.operations_disabled:
+        if self.operations_disabled or not self._patches:
             return 0
 
+        (retc, _) = yield from run_cmd_async(self.prepare_patches_cmd(),
+                                             cwd=self.path)
+        if retc:
+            return retc
+
         my_patches = []
 
         for patch in self._patches:
@@ -359,6 +364,9 @@ class GitRepo(RepoImpl):
         return ['git', 'checkout', '-q',
                 '{refspec}'.format(refspec=self.refspec)]
 
+    def prepare_patches_cmd(self):
+        return ['git', 'checkout', '-q', '-B', 'local-kas-patches']
+
     def apply_patches_file_cmd(self, path):
         return ['git', 'apply', path]
 
@@ -395,6 +403,9 @@ class MercurialRepo(RepoImpl):
     def checkout_cmd(self):
         return ['hg', 'checkout', '{refspec}'.format(refspec=self.refspec)]
 
+    def prepare_patches_cmd(self):
+        return ['hg', 'branch', '-f', 'local-kas-patches']
+
     def apply_patches_file_cmd(self, path):
         return ['hg', 'import', '--no-commit', path]
 
-- 
2.16.4


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

             reply	other threads:[~2019-09-21 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-21 11:07 Jan Kiszka [this message]
2019-09-21 11:07 ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05b54135-7bbb-3093-274d-33b0bc3b82d8@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=marek.belisko@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox