`Index.add()` accepts files behind symlinks
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
Hey.
Not sure whether this is a bug or considered valid (though probably strange) usage, but Index.add() - and presumably Index.add_all() as well as IndexEntry, too - accept paths where even non-final components are symbolic links, like in symlink-to-dir/some-non-dir-file.
git-add itself rejects these with an error like:
$ git add symlink-to-dir/some-non-dir-file
fatal: pathspec 'symlink-to-dir/some-non-dir-file' is beyond a symbolic link
The Index object even uses these pathnames and doesn't just resolve them:
list(r.index)
[<pygit2.index.IndexEntry path=symlink-to-dir/some-non-dir-file id=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 mode=33188>]
Creating a commit of that works, too.
Now the problem with such pathnames is that symlink-to-dir is not added as a symbolic link to the index (at least not automatically), instead it seems to behave as if there were a true directory of that name which contained the file, but which is then immediately gone after adding.
IMO hat leads to all kinds of unexpected stuff (which is probably the reason why git-add forbids it instead of e.g either resolving it or doing something else (like resolving it and adding the file under its real dir).
Maybe pygit2 should also reject these? Not sure what libgit2 does, though.
Cheers,
Chris.
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 reproduire le comportement signalé de Index.add() avec un composant de symlink qui n’est pas le dernier, puis comparez-le au rejet du même chemin par git-add. Vérifiez si Index.add_all() et IndexEntry se comportent de la même manière et examinez le comportement correspondant de libgit2. Le travail est terminé lorsque le traitement attendu est établi et couvert par un test de régression.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- git, python
- Domaine
- devtools
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100