Skip to content

Use -- to separate arguments from paths#847

Merged
nedtwigg merged 1 commit intodiffplug:mainfrom
JakeWharton:patch-1
Apr 21, 2021
Merged

Use -- to separate arguments from paths#847
nedtwigg merged 1 commit intodiffplug:mainfrom
JakeWharton:patch-1

Conversation

@JakeWharton
Copy link
Copy Markdown
Contributor

@JakeWharton JakeWharton commented Apr 21, 2021

Some paths have characters which make them ambiguous as to whether they're a path or argument

For example,

$ git log --follow --find-renames=40% --reverse a/b-c-d/e.txt
fatal: ambiguous argument 'a/b-c-d/e.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

$ echo $?
128

compared to

$ git log --follow --find-renames=40% --reverse -- a/b-c-d/e.txt

$ echo $?
0

Please add a commit that adds a bullet-point under the -SNAPSHOT section of CHANGES.md, plugin-gradle/CHANGES.md, and plugin-maven/CHANGES.md which includes:

  • a summary of the change
  • either
    • a link to the issue you are resolving (for small changes)
    • a link to the PR you just created (for big changes likely to have discussion)


private static String parseYear(String cmd, File file) throws IOException {
String fullCmd = cmd + " " + file.getAbsolutePath();
String fullCmd = cmd + " -- " + file.getAbsolutePath();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unsure if it's best to assume the cmd supports this, or whether it's better to hoist it up into the caller's strings for each command. Let me know...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks.

Some paths have characters which make them ambiguous as to whether they're a path or argument

For example,

    $ git log --follow --find-renames=40% --reverse a/b-c-d/e.txt
    fatal: ambiguous argument 'a/b-c-d/e.txt': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

    $ echo $?
    128

compared to

    $ git log --follow --find-renames=40% --reverse -- a/b-c-d/e.txt

    $ echo $?
    0
@nedtwigg nedtwigg merged commit 7b70080 into diffplug:main Apr 21, 2021
@JakeWharton JakeWharton deleted the patch-1 branch April 21, 2021 16:22
@nedtwigg
Copy link
Copy Markdown
Member

nedtwigg commented Apr 21, 2021

Thanks! Published in plugin-gradle 5.12.3 and plugin-maven 2.10.3.

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