diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-06-20 14:10:02 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-06-20 14:29:38 +0100 |
commit | 5099a42730ecb2a33152826a623d545f60fea77e (patch) | |
tree | 03d2c10435508ad50d8f0bc1750635582392ac33 | |
parent | 1cf29315dda6f4d7aa1ae6f9b5800b35173040c6 (diff) |
dgit: gitattributes: Defuse working-tree-encoding
* Add -working-tree-encoding to $negate_harmful_gitattrs.
* Add new arrangements for updating an existing dgit-defuse-attrs
macro definition:
- is_gitattrs: say whether the macro is up to date
- setup_gitattrs: update an existing out-of-date macro
- minor message changes
- document the new behaviour
One consequence is that we have had to breach the promise about how to
stop future dgit setup-new-tree runs messing with this: it is now
necessary to disapply the macro, rather than redefine it.
Closes:#901900.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rw-r--r-- | Debian/Dgit.pm | 4 | ||||
-rwxr-xr-x | dgit | 22 | ||||
-rw-r--r-- | dgit.1 | 11 |
3 files changed, 30 insertions, 7 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index 960f505..aec5a23 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -101,7 +101,9 @@ sub NOCOMMITCHECK () { return 0x8; } our $debugprefix; our $debuglevel = 0; -our $negate_harmful_gitattrs = "-text -eol -crlf -ident -filter"; +our $negate_harmful_gitattrs = + "-text -eol -crlf -ident -filter -working-tree-encoding"; + # ^ when updating this, alter the regexp in dgit:is_gitattrs_setup our $forkcheck_mainprocess; @@ -3396,15 +3396,23 @@ sub open_main_gitattrs () { our $gitattrs_ourmacro_re = qr{^\[attr\]dgit-defuse-attrs\s}; sub is_gitattrs_setup () { + # return values: + # trueish + # 1: gitattributes set up and should be left alone + # falseish + # 0: there is a dgit-defuse-attrs but it needs fixing + # undef: there is none my $gai = open_main_gitattrs(); return 0 unless $gai; while (<$gai>) { next unless m{$gitattrs_ourmacro_re}; - return 1; + return 1 if m{\s-working-tree-encoding\s}; + printdebug "is_gitattrs_setup: found old macro\n"; + return 0; } $gai->error and die $!; printdebug "is_gitattrs_setup: found nothing\n"; - return 0; + return undef; } sub setup_gitattrs (;$) { @@ -3414,7 +3422,7 @@ sub setup_gitattrs (;$) { my $already = is_gitattrs_setup(); if ($already) { progress <<END; -[attr]dgit-defuse-attrs already found in .git/info/attributes +[attr]dgit-defuse-attrs already found, and proper, in .git/info/attributes not doing further gitattributes setup END return; @@ -3424,7 +3432,7 @@ END ensuredir "$maindir_gitcommon/info"; open GAO, "> $af.new" or die $!; - print GAO <<END or die $!; + print GAO <<END or die $! unless defined $already; * dgit-defuse-attrs $new # ^ see GITATTRIBUTES in dgit(7) and dgit setup-new-tree in dgit(1) @@ -3432,6 +3440,10 @@ END my $gai = open_main_gitattrs(); if ($gai) { while (<$gai>) { + if (m{$gitattrs_ourmacro_re}) { + die unless defined $already; + $_ = $new; + } chomp; print GAO $_, "\n" or die $!; } @@ -3466,7 +3478,7 @@ sub check_gitattrs ($$) { # oh dear, found one print STDERR <<END; dgit: warning: $what contains .gitattributes -dgit: .gitattributes have not been defused. Recommended: dgit setup-new-tree. +dgit: .gitattributes not (fully) defused. Recommended: dgit setup-new-tree. END close $gafl; return; @@ -268,10 +268,19 @@ For why, see in .BR dgit(7) . +If there is an existing macro attribute line +.B [attr]dgit-defuse-attrs +in .git/info/attributes, +but it is insufficient, +because it was made by an earlier version of dgit +and git has since introduced new transforming attributes, +modifies the macro to disable the newer transformations. + (If there is already a macro attribute line .B [attr]dgit-defuse-attrs in .git/info/attributes -(whatever its effects), +which does what dgit requires +(whatever files it effects), this operation does nothing further. This fact can be used to defeat or partially defeat dgit setup-gitattributes |