Skip to content
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

refname 'stash' is ambiguous. #905

Closed
philipbjorge opened this issue Aug 18, 2020 · 2 comments
Closed

refname 'stash' is ambiguous. #905

philipbjorge opened this issue Aug 18, 2020 · 2 comments

Comments

@philipbjorge
Copy link
Contributor

Description

When you have a branch named stash, you receive the following error from lint-staged.

warning: refname 'stash' is ambiguous.
error: refname 'stash' is ambiguous
warning: refname 'stash' is ambiguous.
'--quiet stash@{0}' is not a stash reference 

Steps to reproduce

  1. git checkout -b stash
  2. git checkout -b some-other-branch
  3. touch foo.txt
  4. git add foo.txt
  5. git commit -m "test"

Expected:
Commits

Actual:

warning: refname 'stash' is ambiguous.
error: refname 'stash' is ambiguous
warning: refname 'stash' is ambiguous.
'--quiet stash@{0}' is not a stash reference 

Debug Logs

expand to view
2020-08-18T19:01:36.104Z lint-staged:bin Running `lint-staged@10.2.11`
2020-08-18T19:01:36.105Z lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  debug: true,
  maxArgLength: 65536,
  stash: true,
  quiet: false,
  relative: false,
  shell: false,
  verbose: false
}
2020-08-18T19:01:36.106Z lint-staged Loading config using `cosmiconfig`
2020-08-18T19:01:36.120Z lint-staged Successfully loaded config from `/home/betterup/betterup-app/.lintstagedrc.js`:
{
  '*.{json,md}': [Function: *.{json,md}],
  '*.{css,scss}': [Function: *.{css,scss}],
  '*.{rake,rb}': [Function: *.{rake,rb}],
  './app/**/*.js': [Function: ./app/**/*.js],
  './frontend/**/*.js': [Function: ./frontend/**/*.js],
  './frontend/**/*.hbs': [Function: ./frontend/**/*.hbs]
}
2020-08-18T19:01:36.120Z lint-staged:cfg Validating config
Running lint-staged with the following config:
{
  '*.{json,md}': (filenames) =>
    dockerAwareCommand(`yarn run prettier --write`, 'web', filenames),
  '*.{css,scss}': (filenames) => [
    dockerAwareCommand(`yarn run stylelint --fix`, 'web', filenames),
    dockerAwareCommand(`yarn run prettier --write`, 'web', filenames),
  ],
  '*.{rake,rb}': (filenames) =>
    dockerAwareCommand(
      `bin/rubocop --auto-correct --force-exclusion`,
      'spring',
      filenames
    ),
  './app/**/*.js': (filenames) =>
    dockerAwareCommand(`yarn run prettier --write`, 'web', filenames),
  './frontend/**/*.js': (filenames) => [
    dockerAwareCommand(
      `yarn --cwd frontend run eslint --fix`,
      'frontend',
      filenames
    ),
    dockerAwareCommand(`yarn run prettier --write`, 'web', filenames),
  ],
  './frontend/**/*.hbs': (filenames) =>
    dockerAwareCommand(
      `yarn --cwd frontend run ember-template-lint`,
      'frontend',
      filenames
    )
}
2020-08-18T19:01:36.121Z lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`)
2020-08-18T19:01:36.121Z lint-staged:run Running all linter scripts
2020-08-18T19:01:36.121Z lint-staged:resolveGitRepo Resolving git repo from `/home/betterup/betterup-app`
2020-08-18T19:01:36.121Z lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`)
2020-08-18T19:01:36.121Z lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`)
2020-08-18T19:01:36.121Z lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ]
2020-08-18T19:01:36.129Z lint-staged:resolveGitRepo Resolved git directory to be `/home/betterup/betterup-app`
2020-08-18T19:01:36.129Z lint-staged:resolveGitRepo Resolved git config directory to be `/home/betterup/betterup-app/.git`
2020-08-18T19:01:36.130Z lint-staged:git Running git command [ 'log', '-1' ]
2020-08-18T19:01:36.133Z lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACMR', '--name-only', '-z' ]
2020-08-18T19:01:36.137Z lint-staged:run Loaded list of staged files in git:
[ 'README.md' ]
2020-08-18T19:01:36.137Z lint-staged:chunkFiles Resolved an argument string length of 37 characters from 1 files
2020-08-18T19:01:36.138Z lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536
2020-08-18T19:01:36.138Z lint-staged:gen-tasks Generating linter tasks
2020-08-18T19:01:36.140Z lint-staged:gen-tasks Generated task: 
{
  pattern: '*.{json,md}',
  commands: [Function: *.{json,md}],
  fileList: [ '/home/betterup/betterup-app/README.md' ]
}
2020-08-18T19:01:36.140Z lint-staged:gen-tasks Generated task: 
{
  pattern: '*.{css,scss}',
  commands: [Function: *.{css,scss}],
  fileList: []
}
2020-08-18T19:01:36.140Z lint-staged:gen-tasks Generated task: 
{
  pattern: '*.{rake,rb}',
  commands: [Function: *.{rake,rb}],
  fileList: []
}
2020-08-18T19:01:36.141Z lint-staged:gen-tasks Generated task: 
{
  pattern: './app/**/*.js',
  commands: [Function: ./app/**/*.js],
  fileList: []
}
2020-08-18T19:01:36.141Z lint-staged:gen-tasks Generated task: 
{
  pattern: './frontend/**/*.js',
  commands: [Function: ./frontend/**/*.js],
  fileList: []
}
2020-08-18T19:01:36.141Z lint-staged:gen-tasks Generated task: 
{
  pattern: './frontend/**/*.hbs',
  commands: [Function: ./frontend/**/*.hbs],
  fileList: []
}
2020-08-18T19:01:36.141Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: *.{json,md}]
2020-08-18T19:01:36.142Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.142Z lint-staged:task args: [
  'run',
  'prettier',
  '--write',
  '/home/betterup/betterup-app/README.md'
]
2020-08-18T19:01:36.142Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.142Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: *.{css,scss}]
2020-08-18T19:01:36.143Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.143Z lint-staged:task args: [ 'run', 'stylelint', '--fix' ]
2020-08-18T19:01:36.143Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.143Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.143Z lint-staged:task args: [ 'run', 'prettier', '--write' ]
2020-08-18T19:01:36.143Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.143Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: *.{rake,rb}]
2020-08-18T19:01:36.143Z lint-staged:task cmd: bin/rubocop
2020-08-18T19:01:36.143Z lint-staged:task args: [ '--auto-correct', '--force-exclusion' ]
2020-08-18T19:01:36.143Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.143Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: ./app/**/*.js]
2020-08-18T19:01:36.143Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.143Z lint-staged:task args: [ 'run', 'prettier', '--write' ]
2020-08-18T19:01:36.143Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.143Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: ./frontend/**/*.js]
2020-08-18T19:01:36.143Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.143Z lint-staged:task args: [ '--cwd', 'frontend', 'run', 'eslint', '--fix' ]
2020-08-18T19:01:36.143Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.144Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.144Z lint-staged:task args: [ 'run', 'prettier', '--write' ]
2020-08-18T19:01:36.144Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.144Z lint-staged:make-cmd-tasks Creating listr tasks for commands [Function: ./frontend/**/*.hbs]
2020-08-18T19:01:36.144Z lint-staged:task cmd: yarn
2020-08-18T19:01:36.144Z lint-staged:task args: [ '--cwd', 'frontend', 'run', 'ember-template-lint' ]
2020-08-18T19:01:36.144Z lint-staged:task execaOptions: { preferLocal: true, reject: false, shell: false }
2020-08-18T19:01:36.144Z lint-staged:chunkFiles Resolved an argument string length of 37 characters from 1 files
2020-08-18T19:01:36.144Z lint-staged:chunkFiles Creating 1 chunks for maxArgLength of 65536
[STARTED] Preparing...
2020-08-18T19:01:36.146Z lint-staged:git Backing up original state...
2020-08-18T19:01:36.146Z lint-staged:git Getting partially staged files...
2020-08-18T19:01:36.146Z lint-staged:git Running git command [ 'status', '-z' ]
2020-08-18T19:01:36.171Z lint-staged:git Found partially staged files: []
2020-08-18T19:01:36.172Z lint-staged:git Backing up merge state...
2020-08-18T19:01:36.172Z lint-staged:file Reading file `/home/betterup/betterup-app/.git/MERGE_HEAD`
2020-08-18T19:01:36.172Z lint-staged:file Reading file `/home/betterup/betterup-app/.git/MERGE_MODE`
2020-08-18T19:01:36.172Z lint-staged:file Reading file `/home/betterup/betterup-app/.git/MERGE_MSG`
2020-08-18T19:01:36.172Z lint-staged:file File `/home/betterup/betterup-app/.git/MERGE_HEAD` doesn't exist, ignoring...
2020-08-18T19:01:36.172Z lint-staged:file File `/home/betterup/betterup-app/.git/MERGE_MODE` doesn't exist, ignoring...
2020-08-18T19:01:36.172Z lint-staged:file File `/home/betterup/betterup-app/.git/MERGE_MSG` doesn't exist, ignoring...
2020-08-18T19:01:36.172Z lint-staged:git Done backing up merge state!
2020-08-18T19:01:36.172Z lint-staged:git Getting deleted files...
2020-08-18T19:01:36.172Z lint-staged:git Running git command [ 'ls-files', '--deleted' ]
2020-08-18T19:01:36.185Z lint-staged:git Found deleted files: []
2020-08-18T19:01:36.185Z lint-staged:git Running git command [ 'stash', 'create' ]
2020-08-18T19:01:36.272Z lint-staged:git Running git command [
  'stash',
  'store',
  '--quiet',
  '--message',
  'lint-staged automatic backup',
  '9ba1212a13f3d1d74d57cddb787880a358b707e9'
]
2020-08-18T19:01:36.291Z lint-staged:git Done backing up original state!
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *.{json,md}
[STARTED] Running tasks for *.{css,scss}
[STARTED] Running tasks for *.{rake,rb}
[STARTED] Running tasks for ./app/**/*.js
[STARTED] Running tasks for ./frontend/**/*.js
[STARTED] Running tasks for ./frontend/**/*.hbs
[SKIPPED] No staged files match *.{css,scss}
[SKIPPED] No staged files match *.{rake,rb}
[SKIPPED] No staged files match ./app/**/*.js
[SKIPPED] No staged files match ./frontend/**/*.js
[SKIPPED] No staged files match ./frontend/**/*.hbs
[STARTED] yarn run prettier --write /home/betterup/betterup-app/README.md
[SUCCESS] yarn run prettier --write /home/betterup/betterup-app/README.md
[SUCCESS] Running tasks for *.{json,md}
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
2020-08-18T19:01:36.702Z lint-staged:git Adding task modifications to index...
2020-08-18T19:01:36.702Z lint-staged:git Running git command [ 'add', '--', '/home/betterup/betterup-app/README.md' ]
2020-08-18T19:01:36.707Z lint-staged:git Done adding task modifications to index!
2020-08-18T19:01:36.707Z lint-staged:git Running git command [ 'diff', '--name-only', '--cached' ]
[SUCCESS] Applying modifications...
[STARTED] Cleaning up...
2020-08-18T19:01:36.712Z lint-staged:git Dropping backup stash...
2020-08-18T19:01:36.712Z lint-staged:git Running git command [ 'stash', 'list' ]
2020-08-18T19:01:36.732Z lint-staged:git Running git command [ 'stash', 'drop', '--quiet', 'stash@{0}' ]
[FAILED] warning: refname 'stash' is ambiguous.
[FAILED] warning: refname 'stash' is ambiguous.
[FAILED] error: refname 'stash' is ambiguous
[FAILED] warning: refname 'stash' is ambiguous.
[FAILED] '--quiet stash@{0}' is not a stash reference

  ✖ lint-staged failed due to a git error.
  Any lost modifications can be restored from a git stash:

    > git stash list
    stash@{0}: automatic lint-staged backup
    > git stash apply --index stash@{0}


Environment

  • **OS:**Ubuntu 18.04.4
  • Node.js: 12.16.3
  • lint-staged: 10.2.11
@philipbjorge
Copy link
Contributor Author

Here is a potentially related issue that might assist with fixing this.
desktop/desktop#9848

@philipbjorge
Copy link
Contributor Author

So I see a couple ways of proceeding here...

  1. Stashes are stored at refs/stash and we could update this line with refs/ to disambiguate
    https://github.com/okonet/lint-staged/blob/b078324d5e911ec5e667736b2c552af32f475751/lib/gitWorkflow.js#L102

  2. Convert the call from git stash list to git log -g --pretty="%gD %H %gs" refs/stash which returns the disambiguated stash refs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant