Re: [PATCH] fsck: detect bare repos in trees and warn
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 7, 2022, 13:12 UTC
- Message-ID
- <220407.86pmltc9w3.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <20220406232231.47714-1-chooglen@google.com>
On Wed, Apr 06 2022, Glen Choo wrote:
Show 10 quoted lines
> @@ -602,6 +605,12 @@ static int fsck_tree(const struct object_id *tree_oid, > has_dotdot |= !strcmp(name, ".."); > has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name); > has_zero_pad |= *(char *)desc.buffer == '0'; > + has_head |= !strcasecmp(name, "HEAD") > + && (S_ISLNK(mode) || S_ISREG(mode)); > + has_refs_entry |= !strcasecmp(name, "refs") > + && (S_ISLNK(mode) || S_ISDIR(mode)); > + has_objects_entry |= !strcasecmp(name, "objects") > + && (S_ISLNK(mode) || S_ISDIR(mode));
Doesn't this code need to use is_hfs_dot_str() instead of strcasecmp() like the other similar checks?
Show 9 quoted lines
> @@ -336,6 +336,10 @@ int get_common_dir_noenv(struct strbuf *sb, const char *gitdir) > * - either a HEAD symlink or a HEAD file that is formatted as > * a proper "ref:", or a regular file HEAD that has a properly > * formatted sha1 object name. > + * > + * fsck.c checks for bare repositories in trees using similar rules, but a > + * duplicated implementation. If these are changed, the correspnding code in > + * fsck.c should change too. > */
Probably took much hassle to factor these so it can be re-used. Typo: correspnding.
> + test_i18ngrep "warning.*tree $bad_tree: embeddedBareRepo: contains bare repository" out
s/test_i18ngrep/grep/