overcommit --run reports success when Git cannot read the index
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Empieza en GitRepo.all_files, que ejecuta dos comandos git ls-files con backticks sin comprobar, y compáralo con GitRepo.list_files, que ya verifica el resultado del comando y lanza un error de Overcommit. Verifica ambos resultados de enumeración y termina con un estado distinto de cero cuando Git no pueda leer el índice. Está terminado cuando un índice corrupto produce una salida distinta de cero, mientras que un índice válido vacío, una infracción normal y los archivos rastreados eliminados se comportan como antes. La cuestión del alcance sigue abierta para un mantenedor.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Reproduced separately on main 50f3e866bef75e3c3be7f92b47b1c45b6e7436ba (0.74.0), macOS 15.6.1, Ruby 4.0.7, Apple Git 2.50.1.
GitRepo.all_files does not check the exit status of either git ls-files command. If Git cannot read the index, both commands fail, but their empty stdout is treated as a valid empty file list. In a scratch repository with a configured TrailingWhitespace hook, the CLI prints Git's fatal errors followed by All pre-commit hooks passed, and exits 0.
Reproduction
- In a new disposable repository, configure only TrailingWhitespace with
include: ['**/*.rb']andon_warn: fail, and approve the fixture configuration withovercommit --sign. - Create and stage
normal.rbcontaining a trailing-space violation. Confirmovercommit --runexits 65. - Replace only that disposable repository's
.git/indexwith invalid synthetic bytes. No user repository or live index is needed. - Run
overcommit --runagain.
Observed stderr:
fatal: .git/index: index file smaller than expected
fatal: .git/index: index file smaller than expected
Observed stdout ends with:
All pre-commit hooks passed
Exit status is 0. A valid empty index also exits 0, so callers cannot distinguish the two states using the process status.
Expected behavior and scope question
When Git cannot enumerate the files to check, --run should report an enumeration error and return a nonzero status rather than success. GitRepo.list_files already checks command success and raises an Overcommit error; all_files currently uses unchecked backticks.
I checked #524: it concerned restoring the working tree/stash after normal pre-commit execution and did not provide a reproducible cause of index corruption. This report neither attributes index corruption to Overcommit nor asks it to repair a broken index. It is specifically about the standalone --run exit status once enumeration fails.
Would a separate change checking both enumeration command results be in scope? The controls would cover a valid empty index, normal violation, deleted tracked files, and Git enumeration failure. I would not combine it with filename parsing, stash handling, or index recovery.
- Lenguaje dominante
- Ruby
- Estrellas
- 4k
- Forks
- 288
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sds/overcommit
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
sds/overcommit#847 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 Medio día Aptitud para principiantes 62/100
sds/overcommit#908 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
sds/overcommit#875 ·
Los mantenedores suelen responder en 1 día
-
help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
sds/overcommit#869 ·
Los mantenedores suelen responder en 1 día
-
Please remove the default hooksAbierto
Dificultad 3/5 Medio día Aptitud para principiantes 25/100
sds/overcommit#856 ·
Los mantenedores suelen responder en 1 día
Todos los issues de sds/overcommit
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
seek4science/seek#2784 ·
Los mantenedores suelen responder en 2 días
-
Translation tutorial: snippet crashes on chunks export and misses simple { t } entriesPosiblemente ocupada @Mahdi-Hasan la tomó hoy. Abiertoresource-documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TarteelAI/quranic-universal-library#1020 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Records without the CRI logtag raise NoMethodError and are joined into the next recordPosiblemente ocupada @nazarli-shabnam la tomó hoy. Abiertobug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
swombat/souls-house#842 ·
Los mantenedores suelen responder en 1 día