diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-06-20 14:08:03 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2018-06-20 14:29:38 +0100 |
commit | 1cf29315dda6f4d7aa1ae6f9b5800b35173040c6 (patch) | |
tree | 2f1cfbd9da1de44c8c03ad4b70aab25d4d3f4bdb | |
parent | 61016923b2a47b0550e36ed5f5a929d401811b42 (diff) |
dgit: gitattributes: Minor refactoring to prep for adding new squash
* is_gitattrs_setup: Break out $gitattrs_ourmacro_re
* is_gitattrs_setup: Reorganise very slightly
* is_gitattrs_setup: Add a debug print
* setup_gitattrs: Introduce $new
* setup_gitattrs: Add a blank line
No functional change.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-x | dgit | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -3393,13 +3393,17 @@ sub open_main_gitattrs () { return $gai; } +our $gitattrs_ourmacro_re = qr{^\[attr\]dgit-defuse-attrs\s}; + sub is_gitattrs_setup () { my $gai = open_main_gitattrs(); return 0 unless $gai; while (<$gai>) { - return 1 if m{^\[attr\]dgit-defuse-attrs\s}; + next unless m{$gitattrs_ourmacro_re}; + return 1; } $gai->error and die $!; + printdebug "is_gitattrs_setup: found nothing\n"; return 0; } @@ -3407,19 +3411,22 @@ sub setup_gitattrs (;$) { my ($always) = @_; return unless $always || access_cfg_bool(1, 'setup-gitattributes'); - if (is_gitattrs_setup()) { + my $already = is_gitattrs_setup(); + if ($already) { progress <<END; [attr]dgit-defuse-attrs already found in .git/info/attributes not doing further gitattributes setup END return; } + my $new = "[attr]dgit-defuse-attrs $negate_harmful_gitattrs"; my $af = "$maindir_gitcommon/info/attributes"; ensuredir "$maindir_gitcommon/info"; + open GAO, "> $af.new" or die $!; print GAO <<END or die $!; * dgit-defuse-attrs -[attr]dgit-defuse-attrs $negate_harmful_gitattrs +$new # ^ see GITATTRIBUTES in dgit(7) and dgit setup-new-tree in dgit(1) END my $gai = open_main_gitattrs(); |