Package: myrepos
Version: 1.20180726
Severity: normal

Dear Maintainer,

An error is returned when running "mr register" on a bare git
repository that has no refs/tags or refs/heads directory. 

$ git clone --bare --quiet https://github.com/beancount/beancount-mode.git
$ cd beancount-mode.git
$ rmdir refs/tags
$ mr register
mr register: unknown repository type

In my case my repositories are stored that way on disk, perhaps
because I'm using GitLab which seems to aggressively prefer
packed-refs [1] instead for example.

I checked the git reference documentation (gitrepository-layout [2],
etc.)  and was unable to find anything defining the directories under
refs/ as required instead of optional, but git seems to work fine with
an empty refs directory, lazily creating things under refs/ if they
are missing. However having a missing refs/ directory entirely is not
OK:

$ rm -rf refs
$ git log --oneline -1
fatal: not a git repository (or any of the parent directories): .git

A patch is attached that loosens the git_bare test (and vcsh) to not
require heads nor tags under refs, but instead simply require a refs
folder in addition to the other heuristics used for detecting a git
repository. 

This appears to have been added in
c20b454a225407e5c6b918cbb6e739b888b252ab when handling of git bare
repositories was separated out.

[1] https://git-scm.com/docs/git-pack-refs
[2] https://git-scm.com/docs/gitrepository-layout


*** 0001-Fix-detection-of-git-bare-repositories-with-no-tags-.patch
From: Jacob Greenleaf <ja...@jacobgreenleaf.com>
Origin: other
Date: Tue, 7 Mar 2023 19:35:41 -0800
Subject: [PATCH] Fix detection of git bare repositories with no tags or heads
 refs dirs

---
 mr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mr b/mr
index 056e749..26d9300 100755
--- a/mr
+++ b/mr
@@ -2501,11 +2501,11 @@ hg_test  = perl: -d "$ENV{MR_REPO}/.hg"
 darcs_test = perl: -d "$ENV{MR_REPO}/_darcs"
 fossil_test = perl: -f "$ENV{MR_REPO}/_FOSSIL_" || -f "$ENV{MR_REPO}/.fslckout"
 git_bare_test = perl:
-       -d "$ENV{MR_REPO}/refs/heads" && -d "$ENV{MR_REPO}/refs/tags" &&
+       -d "$ENV{MR_REPO}/refs" &&
        -d "$ENV{MR_REPO}/objects" && -f "$ENV{MR_REPO}/config" &&
        `GIT_CONFIG="$ENV{MR_REPO}"/config git config --get core.bare` =~ /true/
 vcsh_test = perl:
-       -d "$ENV{MR_REPO}/refs/heads" && -d "$ENV{MR_REPO}/refs/tags" &&
+       -d "$ENV{MR_REPO}/refs" &&
        -d "$ENV{MR_REPO}/objects" && -f "$ENV{MR_REPO}/config" &&
        `GIT_CONFIG="$ENV{MR_REPO}"/config git config --get vcsh.vcsh` =~ /true/
 veracity_test  = perl: -d "$ENV{MR_REPO}/.sgdrawer"
-- 
2.30.2


-- System Information:
Debian Release: 11.6
  APT prefers bullseye
  APT policy: (500, 'bullseye')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-21-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages myrepos depends on:
ii  perl  5.32.1-4+deb11u2

Versions of packages myrepos recommends:
ii  libfile-homedir-perl  1.006-1
ii  libhtml-parser-perl   3.75-1+b1
ii  libio-pty-easy-perl   0.10-1.1
ii  libwww-perl           6.52-1

Versions of packages myrepos suggests:
pn  ack | ack-grep    <none>
pn  bzr               <none>
ii  curl              7.74.0-1.3+deb11u7
pn  cvs               <none>
pn  darcs             <none>
pn  dgit              <none>
pn  fossil            <none>
ii  git [git-core]    1:2.30.2-1+deb11u2
pn  git-annex         <none>
pn  git-big-picture   <none>
pn  git-svn           <none>
pn  gitk | tig        <none>
pn  kdesdk-scripts    <none>
ii  liburi-perl       5.08-1
pn  mercurial         <none>
pn  perl-doc          <none>
pn  stow              <none>
pn  subversion        <none>
pn  subversion-tools  <none>
pn  unison            <none>
pn  vcsh              <none>
ii  xdg-utils         1.1.3-4.1

-- no debconf information

Reply via email to