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

Use -- to separate arguments from paths #847

Merged
merged 1 commit into from
Apr 21, 2021
Merged

Use -- to separate arguments from paths #847

merged 1 commit into from
Apr 21, 2021

Conversation

JakeWharton
Copy link
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)

@@ -335,7 +335,7 @@ private String setLicenseHeaderYearsFromGitHistory(String raw, File file) throws
}

private static String parseYear(String cmd, File file) throws IOException {
String fullCmd = cmd + " " + file.getAbsolutePath();
String fullCmd = cmd + " -- " + file.getAbsolutePath();
Copy link
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
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
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