chiark / gitweb /
worktree support: dgit: Fix for .git/info/attributes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 2 Aug 2017 18:22:28 +0000 (19:22 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Aug 2017 19:37:19 +0000 (20:37 +0100)
Experimentally, this file is in the common dir, not the per-worktree
dir.  Honour $maindir_gitcommon everywhere.

Rename `open_main_gitattrs'.  Previously it could in theory be used in
the playtree (but, it isn't).  Now it always operates on the main
tree.

Indeed, as we require, the `setup' stuff is only done in the main
tree.  The gitattributes fixes for playtrees are done,
unconditionally, with the much simpler hammer in playtree_setup.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 0ef27f050976e9b550221135f649da527a8e7c7f..83013b898448046d69711064908354b98736b7a9 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -3266,8 +3266,9 @@ sub setup_mergechangelogs (;$) {
 
     my $driver = 'dpkg-mergechangelogs';
     my $cb = "merge.$driver";
-    my $attrs = '.git/info/attributes';
-    ensuredir '.git/info';
+    confess unless defined $maindir;
+    my $attrs = "$maindir_gitcommon/info/attributes";
+    ensuredir "$maindir_gitcommon/info";
 
     open NATTRS, ">", "$attrs.new" or die "$attrs.new $!";
     if (!open ATTRS, "<", $attrs) {
@@ -3312,15 +3313,15 @@ sub ensure_setup_existing_tree () {
     set_local_git_config $k, 'true';
 }
 
-sub open_gitattrs () {
-    my $gai = new IO::File ".git/info/attributes"
+sub open_main_gitattrs () {
+    my $gai = new IO::File "$maindir_gitcommon/info/attributes"
        or $!==ENOENT
-       or die "open .git/info/attributes: $!";
+       or die "open $maindir_gitcommon/info/attributes: $!";
     return $gai;
 }
 
 sub is_gitattrs_setup () {
-    my $gai = open_gitattrs();
+    my $gai = open_main_gitattrs();
     return 0 unless $gai;
     while (<$gai>) {
        return 1 if m{^\[attr\]dgit-defuse-attrs\s};
@@ -3340,15 +3341,15 @@ sub setup_gitattrs (;$) {
 END
        return;
     }
-    my $af = ".git/info/attributes";
-    ensuredir '.git/info';
+    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
 # ^ see GITATTRIBUTES in dgit(7) and dgit setup-new-tree in dgit(1)
 END
-    my $gai = open_gitattrs();
+    my $gai = open_main_gitattrs();
     if ($gai) {
        while (<$gai>) {
            chomp;