git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git 2.8.1 fails test 32 of t7300-clean.sh, breaks profile build

From
erik elfström <erik.elfstrom@gmail.com>
Date
May 3, 2016, 21:28 UTC
Message-ID
<CAMpP7NbeELYQvZ1A1acA-V6jZVRvNzjbAqD6zd2YoJvGT5Dxxw@mail.gmail.com>
In-Reply-To
<20160503190053.GC30530@sigill.intra.peff.net>
Thanks for fixing the missing SANITY prerequisite Stefan.

As for the error handling logic in setup.c: is_nonbare_repository_dir (was clean.c: is_git_repository) my reasoning is as follows:

READ_GITFILE_ERR_STAT_FAILED READ_GITFILE_ERR_NOT_A_FILE:

When checking random paths for .git files these are the common error modes, file is not there or it is a directory. This should not be interpreted as a valid .git file.

READ_GITFILE_ERR_OPEN_FAILED READ_GITFILE_ERR_READ_FAILED:

Here we found a .git file but could not open and read it to verify that it is valid. Treating it as valid is the safest option for clean. For resolve_gitlink_ref I think it maybe leads to the creation of a redundant ref cache entries but I don't think this is a problem unless someone has a huge amount of unreadable .git files lying around.

READ_GITFILE_ERR_TOO_LARGE:
File is absurdly large (1MB), very unlikely to be a valid .git file.

READ_GITFILE_ERR_INVALID_FORMAT READ_GITFILE_ERR_NO_PATH:

File is malformed in some way, either the "gitdir:" prefix is missing or the path is missing. Could theoretically be a corrupted .git file but seems unlikely.

READ_GITFILE_ERR_NOT_A_REPO:

This is maybe a bit more suspicious. Here we have found a .git file, it has the format "gitdir: some/path" but is_git_directory("some/path") returned false, meaning that "some/path" does not fulfill:

/*
 * Test if it looks like we're at a git directory.
 * We want to see:
 *
 *  - either an objects/ directory _or_ the proper
 *    GIT_OBJECT_DIRECTORY environment variable
 *  - a refs/ directory
 *  - 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.
*/

Technically we don't have a valid .git file here but we have something that really tries to be. I guess it is debatable what the correct conservative choice is here and if it is the same for all callers.

/Erik
Previous: Jeff King
Message 10 of 10 in “Fwd: Git 2.8.1 fails test 32 of t7300-clean.sh, breaks profile build”
  1. Jan KeromnesApr 29, 2016
  2. Johannes SchindelinApr 29, 2016
  3. Stefan BellerApr 29, 2016
  4. Jan KeromnesMay 3, 2016
  5. Stefan BellerMay 3, 2016
  6. Junio C HamanoMay 3, 2016
  7. Jeff KingMay 3, 2016
  8. Stefan BellerMay 3, 2016
  9. Jeff KingMay 3, 2016
  10. erik elfströmMay 3, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.