jj icon indicating copy to clipboard operation
jj copied to clipboard

Can't `forget` a branch with an illegal character

Open BatmanAoD opened this issue 1 year ago • 4 comments

Description

jj permits creating branches with names that cannot be exported to git. These branches can be renamed using jj branch rename, but they cannot be removed using jj branch forget.

(I consider this is a pretty minor/low-priority bug, because rename is suggested by the error message and it works fine.)

Steps to Reproduce the Problem

  1. Create a branch with an illegal punctuation mark, e.g. foo:
  2. Attempt to forget the branch

Expected Behavior

Either branch creation fails, or the branch forget call succeeds.

Actual Behavior

jj prints an Invalid string pattern error:

❯ jj branch create foo:
Failed to export some branches:
  foo:: Failed to set: A reference must be a valid tag name as well: A ref must not contain invalid bytes or ascii control characters: ":"
Hint: Git doesn't allow a branch name that looks like a parent directory of
another (e.g. `foo` and `foo/bar`). Try to rename the branches that failed to
export or their "parent" branches.

❯ jj branch forget 'foo:'
error: invalid value 'foo:' for '[NAMES]...': Invalid string pattern kind "foo"

For more information, try '--help'.

Specifications

  • Platform: Mac OS Sonama 14.3.1, Apple Silicon
  • Version: built from the advanceable-branches branch

BatmanAoD avatar Mar 06 '24 00:03 BatmanAoD

❯ jj branch forget 'foo:' error: invalid value 'foo:' for '[NAMES]...': Invalid string pattern kind "foo"

You'll need to prefix it as exact:foo: because NAME is is a pattern. I agree that the error message is unclear, btw.

yuja avatar Mar 06 '24 02:03 yuja

What does "NAME is a pattern" mean?

BatmanAoD avatar Mar 06 '24 03:03 BatmanAoD

https://martinvonz.github.io/jj/v0.14.0/revsets/#string-patterns (note: the default in jj branch subcommands is exact match)

yuja avatar Mar 06 '24 03:03 yuja

Ah, okay, thanks.

BatmanAoD avatar Mar 06 '24 03:03 BatmanAoD