Skip to content

[win] Fix git apply failures in incremental builds#22075

Open
bellenot wants to merge 1 commit intoroot-project:masterfrom
bellenot:fix-git-apply
Open

[win] Fix git apply failures in incremental builds#22075
bellenot wants to merge 1 commit intoroot-project:masterfrom
bellenot:fix-git-apply

Conversation

@bellenot
Copy link
Copy Markdown
Member

On Windows, delete the source directories of a couple of builtins to make sure
there is no conflict with git apply on already patched files in incremental builds
and add LOG_PATCH 1

On Windows, delete the source directories of a couple of builtins to
make sure there is no conflict with `git apply` on already patched files
in incremental builds and add `LOG_PATCH 1`
@bellenot bellenot self-assigned this Apr 27, 2026
Copy link
Copy Markdown
Member

@linev linev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it has something to do with wired file modification time on Windows.
I saw same problem on my Windows as well.

It is workaround but seems to be the only way to solve problem.

Copy link
Copy Markdown
Collaborator

@ferdymercury ferdymercury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

Just out of curiosity:

Did you try instead "undefining" the UPDATE command? See https://stackoverflow.com/questions/56986726/cmake-externalproject-add-rebuilds-every-time
UPDATE_COMMAND ""

If that doesn't help, wouldn't it be cleaner to call something like ExternalProject_Add_Step that reverts the previously applied patch using
git apply patch -R whatever.patch before applying the new one? Rather than deleting the whole source.

Maybe on the first run, applying --ignore-whitespace leads to issues on a second run?
There are also some flags such as --inaccurate-eof but no idea.

Also, maybe a more up-to-date git version helps?

@bellenot
Copy link
Copy Markdown
Member Author

@ferdymercury I already tried all of what you suggest, except up-to-date git version. Will try

@bellenot
Copy link
Copy Markdown
Member Author

@ferdymercury it seems the latest git version (2.54.0.windows.1) doesn't have that issue. @linev can you try?
And I keep that PR on hold for now

@linev
Copy link
Copy Markdown
Member

linev commented Apr 27, 2026

I using git 2.53.0.windows.2. And as reported - saw once such problem.
So using newest git may solve or may not solve the problem

Copy link
Copy Markdown
Collaborator

@ferdymercury ferdymercury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems alma10 does not like the new changes

(or maybe needs clean-build label?)

@bellenot
Copy link
Copy Markdown
Member Author

bellenot commented Apr 27, 2026

Seems alma10 does not like the new changes

(or maybe needs clean-build label?)

That cannot be this PR, my changes are inside if(WIN32)...

@ferdymercury
Copy link
Copy Markdown
Collaborator

ferdymercury commented Apr 27, 2026

That cannot be this PR, my changes are inside if(WIN32)...

ahh. So then maybe the failure in git apply patch incremental builds is not only for windows but also for unix ?

@bellenot
Copy link
Copy Markdown
Member Author

That cannot be this PR, my changes are inside if(WIN32)...

ahh. So then maybe the failure in git apply patch incremental builds is not only for windows but also for unix ?

That might well be...

@bellenot
Copy link
Copy Markdown
Member Author

Yes, same errors:

  [1/4938] Performing patch step for 'BUILTIN_LIBGIF'
  FAILED: builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch 
  cd /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF && /usr/bin/cmake -P /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch-RelWithDebInfo.cmake && /usr/bin/cmake -E touch /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch
  CMake Error at /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch-RelWithDebInfo.cmake:37 (message):
    Command failed: 1
  
     'git' 'apply' '/github/home/ROOT-CI/src/builtins/libgif/libgif_add_cmakelists.patch'
  
    See also
  
      /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch-*.log
  
  
  -- stdout output is:
  
  -- stderr output is:
  error: CMakeLists.txt: already exists in working directory
  
  CMake Error at /github/home/ROOT-CI/build/builtins/LIBGIF-prefix/src/BUILTIN_LIBGIF-stamp/BUILTIN_LIBGIF-patch-RelWithDebInfo.cmake:47 (message):
    Stopping after outputting logs.
  
  
  [2/4938] Updating etc/gitinfo.txt.
  [3/4938] Performing patch step for 'BUILTIN_GL2PS'
  FAILED: builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch 
  cd /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS && /usr/bin/cmake -P /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch-RelWithDebInfo.cmake && /usr/bin/cmake -E touch /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch
  CMake Error at /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch-RelWithDebInfo.cmake:37 (message):
    Command failed: 1
  
     'git' 'apply' '/github/home/ROOT-CI/src/builtins/gl2ps/v142_post_tag_fixes.patch'
  
    See also
  
      /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch-*.log
  
  
  -- stdout output is:
  
  -- stderr output is:
  error: patch failed: CMakeLists.txt:49
  error: CMakeLists.txt: patch does not apply
  error: patch failed: CMakeLists.txt:92
  error: CMakeLists.txt: patch does not apply
  error: patch failed: CMakeLists.txt:155
  error: CMakeLists.txt: patch does not apply
  error: patch failed: CMakeLists.txt:147
  error: CMakeLists.txt: patch does not apply
  error: patch failed: CMakeLists.txt:155
  error: CMakeLists.txt: patch does not apply
  error: patch failed: CMakeLists.txt:1
  error: CMakeLists.txt: patch does not apply
  error: patch failed: gl2ps.c:2
  error: gl2ps.c: patch does not apply
  error: patch failed: gl2ps.h:2
  error: gl2ps.h: patch does not apply
  error: patch failed: gl2ps.tex:2
  error: gl2ps.tex: patch does not apply
  error: patch failed: gl2psTest.c:1
  error: gl2psTest.c: patch does not apply
  error: patch failed: gl2psTestSimple.c:1
  error: gl2psTestSimple.c: patch does not apply
  error: patch failed: gl2ps.c:4456
  error: gl2ps.c: patch does not apply
  
  CMake Error at /github/home/ROOT-CI/build/builtins/GL2PS-prefix/src/BUILTIN_GL2PS-stamp/BUILTIN_GL2PS-patch-RelWithDebInfo.cmake:47 (message):
    Stopping after outputting logs.
  

@ferdymercury
Copy link
Copy Markdown
Collaborator

Seems we're not the first ones:
cpm-cmake/CPM.cmake#618
BohdanBuinich/CPM.cmake@3c3ebf1

Maybe setting
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
helps?

@bellenot
Copy link
Copy Markdown
Member Author

Seems we're not the first ones: cpm-cmake/CPM.cmake#618 BohdanBuinich/CPM.cmake@3c3ebf1

Maybe setting DOWNLOAD_EXTRACT_TIMESTAMP TRUE helps?

Already tried...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants