Staged area modified after cross branch checkout
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 1.7k
- Forks
- 408
- Merge medio
- 2 d 57 min
- PR fusionados (30 d)
- 7
Descripción
I created two branches with commits like this:
Then I call checkout to switch the branch from old_master to master. Somehow, the cached area is updated after checkout:
Here's the code toe reproduce
import pathlib
import pygit2
def test_checkout(tmp_path: pathlib.Path):
repo_dir = tmp_path
git_author = pygit2.Signature(name="foo", email="foo@bar.com")
repo = pygit2.init_repository(str(repo_dir))
workdir = pathlib.Path(repo.workdir)
readme = workdir / "README.md"
readme.write_text("commit0")
index = repo.index
index.add(readme.relative_to(workdir).as_posix())
index.write()
tree = index.write_tree()
commit0 = repo.create_commit("HEAD", git_author, git_author, "commit0", tree, [])
master_branch = repo.branches.local["master"]
old_master_branch = repo.branches.local.create("old_master", master_branch.peel())
readme.write_text("commit1")
index = repo.index
index.add(readme.relative_to(workdir).as_posix())
index.write()
tree = index.write_tree()
repo.create_commit(repo.head.name, git_author, git_author, "commit1", tree, [commit0])
repo.checkout(old_master_branch)
readme.write_text("commit2")
index = repo.index
index.add(readme.relative_to(workdir).as_posix())
index.write()
tree = index.write_tree()
repo.create_commit(repo.head.name, git_author, git_author, "commit2", tree, [commit0])
repo.checkout(master_branch)
# the staged area should be empty after checkout
assert not list(repo.index)
I tried it with git checkout master and it works fine without changing the staged area.
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.
Línea de trabajo
Comienza ejecutando el reproductor test_checkout proporcionado e inspecciona el comportamiento de repo.checkout y repo.index durante los dos cambios de rama. Compara el índice en staging después de volver a master con el estado vacío esperado y verifica el resultado con respecto al comportamiento descrito de git checkout.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- git, python
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100