-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs: enforce name conventions for root refs
We recently taught check_refname_format() to insist that any ref outside of "refs/" match the is_root_ref_syntax() rules. This can reduce the chance of accidentally reading or writing a non-ref file in ".git" when the files backend is in use. For case-sensitive filesystems, this should mostly work. We do not generally create all-caps files under .git/ unless they are meant to be root refs. But for case-insensitive filesystems, it's less clear. Asking to write to "CONFIG" would try to access the actual ".git/config" file (though fortunately this does not work, as we refuse to write anything we can't parse as a ref). We already have functions that catalog the pattern of allowable names (i.e., ending in "_HEAD" or one of a set of historical exceptions). So even if we allowed creating such a ref, we'd skip over it while iterating over the root refs. Let's teach check_refname_format() to use those functions to further restrict what it will allow at the root level. That should make things safer and more consistent with ref iteration. Note that while is_root_ref_syntax() covers the syntax for both regular root refs and pseudo-refs (FETCH_HEAD and MERGE_HEAD), the is_root_ref() function does not include pseudo-refs. So we have to check the two classes separately. This patch doesn't touch refname_is_safe(), which generally tries to be a bit more loose (e.g., to allow deletion of bogus names). I've left it loose here, though arguably it would benefit from some of the same protection (you wouldn't want to delete ".git/config" either, though again, we'd refuse to delete something we can't parse). [the mass test update is ugly; split it out?]
- Loading branch information
Showing
9 changed files
with
93 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...013/diff.diff-tree_--cc_--summary_REVERSE → ...iff.diff-tree_--cc_--summary_REVERSE_HEAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters