cjb / GitTorrent

A decentralization of GitHub using BitTorrent and Bitcoin
MIT License
4.75k stars 262 forks source link

gittorrentd: Check cwd for .git/, too. #27

Open splinterofchaos opened 9 years ago

splinterofchaos commented 9 years ago

From the commit message:

.git/git-daemon-export-ok may exist relative to the current directory, and the user may not want to supply all repositories from its parent.

Also, if you have a slow computer like I do and have hundreds of cloned repositories, glob('*/...') can take a very long time, making it seem like nothing's happening.

Will this file ever contain useful information, because it also might conversely be nice to allow users to pass a flag, like --export-all, to supply all repositories whether or not it has a .git/git-daemon-export-ok file.

splinterofchaos commented 9 years ago

lol, looks like @anarcat made a PR for the same issue right when I did. (#26)

I like that solution more. Still curious about the --export-all flag, too, though.

anarcat commented 9 years ago

well, my thing is different: you seem to be wanting to torrent the git repository in the current directory. my PR adds bare repository support.

i think your PR is still relevant because of POLA...

splinterofchaos commented 9 years ago

Oh, I misread your PR (and misunderstood what "bare" meant). I had looked for a way to express the subdirectory being option, without using **, in glob(...), but couldn't find one.

anarcat commented 9 years ago

maybe ?(*/)?(.git/)git-daemon-export-ok?

anarcat commented 9 years ago

?() doesn't seem to do what i think it does. try this instead: {,*/,*/.git/}git-daemon-export-ok.

splinterofchaos commented 9 years ago

That's perfect. How about you just add that to #29 or #26 and I'll close this.

splinterofchaos commented 9 years ago

Oh wait, doesn't work if the .git is in the current directory.

splinterofchaos commented 9 years ago

Use this:

glob.sync('{,.git/,*/.git/}git-daemon-export-ok')
amirouche commented 9 years ago

:+1: but it's requires a reponame.

anarcat commented 9 years ago

@splinterofchaos #29 was merged, i suggest you reroll this PR...

anarcat commented 9 years ago

the reason why i didn't do it was that i wasn't sure it would work with no subdirs... and i couldn't test it easily.

splinterofchaos commented 9 years ago

Rebased.

but it's requires a reponame.

Thanks, fixed.

EDIT: Actually, fixed is not the word I'd use: better. Do we use the information of the repository's name to inform peers that our branches/sha's beling to it? I think we need a better way of identifying them as directory names might not correspond one-to-one with repositories.