git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Server-side preventing some files from being overwritten

From
Thorsten Glaser <t.glaser@tarent.de>
Date
Jul 14, 2016, 17:51 UTC
Message-ID
<alpine.DEB.2.20.1607141948530.25238@tglase.lan.tarent.de>
In-Reply-To
<CAGZ79kb=2rpYucjhavNB_XHLk9rjKSoHzL9bwM5buDO0GyW3vw@mail.gmail.com>
On Thu, 14 Jul 2016, Stefan Beller wrote:
> go roughly like
Thanks, that did the trick!

Although I’m ordinarily loath to write GNU bash scripts, this helps avoiding temporary files. This works:

-----cutting here may damage your screen surface-----
#!/bin/bash
export LC_ALL=C
subdir=x/y
while IFS=' ' read -r old new name; do
	test x"$name" = x"refs/heads/master" || continue
	if test x"0" != x"$(comm -23z \
	    <(git ls-tree -r -z "$old" "$subdir" | sort -z) \
	    <(git ls-tree -r -z "$new" "$subdir" | sort -z) | wc -c)"; then
		echo >&2 'Untouchable files touched, commit rejected!'
		exit 1
	fi
done
exit 0
-----cutting here may damage your screen surface-----

Of course, set “subdir” in line 3 correctly, and GNU coreutils are required for the NUL line termination, which is not an issue here. (BSD has “-R ''” for sort(1), for example.)

bye, //mirabilos

-- 
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg
Previous: Stefan BellerNext: Junio C Hamano
Message 3 of 12 in “Server-side preventing some files from being overwritten”
  1. Thorsten GlaserJul 14, 2016
  2. Stefan BellerJul 14, 2016
  3. Thorsten GlaserJul 14, 2016
  4. Junio C HamanoJul 14, 2016
  5. Junio C HamanoJul 14, 2016
  6. Stefan BellerJul 14, 2016
  7. Ævar Arnfjörð BjarmasonJul 15, 2016
  8. Thorsten GlaserJul 15, 2016
  9. Thorsten GlaserJul 14, 2016
  10. Junio C HamanoJul 14, 2016
  11. Jakub NarębskiJul 21, 2016
  12. Thorsten GlaserJul 21, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.