summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit22
1 files changed, 17 insertions, 5 deletions
diff --git a/dgit b/dgit
index e7a6904..94f915e 100755
--- a/dgit
+++ b/dgit
@@ -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;