Commit 666c036
committed
Make HEAD lookups work with reftable
Git has a new ref storage backend called reftable that stores all refs,
including HEAD, as well as all reflogs, in a binary format under
.git/reftable. Because the HEAD file is important in determining
whether a directory is a Git repository, Git retains this file, but it
always contains "ref: refs/heads/.invalid", thus pointing to an invalid
ref, since ref components may not start with a dot.
In such a configuration, the only practical possibility is to invoke a
Git command to resolve HEAD for us, so use git rev-parse to do so. Look
up the object ID and the value for HEAD at the same time to avoid the
overhead of two calls and use the former if the latter is HEAD (that is,
we're not on a branch).
Unfortunately, this doesn't work when we have an unborn branch without
any commits, such as when a repository is newly initialized. Fall back
to git symbolic-ref in such a case.
Note that the head cache cannot be preserved here because the .git/HEAD
file does not have to change when the branch changes with reftable (in
fact, it will not), so remove that code here.1 parent 4a745ea commit 666c036
1 file changed
+13
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1031 | 1033 | | |
1032 | | - | |
1033 | 1034 | | |
1034 | | - | |
| 1035 | + | |
1035 | 1036 | | |
1036 | | - | |
| 1037 | + | |
1037 | 1038 | | |
1038 | | - | |
| 1039 | + | |
1039 | 1040 | | |
1040 | | - | |
1041 | | - | |
| 1041 | + | |
| 1042 | + | |
1042 | 1043 | | |
1043 | 1044 | | |
1044 | 1045 | | |
| |||
0 commit comments