Skip to content

General git command-line issues. #16

@puellanivis

Description

@puellanivis

If git diff is run against a branch name or commit reference that is also a file, git diff will error out, and report that it has an ambiguous argument. Worse, if the commit reference does not exist, but the file does, then the git diff will happily only report changes in that single file.

In order to ensure that a commit reference is always taken as a commit reference, and only as a commit reference, you have to append -- after the commits. So, for revisionFrom = "master": git diff master -- is the unambiguous command-line. (git diff from to -- works as expected as well.)

Also, if one has a .gitconfig that has color.diff = always, the code that looks for changes silently breaks, since the lines starting with + are now starting with an ANSI color sequence instead. It’s recommended to always assume there could be some external default value-override set that could break the command-line output. Adding --color=never fixes this for git diff.

The note in the source about git ls-files showing directories, might be a result of some .gitconfig default overrides as well. Using git status --porcelain is the recommended way to get a reliably appropriate-for-script-processing output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions