arxanas / git-branchless

High-velocity, monorepo-scale workflow for Git
Apache License 2.0
3.37k stars 80 forks source link

Error message: "Could not parse OID from string ref:refs/heads/main" #1321

Open jblebrun opened 1 month ago

jblebrun commented 1 month ago

Description of the bug

I've started to see an error appearing when I navigate between branches in git branchless:

2024-05-22T18:25:56.228109Z ERROR git_branchless_hook: Could not parse reference-transaction-line err=
   0: Could not parse OID from string ref:refs/heads/main
   1: Git error GenericError: unable to parse OID - contains invalid characters

Location:
   git-branchless-lib/src/git/repo.rs:289

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   0: git_branchless_hook::reference_transaction::parse_reference_transaction_line with line="0000000000000000000000000000000000000000 ref:refs/heads/main HEAD"
      at git-branchless-hook/src/lib.rs:289
   1: git_branchless_hook::hook_reference_transaction with effects=<Output fancy=false> transaction_state="committed"
      at git-branchless-hook/src/lib.rs:418
   2: git_branchless_hook::command_main with ctx=CommandContext { effects: <Output fancy=false>, git_run_info: <GitRunInfo path_to_git="git" working_directory="/usr/local/google/home/jibbl/Projects/oak" env=not shown> } args=HookArgs { subcommand: ReferenceTransaction { transaction_state: "committed" } }
      at git-branchless-hook/src/lib.rs:527

It seems that it somehow gets the value ref:refs/heads/main in a position where a commit hash is expected.

I'm still digging into this more, but figured I'd file a bug in case anyone else has any hunches about what might be happening. So far, all I can say is that I can't find any entry in the SQLite db that contains ref:refs/heads/main in that position; so I'm not sure where that's being introduced.

It seems that it's related to the state of the repository; even when I check out a fresh copy of the repository, this is happening. It just started happening yesterday or today, so perhaps it's somehow related to some commit metadata?

Functionally, everything still seems to work OK (it still switches tot he branch, for example).

Expected behavior

I expect the message not to appear.

Actual behavior

The message appears.

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

0.8.0

Version of git

2.45.1.288.patched (internal company version)

jblebrun commented 1 month ago

It looks like this may be related to this recent change in git:

https://github.com/git/git/commit/a8ae923f85da6434c3faf9c39719d6d5e5c77e65

jblebrun commented 1 month ago

I think I have a fix.