Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchpatch2 allows lengths of commit hashes to change #257446

Open
NiklasGollenstede opened this issue Sep 26, 2023 · 4 comments
Open

fetchpatch2 allows lengths of commit hashes to change #257446

NiklasGollenstede opened this issue Sep 26, 2023 · 4 comments

Comments

@NiklasGollenstede
Copy link
Contributor

Describe the bug

The point of fetchpatch and fetchpatch2 is to prevent changes in API-generated patches that don't affect the patched tree from affecting the hash of the fetched patch.

GitHub dynamically chooses the length of abbreviated commit hashes in a number of places, and (I guess) also in the generated patches.

Some time around August, a commit hash in the following patch changed from 5d7ffe2d91910 to 5d7ffe2d91910a.

/* was: */ (pkgs.fetchpatch2 { url = "https://github.com/NixOS/nixpkgs/commit/eeff6c493373d3fff11421b55309fab6a1d4ec7d.diff"; sha256 = "sha256-Sqt1FQG+0j9dJMtZiBX+dK3UW5SH5Gtg8zVFTs0F23s="; })
/* now: */ (pkgs.fetchpatch2 { url = "https://github.com/NixOS/nixpkgs/commit/eeff6c493373d3fff11421b55309fab6a1d4ec7d.diff"; sha256 = "sha256-Z5vENYxMNBmTUuhzug9Kgi7/21J1X6d7BxqovyOv9fg="; })
Old patch output
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix
index 5d7ffe2d91910..14d5e29c372a88 100644
--- a/pkgs/os-specific/linux/systemd/default.nix
+++ b/pkgs/os-specific/linux/systemd/default.nix
@@ -178,6 +178,13 @@
     # need (AFAICT).
     # See https://github.com/systemd/systemd/pull/20479 for upstream discussion.
     ./0019-core-handle-lookup-paths-being-symlinks.patch
+
+    # fixes reproducability of dbus xml files
+    # Should no longer be necessary with v251.
+    (fetchpatch {
+      url = "https://github.com/systemd/systemd/pull/22174.patch";
+      sha256 = "sha256-RVhxUEUiISgRlIP/AhU+w1VHfDQw2W16cFl2TXXyxno=";
+    })
   ] ++ lib.optional stdenv.hostPlatform.isMusl (
     let
       oe-core = fetchzip {

I still had that file in a local store. The new output is identical, except it uses 5d7ffe2d91910a as the commit hash.

Steps To Reproduce

That's difficult, since GitHub does not provide the old patch file anymore.
I assume the only difference in the patch files was exactly that hash.

Expected behavior

Stable output by fetchpatch and fetchpatch2.

fetchpatch2 is fairly new and hardly used in nixpkgs. Maybe it should be updated to normalize/strip the hashes? Or we get a fetchpatch3 ...

Notify maintainers

@Artturin

@Artturin
Copy link
Member

Artturin commented Sep 27, 2023

Git auto scales the commit length depending on the amount of commits so that should be the issue

https://github.com/orgs/community/discussions/12531

?full_index=1

@NiklasGollenstede
Copy link
Contributor Author

NiklasGollenstede commented Sep 27, 2023 via email

@jtojnar
Copy link
Contributor

jtojnar commented Jun 6, 2024

@NiklasGollenstede
Copy link
Contributor Author

NiklasGollenstede commented Jun 6, 2024 via email

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

No branches or pull requests

3 participants