[Nix#9359] nix fmt formats files in .git, leading to a corrupted repository #101

Open
opened 2024-03-16 06:44:54 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#9359

Describe the bug

If you make a git branch/tag whose name ends in .nix, git creates files like .git/refs/heads/add-stuff-to-default.nix that don't contain nix code but end up being "formatted" by nix fmt anyway. This leads to a corrupted git repository and very confusing messages like:

$ git log
fatal: your current branch appears to be broken
$ git checkout
fatal: You are on a branch yet to be born
$ git stash save
You do not have the initial commit yet

Steps To Reproduce

  1. Make a flake and add a formatter
  2. git switch -C add-stuff-to-default.nix
  3. nix fmt
  4. everything gets really fucky

Expected behavior

I think nix fmt should entirely ignore .git. Perhaps it should also skip gitignored stuff, but I'm not sure.

nix-env --version output

nix-env (Nix) 2.13.6

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9359 **Describe the bug** If you make a git branch/tag whose name ends in .nix, git creates files like `.git/refs/heads/add-stuff-to-default.nix` that don't contain nix code but end up being "formatted" by `nix fmt` anyway. This leads to a corrupted git repository and very confusing messages like: ``` $ git log fatal: your current branch appears to be broken $ git checkout fatal: You are on a branch yet to be born $ git stash save You do not have the initial commit yet ``` **Steps To Reproduce** 1. Make a flake and add a formatter 2. `git switch -C add-stuff-to-default.nix` 3. `nix fmt` 4. everything gets really fucky **Expected behavior** I think `nix fmt` should entirely ignore `.git`. Perhaps it should also skip gitignored stuff, but I'm not sure. **`nix-env --version` output** `nix-env (Nix) 2.13.6`
lix-bot added the
bug
imported
labels 2024-03-16 06:44:54 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#101
No description provided.