Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "openembedded-core@lists.openembedded.org"
	<openembedded-core@lists.openembedded.org>,
	"alex.kanavin@gmail.com" <alex.kanavin@gmail.com>,
	"paul@pbarker.dev" <paul@pbarker.dev>
Cc: Troy Lee <troy_lee@aspeedtech.com>, Jamin Lin <jamin_lin@aspeedtech.com>
Subject: [PATCH v3 2/5] oe/patch: Skip commitIgnored when nothing is actually staged
Date: Thu, 23 Jul 2026 08:11:21 +0000	[thread overview]
Message-ID: <20260723081118.1558249-3-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260723081118.1558249-1-jamin_lin@aspeedtech.com>

patch.bbclass's patch_task_postfunc calls GitApplyTree.commitIgnored()
whenever 'git status --porcelain .' reports the source tree as dirty
after do_patch, to snapshot those changes into the devtool tracking
repo with 'git add' + 'git commit'.

A path can be reported as dirty by git status purely because it is a
submodule (or an unregistered embedded git repo) that itself has
modified or untracked content - for example a recipe with multiple git
SRC_URI entries where one destsuffix places a repo inside another
repo's own working tree. The outer repo's tracked commit hash for that
submodule hasn't changed, so 'git add' has nothing new to stage for it,
and git refuses to fold the submodule's own dirty state into a plain
commit without it being resolved first:

  $ git commit -m ... --no-verify --no-gpg-sign
  Changes not staged for commit:
    (commit or discard the untracked or modified content in submodules)
          modified:   level1 (modified content)
  no changes added to commit (use "git add" and/or "git commit -a")

'git commit' then exits non-zero with nothing to commit, and
commitIgnored() propagates that failure straight up, taking the whole
do_patch task down with it.

Fix by checking 'git diff --cached --name-only' after 'git add': if
nothing was actually staged, there is nothing meaningful to snapshot,
so skip the commit (and the note it would otherwise add) instead of
failing.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 meta/lib/oe/patch.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 1d50e83ab7..944dde1e03 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -516,6 +516,18 @@ class GitApplyTree(PatchTree):
     def commitIgnored(subject, dir=None, files=None, d=None):
         if files:
             runcmd(['git', 'add'] + files, dir)
+
+        # 'git add' can leave nothing actually staged even though the caller
+        # saw a dirty status: a path can show as modified purely because it
+        # is a submodule/embedded git repository with modified or untracked
+        # content of its own (e.g. a further nested git repo from another
+        # destsuffix SRC_URI entry) - git refuses to record that via a plain
+        # 'git add'/'git commit' without resolving the submodule's own state,
+        # so the commit below would fail with "no changes added to commit".
+        # Skip the commit if there is nothing actually staged.
+        if not runcmd(['git', 'diff', '--cached', '--name-only'], dir).strip():
+            return
+
         cmd = ["git"]
         GitApplyTree.gitCommandUserOptions(cmd, d=d)
         cmd += ["commit", "-m", subject, "--no-verify", "--no-gpg-sign"]
-- 
2.43.0


  parent reply	other threads:[~2026-07-23  8:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  8:11 [PATCH v3 0/5] devtool: fix standalone clone conversion for nested git repos Jamin Lin
2026-07-23  8:11 ` [PATCH v3 1/5] devtool: Detect nested git repos before the initial workspace commit Jamin Lin
2026-07-23  8:11 ` Jamin Lin [this message]
2026-07-23  8:11 ` [PATCH v3 3/5] devtool-source: Convert nested git SRC_URI destsuffix repos to standalone clones Jamin Lin
2026-07-23  8:11 ` [PATCH v3 4/5] meta-selftest: Add devtool-test-multi-destsuffix recipe Jamin Lin
2026-07-23  8:11 ` [PATCH v3 5/5] oeqa/selftest/devtool: Add test for multiple nested git destsuffix repos Jamin Lin

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=20260723081118.1558249-3-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=alex.kanavin@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul@pbarker.dev \
    --cc=troy_lee@aspeedtech.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