libgit2 / libgit2/pygit2

`Index.add()` accepts files behind symlinks

Aperta
#1,375 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
1.7k
Fork
408
Merge medio
2g 57m
PR unite (30g)
7

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il comportamento segnalato di Index.add() con un componente symlink non finale, quindi confrontalo con il rifiuto dello stesso percorso da parte di git-add. Verifica se Index.add_all() e IndexEntry si comportano in modo analogo e esamina il comportamento corrispondente di libgit2. Il lavoro è completato quando la gestione prevista è stata stabilita ed è coperta da un test di regressione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
git, python
Ambito
devtools
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.