Skip to contentSkip to conversation

fetch/git: Add an 'update' unpack mode to the fetchers (git only for now)

PATCH Richard Purdie 3 participants 7 messages Mar 19 – Mar 20 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 11 lines · Richard Purdie via lists.openembedded.org
(quoted diff) +0 -0
@@ -714,6 +724,32 @@ class Git(FetchMethod):

         if not source_found:
             raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url)

+        if update_mode:
+            if ud.shallow:
+                bb.fetch2.UnpackError("Can't update shallow clones checkouts without network access, not supported.", ud.url) +
+            output = runfetchcmd("%s status --porcelain" % (ud.basecmd), d, workdir=destdir)
+            if output:
+                raise bb.fetch2.UnpackError("Repository at %s has uncommitted changes, unable to update:\n%s" % (destdir, output), ud.url)

There is a bit of a debate on this line between Adrian and myself. Should we use:

git status --porcelain

or

git status --untracked-files=no --porcelain

?

The difference is untracked files. The rebase will abort if an untracked file is changed by the changes involved in the rebase so it will allow untracked files to be untouched and should be safe.

I had thought we should exercise caution but perhaps that is ok...

Any other opinions?

Cheers,

Richard

#2 lore raw
Quoted 11 lines · Richard Purdie

There is a bit of a debate on this line between Adrian and myself. Should we use:

git status --porcelain

or

git status --untracked-files=no --porcelain

?

Quoted 7 lines

The difference is untracked files. The rebase will abort if an untracked file is changed by the changes involved in the rebase so it will allow untracked files to be untouched and should be safe.

I had thought we should exercise caution but perhaps that is ok...

Any other opinions?

Yes, actually :) The bitbake-setup patch I posted pre-empts this check entirely, by first stashing away everything uncommitted, including untracked files, with a warning to the user. I want to minimize various aborts and errors on updates which will cause them to half-complete and leave the checkouts in an inconsistent state. I'd rather stash it, make that clear, and have the user handle the un-stashing and any needed conflict resolution after the fact.

Alex

#3 lore raw
Quoted 21 lines · Alexander Kanavin
Quoted 11 lines · Richard Purdie

There is a bit of a debate on this line between Adrian and myself. Should we use:

git status --porcelain

or

git status --untracked-files=no --porcelain

?

Quoted 7 lines

The difference is untracked files. The rebase will abort if an untracked file is changed by the changes involved in the rebase so it will allow untracked files to be untouched and should be safe.

I had thought we should exercise caution but perhaps that is ok...

Any other opinions?

Quoted 7 lines

Yes, actually :) The bitbake-setup patch I posted pre-empts this check entirely, by first stashing away everything uncommitted, including untracked files, with a warning to the user. I want to minimize various aborts and errors on updates which will cause them to half-complete and leave the checkouts in an inconsistent state. I'd rather stash it, make that clear, and have the user handle the un-stashing and any needed conflict resolution after the fact.

I was looking at your patch and I'm not 100% convinced about this. Personally, if I have things lying around the tree I've forgotten about, I'd prefer it to just error out and make me fix it, then allow the rebase to happen.

Stashing it make it "disappear" and would probably confuse me more if I miss the message about it doing that...

Cheers,

Richard

#4 lore raw
Quoted 34 lines · Richard Purdie via lists.openembedded.org
Quoted 24 lines · Alexander Kanavin
Quoted 17 lines · Richard Purdie

There is a bit of a debate on this line between Adrian and myself.
Should we use:

git status --porcelain

or

git status --untracked-files=no --porcelain

?

The difference is untracked files. The rebase will abort if an untracked file is changed by the changes involved in the rebase so it
will allow untracked files to be untouched and should be safe.

Quoted 4 lines

I had thought we should exercise caution but perhaps that is ok...

Any other opinions?

Quoted 8 lines

Yes, actually :) The bitbake-setup patch I posted pre-empts this check
entirely, by first stashing away everything uncommitted, including untracked files, with a warning to the user. I want to minimize various aborts and errors on updates which will cause them to half-complete and leave the checkouts in an inconsistent state. I'd rather stash it, make that clear, and have the user handle the un-stashing and any needed conflict resolution after the fact.

Quoted 9 lines

I was looking at your patch and I'm not 100% convinced about this. Personally, if I have things lying around the tree I've forgotten about, I'd prefer it to just error out and make me fix it, then allow the rebase to happen.

Stashing it make it "disappear" and would probably confuse me more if I
miss the message about it doing that...

Here is my branch which tries to solve this (with --untracked-files=no so far):
https://git.openembedded.org/bitbake-contrib/log/?h=adrianf/bitbake-setup-init-vscode

I guess the rebase with untracked files should be properly handled and tested on the git fetcher level already.

Handling corner cases for bb.fetch2.UnpackError at the bitbake-setup level is complex, and accidental file deletion remains a concern. However, we should pursue an implementation that supports automatic rebasing with untracked files, which are commonplace. Backup-based approaches are cumbersome and should be a last resort.

I tried to achieve this by adding many test cases, at least.

Regards,
Adrian

Quoted 14 lines

Cheers,

Richard

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#19177):
https://lists.openembedded.org/g/bitbake-devel/message/19177
Mute This Topic: https://lists.openembedded.org/mt/118398869/4454582
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]
]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw
In reply to Richard Purdie
Quoted 7 lines · Richard Purdie

I was looking at your patch and I'm not 100% convinced about this. Personally, if I have things lying around the tree I've forgotten about, I'd prefer it to just error out and make me fix it, then allow the rebase to happen.

Stashing it make it "disappear" and would probably confuse me more if I miss the message about it doing that...

Alright. Let's keep things simple for now, and stop the update on any conflict. The workflow will be that the user is expected to resolve the conflict, and run update again. I'll send a revised patch.

Alex

#5 lore raw
In reply to [email protected]
Quoted 7 lines · On Fri, 20 Mar 2026 at 00:55, <[email protected]> wrote:

Here is my branch which tries to solve this (with --untracked-files=no so far):
https://git.openembedded.org/bitbake-contrib/log/?h=adrianf/bitbake-setup-init-vscode

I guess the rebase with untracked files should be properly handled and tested on the git fetcher level already.

Quoted 7 lines

Handling corner cases for bb.fetch2.UnpackError at the bitbake-setup level is complex, and accidental file deletion remains a concern. However, we should pursue an implementation that supports automatic rebasing with untracked files, which are commonplace. Backup-based approaches are cumbersome and should be a last resort.

I tried to achieve this by adding many test cases, at least.

The additional test cases are very useful but we should tread carefully with adding bitbake-setup update logic (e.g. in your patchset it first tries non-destrictuive unpack, then in case of fetcher errors falls back to backup+clean unpack, not giving users a chance to resolve conflicts - I am not sure users are going to like that).

Let's first not try to handle UnpackErrors at all, and implement simple support for unpack_update(). Users would resolve the conflicts and run bitbake-setup update again.

Alex

#6 lore raw
Quoted 26 lines · Alexander Kanavin
Quoted 9 lines · On Fri, 20 Mar 2026 at 00:55, <[email protected]> wrote:

Here is my branch which tries to solve this (with --untracked- files=no
so far):
https://git.openembedded.org/bitbake-contrib/log/?h=adrianf/bitbake-setup-init-vscode

I guess the rebase with untracked files should be properly handled and
tested on the git fetcher level already.

Quoted 8 lines

Handling corner cases for bb.fetch2.UnpackError at the bitbake- setup
level is complex, and accidental file deletion remains a concern. However, we should pursue an implementation that supports automatic rebasing with untracked files, which are commonplace. Backup-based approaches are cumbersome and should be a last resort.

I tried to achieve this by adding many test cases, at least.

The additional test cases are very useful but we should tread carefully with adding bitbake-setup update logic (e.g. in your patchset it first tries non-destrictuive unpack, then in case of fetcher errors falls back to backup+clean unpack, not giving users a chance to resolve conflicts - I am not sure users are going to like that).

Quoted 3 lines

Let's first not try to handle UnpackErrors at all, and implement simple support for unpack_update(). Users would resolve the conflicts and run bitbake-setup update again.

I think this is the best approach. Users are going to want to know about conflicts and will usually have an idea of how they want to resolve them. The point of this update mechanism is to make it easy for the user to pull in changes but allow them to have local changes too, since most of us will end up doing that, I know I do...

Cheers,

Richard