From f871bade5ee513f8367ebb35a843778df61eaed2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Aug 2017 19:22:28 +0100 Subject: [PATCH] worktree support: dgit: Fix for .git/info/attributes 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 --- dgit | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dgit b/dgit index 0ef27f05..83013b89 100755 --- 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 <) { chomp; -- 2.30.2