diff options
-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 |