Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_whitespace [2018/06/11 10:48] – [Overview] rpjday | git_whitespace [2019/03/05 18:15] (current) – [git blame] rpjday | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Overview ===== | ===== Overview ===== | ||
| - | A moderately (dis)organized list of features related to dealing with whitespace issues in Git, in no particular order. | + | A moderately (dis)organized list of features related to dealing with whitespace issues in Git, in no particular order. |
| + | |||
| + | ===== config options ===== | ||
| + | |||
| + | ==== apply.ignoreWhitespace ==== | ||
| + | ==== apply.whitespace ==== | ||
| + | ==== core.whitespace ==== | ||
| + | |||
| + | < | ||
| + | $ git config --global core.whitespace \ | ||
| + | trailing-space, | ||
| + | </ | ||
| + | ==== core.eol ==== | ||
| + | ==== core.safecrlf ==== | ||
| + | ==== core.autocrlf ==== | ||
| + | |||
| + | Setting this variable to " | ||
| + | |||
| + | ===== git apply ===== | ||
| + | |||
| + | TO DO. | ||
| + | |||
| ===== git diff ===== | ===== git diff ===== | ||
| Line 10: | Line 32: | ||
| $ git diff --check | $ git diff --check | ||
| </ | </ | ||
| + | |||
| + | based on: | ||
| + | |||
| + | < | ||
| + | --check | ||
| + | Warn if changes introduce conflict markers or whitespace errors. What are | ||
| + | considered whitespace errors is controlled by core.whitespace configuration. | ||
| + | By default, trailing whitespaces (including lines that solely consist of | ||
| + | whitespaces) and a space character that is immediately followed by a tab | ||
| + | character inside the initial indent of the line are considered whitespace | ||
| + | errors. Exits with non-zero status if problems are found. Not compatible with | ||
| + | --exit-code. | ||
| + | |||
| + | --ws-error-highlight=< | ||
| + | Highlight whitespace errors in the context, old or new lines of the diff. | ||
| + | Multiple values are separated by comma, none resets previous values, default | ||
| + | reset the list to new and all is a shorthand for old, | ||
| + | option is not given, and the configuration variable diff.wsErrorHighlight is | ||
| + | not set, only whitespace errors in new lines are highlighted. The whitespace | ||
| + | errors are colored whith color.diff.whitespace. | ||
| + | </ | ||
| + | |||
| + | Other possibilities: | ||
| + | |||
| + | < | ||
| + | --ignore-space-at-eol | ||
| + | Ignore changes in whitespace at EOL. | ||
| + | |||
| + | -b, --ignore-space-change | ||
| + | Ignore changes in amount of whitespace. This ignores whitespace at line end, and | ||
| + | considers all other sequences of one or more whitespace characters to be equivalent. | ||
| + | |||
| + | -w, --ignore-all-space | ||
| + | Ignore whitespace when comparing lines. This ignores differences even if one line has | ||
| + | whitespace where the other line has none. | ||
| + | |||
| + | --ignore-blank-lines | ||
| + | Ignore changes whose lines are all blank. | ||
| + | </ | ||
| + | |||
| + | ===== git merge ===== | ||
| + | |||
| + | Recursive merge options: | ||
| + | |||
| + | < | ||
| + | ignore-space-change, | ||
| + | Treats lines with the indicated type of whitespace change as unchanged for the sake | ||
| + | of a three-way merge. Whitespace changes mixed with other changes to a line are not | ||
| + | ignored. See also git-diff(1) -b, -w, --ignore-space-at-eol, | ||
| + | |||
| + | · If their version only introduces whitespace changes to a line, our version is | ||
| + | used; | ||
| + | |||
| + | · If our version introduces whitespace changes but their version includes a | ||
| + | substantial change, their version is used; | ||
| + | |||
| + | · | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== git rebase ===== | ||
| + | |||
| + | < | ||
| + | --ignore-whitespace, | ||
| + | These flag are passed to the git apply program (see git-apply(1)) that applies | ||
| + | the patch. Incompatible with the --interactive option. | ||
| + | </ | ||
| + | |||
| + | From '' | ||
| + | |||
| + | < | ||
| + | --ignore-space-change, | ||
| + | When applying a patch, ignore changes in whitespace in context lines if | ||
| + | necessary. Context lines will preserve their whitespace, and they will not | ||
| + | undergo whitespace fixing regardless of the value of the --whitespace option. | ||
| + | New lines will still be fixed, though. | ||
| + | |||
| + | --whitespace=< | ||
| + | When applying a patch, detect a new or modified line that has whitespace | ||
| + | errors. What are considered whitespace errors is controlled by core.whitespace | ||
| + | configuration. By default, trailing whitespaces (including lines that solely | ||
| + | consist of whitespaces) and a space character that is immediately followed by | ||
| + | a tab character inside the initial indent of the line are considered | ||
| + | whitespace errors. | ||
| + | |||
| + | By default, the command outputs warning messages but applies the patch. When | ||
| + | git-apply is used for statistics and not applying a patch, it defaults to | ||
| + | nowarn. | ||
| + | | ||
| + | You can use different < | ||
| + | |||
| + | · | ||
| + | |||
| + | · warn outputs warnings for a few such errors, but applies the patch as-is | ||
| + | (default). | ||
| + | |||
| + | · fix outputs warnings for a few such errors, and applies the patch after | ||
| + | fixing them (strip is a synonym --- the tool used to consider only | ||
| + | trailing whitespace characters as errors, and the fix involved stripping | ||
| + | them, but modern Gits do more). | ||
| + | |||
| + | · error outputs warnings for a few such errors, and refuses to apply the | ||
| + | patch. | ||
| + | |||
| + | · | ||
| + | </ | ||
| + | |||
| + | ===== git blame ===== | ||
| + | |||
| + | < | ||
| + | -w | ||
| + | Ignore whitespace when comparing the parent’s version and the child’s to find | ||
| + | where the lines came from. | ||
| + | </ | ||
| + | |||
| + | ===== git stripspace ===== | ||
| + | |||
| + | < | ||
| + | $ man git-stripspace | ||
| + | </ | ||
| + | |||