Skip to content

Improved error message of rev_parse #789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

mpapis
Copy link
Contributor

@mpapis mpapis commented May 14, 2025

Description

Improved error message of rev_parse

As described by git-rev-parse:

  Many Git porcelainish commands take mixture of flags (i.e. parameters
  that begin with a dash -) and parameters meant for the underlying git
  rev-list command they use internally and flags and parameters for the
  other commands they use downstream of git rev-list. This command is
  used to distinguish between them.

Using the -- to separate revisions from paths is at the core of git. I do not think this behavior will ever change.

The message without the extra parameters:

  fatal: ambiguous argument 'v3': unknown revision or path not in the
  working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

The message with new parameters:

  fatal: bad revision 'NOTFOUND'

I think it's way more descriptive.

As described by git-rev-parse:
  Many Git porcelainish commands take mixture of flags (i.e. parameters
  that begin with a dash -) and parameters meant for the underlying git
  rev-list command they use internally and flags and parameters for the
  other commands they use downstream of git rev-list. This command is
  used to distinguish between them.

Using the `--` to separate revisions from paths is at the core of git.
I do not think this behavior will ever change.

The message without the extra parameters:
  fatal: ambiguous argument 'v3': unknown revision or path not in the
  working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

The message with new parameters:
  fatal: bad revision 'NOTFOUND'

I think it's way more descriptive.
Copilot

This comment was marked as resolved.

@ruby-git ruby-git deleted a comment from Copilot AI May 14, 2025
Copy link
Member

@jcouball jcouball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good... short and sweet!

@jcouball jcouball merged commit b47eedc into ruby-git:master May 14, 2025
7 checks passed
@jcouball
Copy link
Member

jcouball commented May 14, 2025

@mpapis I just pushed git-3.0.1 to RubyGems with this fix.

@mpapis mpapis deleted the improve-rev_parse-error branch May 23, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants