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

"start line should be at least 1" removing first line from file #32

Open
benjackson-btcs opened this issue Feb 29, 2024 · 0 comments
Open

Comments

@benjackson-btcs
Copy link

benjackson-btcs commented Feb 29, 2024

Issue:

When removing the first line from a file, the pre-commit hook fails with the following error, preventing commit.

[test-clang-format-repo]$ git commit -m "Test file remove first line"
error: start line should be at least 1

The apply-format script failed.
[test-clang-format-repo]$

Steps to reproduce:

  1. mkdir test-clang-format-repo && cd test-clang-format-repo && git init .
  2. /path/to/this/repo/git-pre-commit-format install
  3. Create TestFile.cc with:

#include <iostream>

int main() {
  std::cout << "Hello, clang" << std::endl;
  return 0;
    }

(note first line is empty)

  1. git add 'TestFile.cc' && git commit -m "test file"
  2. accept the suggested correction (to the indentation)
  3. edit TestFile.cc and remove the first (empty) line
  4. git add 'TestFile.cc' && git commit -m "remove first line"

Expected behaviour:

  • commit is successful

Actual behaviour:

error: start line should be at least 1

The apply-format script failed.

[test-clang-format-repo]$ git status
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   Testfile.cc

Change is still stashed.

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

No branches or pull requests

1 participant