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 /dgit | |
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>
Diffstat (limited to 'dgit')
-rwxr-xr-x | dgit | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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; |