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

safer git?

From
Hhv@crypt.org <hv@crypt.org>
Date
Oct 24, 2020, 20:19 UTC
Message-ID
<202010242019.09OKJTP13180@crypt.org>

Hi, due to a hardware or firmware issue, my machine is currently crashing rather a lot. If that happens around the time I'm performing any git activity, it seems quite likely to cause substantial corruption of the git state.

I've responded both by running sync(1) every 60 seconds and by pushing work to github more frequently, but the latter isn't appropriate for everything; twice recently I've lost a fair bit of work as a result.

Q: Is there a mode in which I can run git that would make it a bit more
robust against crashes, at the cost of being a bit slower?

The primary symptom is that files modified shortly before a crash show up existing but zero-length after the crash. For source files I mostly know what to do in that situation, but `git fsck` shows a lot of files under '.git/objects' that are empty, which seems to make things hard to recover:

% git fsck error: object file .git/objects/0e/f31631726cea2e9bf89d7bbe7b924b5282d533 is empty error: unable to mmap .git/objects/0e/f31631726cea2e9bf89d7bbe7b924b5282d533: No such file or directory error: 0ef31631726cea2e9bf89d7bbe7b924b5282d533: object corrupt or missing: .git/objects/0e/f31631726cea2e9bf89d7bbe7b924b5282d533 [... a dozen similar entries ...] error: object file .git/objects/f5/a9d125645e69a0e40f9bf7a8c90b1c1c4a4ea5 is empty error: unable to mmap .git/objects/f5/a9d125645e69a0e40f9bf7a8c90b1c1c4a4ea5: No such file or directory error: f5a9d125645e69a0e40f9bf7a8c90b1c1c4a4ea5: object corrupt or missing: .git/objects/f5/a9d125645e69a0e40f9bf7a8c90b1c1c4a4ea5 Checking object directories: 100% (256/256), done. Checking objects: 100% (1577/1577), done. error: refs/stash: invalid sha1 pointer 0000000000000000000000000000000000000000 error: bad ref for .git/logs/refs/stash dangling commit 1c0ea4e6159952501957012d2b9db7d68b52d107 %

Last time I checked out the previous state from github in a new
directory and was able to find and copy over most of my work before
continuing. On this occasion I did a `git stash save` shortly before
the crash, and I'm not sure how to get that back. I see René Scharfe's
suggestion of:
  git fsck --unreachable |
  grep commit | cut -d\  -f3 |
  xargs git log --merges --no-walk --grep=WIP
from a recent message, but that is only showing me an older stash item.
Thanks in advance for any suggestions,
Hugo van der Sanden
Next: hv@crypt.org
Message 1 of 6 in “safer git?”
  1. hv@crypt.orgOct 24, 2020
  2. hv@crypt.orgOct 24, 2020
  3. Randall S. BeckerOct 24, 2020
  4. brian m. carlsonOct 25, 2020
  5. hv@crypt.orgOct 25, 2020
  6. Randall S. BeckerOct 25, 2020

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.