Staged area modified after cross branch checkout
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 1.7k
- Fork
- 408
- Merge medio
- 2g 57m
- PR unite (30g)
- 7
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo il riproduttore test_checkout fornito e analizza il comportamento di repo.checkout e repo.index durante i due cambi di branch. Confronta l’indice in staging dopo essere tornato a master con lo stato vuoto previsto e verifica il risultato rispetto al comportamento descritto di git checkout.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- git, python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100