Staged area modified after cross branch checkout
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.7k
- Forks
- 408
- Merge moyen
- 2 j 57 min
- PR mergées (30 j)
- 7
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par exécuter le reproducer test_checkout fourni et examinez le comportement de repo.checkout et repo.index lors des deux changements de branche. Comparez l’index staged après le retour sur master avec l’état vide attendu, et vérifiez le résultat par rapport au comportement décrit de git checkout.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- git, python
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100