Project

General

Profile

Actions

Misc #16112

closed

Reduce the possibility of "expand tabs" commit occurrences

Added by k0kubun (Takashi Kokubun) over 5 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
[ruby-core:94428]

Description

Problem

  • While we agreed to use only spaces for indentation of C code in [Bug #14246], we sometimes hit "expand tabs" commit when we just edit a part of existing lines with hard tab indentation.
  • "expand tabs" commit bothers people when we need to perform a revert or a backport.
  • However, because [Bug #14246] aimed to eventually make indentations consistent, we do not want to just drop "expand tabs".
    • One of the motivations to solve [Bug #14246] is that having hard tabs makes preprocessed MJIT header ugly and it makes debugging on GCC hard. As MJIT may introduce C-code inlining for sources outside vm.c in the future, we want to fix the issue in almost all C sources which can be run on runtime.

Possible Solutions

There would be some options to approach the problem. I'd like to hear opinions about these options.

  1. Expand all tabs at once for all files managed by auto-style.
  • In [Bug #14246], this was clearly objected for the reason "Indents should become consistent over time".
  • In my understanding, not folliwng "Indents should become consistent over time" would be problematic mainly for polluting "git blame" and conflicts on backport.
  • Also reverting a commit before the commit expanding all tabs would be bothering, for a short while.
  1. Skip expand tabs for existing lines when indentation is not changed, and expand tabs only in newly-added lines.
  • If editors are configured properly, "expand tabs" would not happen for new patches in this approach.
  • Even in this approach, at least we will not go to the opposite direction of eventually achieving [Bug #14246]. So it seems acceptable.
  1. Prepare a local pre-commit hook to expand tabs in newly-added or edited lines, and let people who do not want an "expand tabs" commit use it.
  2. Make pull request CI fail when there's diff to be expanded, and let people who do not want "expand tabs" commit things from pull requests.

Files

Screen Shot 2019-08-19 at 2.43.06 PM.png (48.8 KB) Screen Shot 2019-08-19 at 2.43.06 PM.png VSCode rendering a snippet in ruby.c alanwu (Alan Wu), 08/19/2019 06:44 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14246: Inconsistent C source code indentationClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0