Bug 512981 - Adding project files with "list" results in absolute tree paths
Summary: Adding project files with "list" results in absolute tree paths
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: 25.08.3
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-05 15:09 UTC by kde
Modified: 2025-12-24 18:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kde 2025-12-05 15:09:20 UTC
SUMMARY
I want to add the .env file to the project which is normally ignored via .gitignore:

{
  "name": "test",
  "files": [
    {
      "list": [
        ".env"
      ]
    },
    { "git": 1 }
  ]
}

OBSERVED RESULT
This adds the file with it's full path to the tree instead of its relative path, like the files from git.

EXPECTED RESULT
The tree entry should be relative to the project dir.

ADDITIONAL INFORMATION
The code has an explicit comment, that an absolute path is needed:
https://github.com/KDE/kate/blob/9f7021ea1425f9a306097e97c6d7fbb640b8aa6f/addons/project/kateprojectworker.cpp#L411-L418

But I think this is not correct any more, the filesFromGit function produces relative paths (git ls-files) and the absolute paths are calculated later in
https://github.com/KDE/kate/blob/9f7021ea1425f9a306097e97c6d7fbb640b8aa6f/addons/project/kateprojectworker.cpp#L319

Just removing the loop seems to fix the problem.
Comment 1 Christoph Cullmann 2025-12-11 19:03:38 UTC
I think just removing that works only because that .env is toplevel in the projects but would fail if one has more nested stuff, but I could be wrong.
Comment 2 Christoph Cullmann 2025-12-11 19:14:52 UTC
Reading the code again, you seem to be right and I no longer understand why it was done that way, will need to look at file history.
Comment 3 Bug Janitor Service 2025-12-11 19:42:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1960
Comment 4 Christoph Cullmann 2025-12-12 16:07:36 UTC
Git commit 0fc159c521d37e98fd463020aaf4c8affe1987f9 by Christoph Cullmann.
Committed on 12/12/2025 at 14:36.
Pushed by cullmann into branch 'master'.

make the files relative to current dir

later code requires that
don't assume nobody wrote or generated absolute paths into the file

M  +3    -4    addons/project/kateprojectworker.cpp

https://invent.kde.org/utilities/kate/-/commit/0fc159c521d37e98fd463020aaf4c8affe1987f9
Comment 5 Waqar Ahmed 2025-12-24 18:10:22 UTC
Git commit 2ea2d5b01f6d6782af15b0cdea043b98a43df903 by Waqar Ahmed, on behalf of Christoph Cullmann.
Committed on 24/12/2025 at 18:06.
Pushed by waqar into branch 'release/25.12'.

make the files relative to current dir

later code requires that
don't assume nobody wrote or generated absolute paths into the file
(cherry picked from commit 0fc159c521d37e98fd463020aaf4c8affe1987f9)

M  +3    -4    addons/project/kateprojectworker.cpp

https://invent.kde.org/utilities/kate/-/commit/2ea2d5b01f6d6782af15b0cdea043b98a43df903