jonschlinkert / git-branch

Get the current branch for a local git repository
https://github.com/jonschlinkert
MIT License
91 stars 16 forks source link

Support git-branch from a subdirectory #4

Closed jonathantneal closed 6 years ago

jonathantneal commented 6 years ago

I was hoping to run git-branch from a subdirectory and saw that it couldn’t look up a directory. This PR fixes that.

jonathantneal commented 6 years ago

This fixes the problem without introducing dependencies. Why did you close it?

jonschlinkert commented 6 years ago

Hi @jonathantneal, thanks for the pull request, but I didn't merge since it was a duplicate of #3.

jonschlinkert commented 6 years ago

This fixes the problem without introducing dependencies. Why did you close it?

Can you clarify? Do you mean, why did I merge the PR that was before yours? Or why did I merge it instead of yours, since yours didn't introduce dependencies?

jonathantneal commented 6 years ago

@jonschlinkert, the misunderstanding is mine. I made this PR initially unaware of the other one.

However, I was still thinking this PR was worth adding because it did not add dependencies to an otherwise dependency-less project, and it kept the asynchronous call asynchronous.

The method of detection that I added is fairly common, and is used in other similar libraries — for example https://github.com/soldair/node-gitconfiglocal/blob/master/index.js#L41-L48 (while the code is hardly 1:1, note that it’s the exact same strategy)