* Having an invalid HEAD file causes git not to recognize the repository
@ 2012-08-17 11:42 Egon Elbre
2012-08-21 7:24 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Egon Elbre @ 2012-08-17 11:42 UTC (permalink / raw)
To: git
Having an invalid HEAD file causes git not to recognize the repository
and will cause an invalid message "fatal: Not a git repository (or any
of the parent directories): .git" although there is a .git folder and
everything seems okay in it. Solution was just to change HEAD to a
valid ref/hash.
I ran into this problem when I had a BSOD during a rebase (ignore that
I'm having to use Windows). This meant that only half of the hash got
written into HEAD and all git commands I tried failed.
Not sure whether it's useful to add a better message for this case,
but at least if somebody stumbles on it again, maybe they can find
this text.
+ egon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Having an invalid HEAD file causes git not to recognize the repository
2012-08-17 11:42 Having an invalid HEAD file causes git not to recognize the repository Egon Elbre
@ 2012-08-21 7:24 ` Jeff King
2012-08-21 8:07 ` Egon Elbre
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2012-08-21 7:24 UTC (permalink / raw)
To: Egon Elbre; +Cc: git
On Fri, Aug 17, 2012 at 02:42:33PM +0300, Egon Elbre wrote:
> Having an invalid HEAD file causes git not to recognize the repository
> and will cause an invalid message "fatal: Not a git repository (or any
> of the parent directories): .git" although there is a .git folder and
> everything seems okay in it. Solution was just to change HEAD to a
> valid ref/hash.
Right. When we search for a .git directory, we do a few sanity checks on
each candidate, like whether it has a properly-formatted HEAD, and
whether it has "objects" and "refs" directories. We have to balance
these heuristics to avoid false negatives (like yours, when the
directory was meant to be a repository but looked bogus) with false
positives (when we accidentally treat some random directory like a git
repository).
Since you don't have a working repository, the best we could do is say
"well, this looks like a repository, but it's broken, so I kept
looking". I think the best approach would probably be to have a new
GIT_TRACE_GITDIR environment variable to help debug git-dir lookup
(i.e., to print out details of the search as it happens).
> I ran into this problem when I had a BSOD during a rebase (ignore that
> I'm having to use Windows). This meant that only half of the hash got
> written into HEAD and all git commands I tried failed.
That generally shouldn't happen, as we write new ref content to a
temporary file and then rename it into place atomically. I wonder if
there is a problem with the atomicity there (we do not fsync after
close, which some filesystems might want), or if it was simply
filesystem corruption related to your BSOD.
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Having an invalid HEAD file causes git not to recognize the repository
2012-08-21 7:24 ` Jeff King
@ 2012-08-21 8:07 ` Egon Elbre
0 siblings, 0 replies; 3+ messages in thread
From: Egon Elbre @ 2012-08-21 8:07 UTC (permalink / raw)
To: Jeff King; +Cc: git
On Tue, Aug 21, 2012 at 10:24 AM, Jeff King <peff@peff.net> wrote:
>
>> I ran into this problem when I had a BSOD during a rebase (ignore that
>> I'm having to use Windows). This meant that only half of the hash got
>> written into HEAD and all git commands I tried failed.
>
> That generally shouldn't happen, as we write new ref content to a
> temporary file and then rename it into place atomically. I wonder if
> there is a problem with the atomicity there (we do not fsync after
> close, which some filesystems might want), or if it was simply
> filesystem corruption related to your BSOD.
>
It's a truecrypt drive and I had to run diskcheck on the drive
(because of bad unmounting). In essence the file could have been
invalid and just restored it to some invalid usable state. Also it
might be truecrypt atomicity problem.
+egon
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-21 8:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17 11:42 Having an invalid HEAD file causes git not to recognize the repository Egon Elbre
2012-08-21 7:24 ` Jeff King
2012-08-21 8:07 ` Egon Elbre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).