git-branchless icon indicating copy to clipboard operation
git-branchless copied to clipboard

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

Open jblebrun opened this issue 1 year ago • 4 comments

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 avatar May 22 '24 18:05 jblebrun

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

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

jblebrun avatar May 22 '24 19:05 jblebrun

I think I have a fix.

jblebrun avatar May 22 '24 20:05 jblebrun

Hi,

Sorry if this was already planned, but since it seems to me that this was fixed more than 2 months ago, do you think it would be possible to make a new release that contains the fix?

tperami avatar Aug 20 '24 11:08 tperami

#1388 and #1381 seem to be duplicates

edward-evans-aiven avatar Aug 23 '24 00:08 edward-evans-aiven

Closing as duplicate of https://github.com/arxanas/git-branchless/issues/1388; follow there for updates.

arxanas avatar Oct 09 '24 12:10 arxanas