Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shellgit: Ensure the passed filepath to diff-index is interpreted as …
…filepath Simplified, the code in the past was like this (data/roles/pe_primary.yaml is a random test file): `git diff-index -p HEAD data/roles/pe_primary.yaml` Which results in the following error if the file is tracked in git but was deleted locally: ``` $ git status HEAD detached at 3140475 Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) deleted: data/roles/pe_primary.yaml Untracked files: (use "git add <file>..." to include in what will be committed) .r10k-deploy.json .resource_types/ modules/ no changes added to commit (use "git add" and/or "git commit -a") $ git diff-index -p HEAD data/roles/pe_primary.yaml fatal: ambiguous argument 'data/roles/pe_primary.yaml': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' $ echo $? 128 ``` With adding `--` to the command, we ensure it's interpreted as path. This changes the exit code to 0. ``` $ git status HEAD detached at 3140475 Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) deleted: data/roles/pe_primary.yaml Untracked files: (use "git add <file>..." to include in what will be committed) .r10k-deploy.json .resource_types/ modules/ no changes added to commit (use "git add" and/or "git commit -a") $ git diff-index -p HEAD -- data/roles/pe_primary.yaml diff --git a/data/roles/pe_primary.yaml b/data/roles/pe_primary.yaml deleted file mode 100644 index b827047..0000000 --- a/data/roles/pe_primary.yaml +++ /dev/null @@ -1,48 +0,0 @@ ---- -classes: - - profiles::nftables $ echo $? 0 ``` Why do we do this change? This ensures r10k can properly handle checkouts that were modified.
- Loading branch information