[SDK] "Add New" prevents building

REPRODUCIBILITY (% or how often): 100%
BUILD ID = OS VERSION (Settings > About product): n/a
HARDWARE (XA2, X10, X10 II, …): n/a
UI LANGUAGE: n/a
REGRESSION: (compared to previous public release: Yes, No, ?): Not recent anyway

DESCRIPTION:

Adding a new file in the SDK through the “Add New” menu add it to git unless you opt out.
That borks the automatic versioning and prevents building.

PRECONDITIONS:

Automatic versioning for project/rpm

STEPS TO REPRODUCE:

  1. Add new
  2. Build

EXPECTED RESULT:

Build succeeds

ACTUAL RESULT:

Build fails

ADDITIONAL INFORMATION:

16:34:39: Running steps for project harbour-seaprint...
16:34:39: Starting: "/home/attah/.config/SailfishSDK/libsfdk/build-target-tools/sailfish-os-build-engine/SailfishOS-4.2.0.19EA-aarch64/qmake" /home/attah/repos/harbour-seaprint/harbour-seaprint.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
+ /home/attah/SailfishOS/bin/sfdk qmake /home/attah/repos/harbour-seaprint/harbour-seaprint.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
sfdk: [I] Options from environment: -c target=SailfishOS-4.2.0.19EA-aarch64
error: Entry 'src/curlworker.cpp' not uptodate. Cannot merge.
Cannot save the current worktree state
Fatal: Cannot save state of Git working tree: git-stash failed.
16:34:40: The process "/home/attah/.config/SailfishSDK/libsfdk/build-target-tools/sailfish-os-build-engine/SailfishOS-4.2.0.19EA-aarch64/qmake" exited with code 1.
Error while building/deploying project harbour-seaprint (kit: SailfishOS-4.2.0.19EA-aarch64 (in sailfish-os-build-engine))
When executing step "qmake"
16:34:40: Elapsed time: 00:01.

I wasn’t able to reproduce this. Could you please add more detailed steps to reproduce?

Sure… here it is from a clean env:
Make a new project (not required, but for eliminating other factors), add to git.

git add -u
git commit
git tag 1.0

Set Version to 0 to get automatic tag-based versioning
Screenshot from 2021-09-08 18-39-02

Add new (right-click src in the project hierarchy and choosing new C++ class in this case)

Note how these never-before-seen files show as “not staged” (as opposed to untracked) along with the project file.
Didn’t know that was possible…

Click build, deploy, or run sfdk build.

18:36:14: Running steps for project gitvsntest...
18:36:14: Start Build Engine: The "sailfish-os-build-engine" virtual machine is already running. Nothing to do.
18:36:14: Configuration unchanged, skipping qmake step.
18:36:14: Starting: "/home/attah/.config/SailfishSDK/libsfdk/build-target-tools/sailfish-os-build-engine/SailfishOS-4.1.0.24-aarch64/make" 
+ /home/attah/SailfishOS/bin/sfdk make
sfdk: [I] Options from environment: -c target=SailfishOS-4.1.0.24-aarch64
error: Entry 'src/test.cpp' not uptodate. Cannot merge.
Cannot save the current worktree state
Fatal: Cannot save state of Git working tree: git-stash failed.
18:36:15: The process "/home/attah/.config/SailfishSDK/libsfdk/build-target-tools/sailfish-os-build-engine/SailfishOS-4.1.0.24-aarch64/make" exited with code 1.
Error while building/deploying project gitvsntest (kit: SailfishOS-4.1.0.24-aarch64 (in sailfish-os-build-engine))
When executing step "Make"
18:36:15: Elapsed time: 00:00.

Also note that git-stash fails:

attah@obsidian ~/repos/gitvsntest $ git stash
error: Entry 'src/test.cpp' not uptodate. Cannot merge.
Cannot save the current worktree state

I’m running git 2.33.0, but i’ve seen this quite a while now.

Of course I forgot to set version to 0.

So the behavior is caused by Qt Creator using git add with --intent-to-add, which is known to prevent use of git-stash. It is necessary to add the newly added files to the index (stage) before git-stash is used. (some info git stash tracked but new files - Stack Overflow)

The next Sailfish SDK version will likely omit --intent-to-add by default.

1 Like

Fixed in Sailfish SDK 3.6, which was released to Early Access users just a while ago.