Git hook shebangs should not be rewritten

  • Done
  • quality assurance status badge
Details
4 participants
  • Jack Hill
  • Leo Famulari
  • Marius Bakke
  • Miguel Ángel Arruga Vivas
Owner
unassigned
Submitted by
Leo Famulari
Severity
important
Merged with
L
L
Leo Famulari wrote on 23 Jan 2017 00:25
(address . bug-guix@gnu.org)(name . John Darrington)(address . jmd@gnu.org)
20170122232550.GB27876@jasmine
----- Forwarded message from John Darrington <john@darrington.wattle.id.au> -----

Date: Sun, 22 Jan 2017 14:01:24 +0100
From: John Darrington <john@darrington.wattle.id.au>
To: guix-devel@gnu.org
Subject: Not patching shebang in git hook samples ?
User-Agent: Mutt/1.5.23 (2014-03-12)

The git package ships with a number of sample hook files. These are shell scripts and
therefore the #!/bin/sh line gets substituted at build time.

However these files get installed into every git repostory that is created, and users
are invited to use them as templates for their own hooks.

This will be fine until both git and bash are updated. Now the original bash is free
to be garbage collected. If that happens, the path:
#!/gnu/store/qkw4zrwfybxww8f56nkb6hggxambk89b-bash-4.4.0/bin/sh
will no longer exist.

I suggest what we turn off the shebang patching for the files in share/templates for git.

J'

--
Avoid eavesdropping. Send strong encrypted email.
PGP Public key ID: 1024D/2DE827B3
fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.netor any PGP keyserver for public key.




----- End forwarded message -----
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAliFP3kACgkQJkb6MLrK
fwg9Jg/9HE3EmpVTW6Uq5oYTegpmoq1VkXZ6OBFGkeBx4Xjv6bJwwpxWwKxcuxTY
jmw/JuvjHCW2TCcLEUNHv5a1xMRZ69dUWzppB9JNWO63h+Qku6rA97CH21fyPpNh
j5gGkV9WQnDi1BXOOggXQ0wYbkOTfa0WzCabdxcvf0CeoZRSYflq6kLothZ4pUF9
XED6xCnNxYjPYGlzjdc9LXYpFuqOOLJrX60xL5I0cibfjbpcK41/pk55YKI0LESp
xNzqKmrS4x2xSJFeQHAsnrLsgModpZPP0+6nMI0NhePs+3d5T3Jaa9imfmNDwy4M
DC6gRy8X9kVg4YU/ljklA5kKDMp/bGP2DHc3KsvgzEu9RjxgeGMRImZnFBqbWFAJ
k3FuOm8VymlkKsOP793ah4QDi4GL4JFrIzxwBF9OY8/yNkiqQHk0R+OCK4xjScBU
WOBCdOLsdkAUgAhQbX/yL4Cklc2YU6+6qY0WwFke/eJP2vn1lOtABQoxxnZzOOhw
hgPMMY4LIldu9xpNyu4zQ6F8s/rmi+n1Vtxr2q+ZKf4rKD6V/z1+Qp+HlDQ7YGXl
/01PwkXKNqKeyz6VogLXwfLJkGbPjhQvnI/9aQA0I3uVMyz5elvYT+qXt09+aZJn
x5JQ2NLMCki4zOYf0dkeDbfAr5lfBlUowEt5tjfgUkmvmwXNBmA=
=/fnN
-----END PGP SIGNATURE-----


J
J
Jack Hill wrote on 18 Mar 2020 21:31
Merging issues for not patching some shebang in examples
(address . control@debbugs.gnu.org)
alpine.DEB.2.20.2003181626290.19733@marsh.hcoop.net
reopen 25304
severity 25304 important
severity 25508 important
merge 25508 25304 26749
retitle 26749 mask files from shebang patcher (git, libtool and stagit)
J
J
Jack Hill wrote on 18 Mar 2020 21:37
Merge bugs related to masking files from shebang patcher
(address . control@debbugs.gnu.org)
alpine.DEB.2.20.2003181635570.19733@marsh.hcoop.net
unarchive 25304
reopen 25304
severity 25304 important
merge 25508 25304 26749
thanks
M
M
Miguel Ángel Arruga Vivas wrote on 16 Nov 2020 19:10
Re: bug#25508: Git hook shebangs should not be rewritten
(name . Leo Famulari)(address . leo@famulari.name)
87r1otw4ss.fsf@gmail.com
Sorry, I've closed this with the libtool one.

The attached patch fixes this one too, should I push it to master (as
the last change for git) or to core-updates or staging (as it might seem
looking at the dependencies)?

Happy hacking!
Miguel
From 9f0e9eea6d7c338fba234c2f8935ba76b1d94b2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
<rosen644835@gmail.com>
Date: Mon, 16 Nov 2020 19:06:40 +0100
Subject: [PATCH] gnu: git: Add phase to restore hooks shebang.


* gnu/packages/version-control.scm (git)[arguments]: New phase
restore-sample-hooks-shebang.
---
gnu/packages/version-control.scm | 10 ++++++++++
1 file changed, 10 insertions(+)

Toggle diff (23 lines)
diff --git a/gnu/packages/version-control.scm b/gnu/packages/version-control.scm
index 3e46a6162b..1842528ff6 100644
--- a/gnu/packages/version-control.scm
+++ b/gnu/packages/version-control.scm
@@ -391,6 +391,16 @@ as well as the classic centralized workflow.")
(install-file "contrib/subtree/git-subtree.1"
(string-append subtree "/share/man/man1"))
#t)))
+ (add-after 'install 'restore-sample-hooks-shebang
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (dir (string-append out "/share/git-core/templates/hooks")))
+ (for-each (lambda (file)
+ (format #t "restoring shebang on `~a'~%" file)
+ (substitute* file
+ (("^#!.*/bin/sh") "#!/bin/sh")))
+ (find-files dir ".*"))
+ #t)))
(add-after 'install 'split
(lambda* (#:key inputs outputs #:allow-other-keys)
;; Split the binaries to the various outputs.
--
2.29.2
Leo Famulari <leo@famulari.name> writes:

Toggle quote (19 lines)
> From: John Darrington <john@darrington.wattle.id.au>
> Subject: Not patching shebang in git hook samples ?
> To: guix-devel@gnu.org
> Date: Sun, 22 Jan 2017 14:01:24 +0100 (3 years, 42 weeks, 4 days ago)
>
> The git package ships with a number of sample hook files. These are shell scripts and
> therefore the #!/bin/sh line gets substituted at build time.
>
> However these files get installed into every git repostory that is created, and users
> are invited to use them as templates for their own hooks.
>
> This will be fine until both git and bash are updated. Now the original bash is free
> to be garbage collected. If that happens, the path:
> #!/gnu/store/qkw4zrwfybxww8f56nkb6hggxambk89b-bash-4.4.0/bin/sh
> will no longer exist.
>
> I suggest what we turn off the shebang patching for the files in share/templates for git.
>
> J'
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEEiIeExBRZrMuD5+hMY0xuiXn6vsIFAl+ywLQACgkQY0xuiXn6
vsI5hQv+IfRGaTZ7A0Ulzdy54BxcVq/asGgJUcAG8HU/cZbxQDSjmbcWXoIomrI8
PyvVVmoFwm6RVFKvCZCFqFVIeKMzPZOjgWLV2gRLwBH1VR+oQG+1LT7WTULL8fGB
6ToYkKWqE3d7sZnE5J+jFjVclCXUVyzySIW0cCBT8jXei9sOTnO8+nby9/aBwMpT
+1sMz2qGZ4XR8arXPQnp1duDaBrqq4hPOcsMUH2NL86Widf3EkJ0F+CskU0z/Bi8
jufRuZcy9OfQXUHqoVOEvS9catdq9IAR4rGaYhRMHUiq796Bka232kATYkpTmjZz
pMFxyQNUkDQtRCVt8devE54Xliy6OTPD3w0RRn/3s78XKyCVCim2JQK0+40cDDHh
dnrUN1tkZ87ggHw1xth2NVdi4eKlKIqB4mAClH9QRyF2yW0EzGmjE27Lxbb3e9aM
+nSZHYo52VbKbUVGVkgmBwT9el9zGG/YcIbfO3oM71Pe18Xmmf7KropfvKgVhqaz
AAPVvykG
=3IH3
-----END PGP SIGNATURE-----

M
M
Marius Bakke wrote on 16 Nov 2020 19:42
Re: bug#25304: bug#25508: Git hook shebangs should not be rewritten
87h7pp9m99.fsf@gnu.org
Miguel Ángel Arruga Vivas <rosen644835@gmail.com> writes:

Toggle quote (4 lines)
> The attached patch fixes this one too, should I push it to master (as
> the last change for git) or to core-updates or staging (as it might seem
> looking at the dependencies)?

LGTM. Git (+ git-minimal) is below the 300 rebuild limit for 'master'
(and I try to keep it that way!).
-----BEGIN PGP SIGNATURE-----

iQFDBAEBCgAtFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl+yyBIPHG1hcml1c0Bn
bnUub3JnAAoJEKKgbfKjOlT63K4H/2TqeZuQEnTyDjzDyMHOTuuqaw1Ckbxep04O
9Bp9Dz00OX2qOrJLuviiSbN656G+gtA9phopvZiQhRQrkNt91S202zWQy96tPAHy
ikTNlONVqH1d8penErNSW7Ddzmi+IO16MxIvHSyme+wNo+zy3uirdO9LNEcSBr72
TI+YzkuKh3qFUbW7DMFKIKCdeRL4lwBE5pxdhXhsFLn/ecr9iFmHY9ZqI/C6OYIK
7Xi2sFt5vQu/MmP99N/mhqtURYz6AeRt6xQfMBj9HzXoTbYtoDgseVmfAvZfiQiq
7Q7NJnzBAjOGzmhlRcV8+Q0PrshOkfqzBZ4XSAgzQrZhQDYvOqk=
=1bUC
-----END PGP SIGNATURE-----

M
M
Miguel Ángel Arruga Vivas wrote on 16 Nov 2020 21:51
(name . Marius Bakke)(address . marius@gnu.org)
87ima5vxcw.fsf@gmail.com
Marius Bakke <marius@gnu.org> writes:

Toggle quote (9 lines)
> Miguel Ángel Arruga Vivas <rosen644835@gmail.com> writes:
>
>> The attached patch fixes this one too, should I push it to master (as
>> the last change for git) or to core-updates or staging (as it might seem
>> looking at the dependencies)?
>
> LGTM. Git (+ git-minimal) is below the 300 rebuild limit for 'master'
> (and I try to keep it that way!).

Thanks for the info and the fast review, I wasn't sure if it was 109+242
or just 242. I've pushed it to master as
46ce24fb2d8c9f7dce16c4c08919f0fc108dbfae.

Happy hacking!
Miguel
?