]> git.proxmox.com Git - libgit2.git/commit
refspec: do not set empty rhs for fetch refspecs
authorPatrick Steinhardt <ps@pks.im>
Thu, 4 Aug 2016 11:45:28 +0000 (13:45 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 4 Aug 2016 11:54:19 +0000 (13:54 +0200)
commit1eee631d1189312219773e699d76848680c02e19
treec67d400b9d137e9020a85d9003c99e5e9b917d62
parentbaa87dfc5033364ab5ac71099725f8f6c3e6361c
refspec: do not set empty rhs for fetch refspecs

According to git-fetch(1), "[t]he colon can be omitted when <dst>
is empty." So according to git, the refspec "refs/heads/master"
is the same as the refspec "refs/heads/master:" when fetching
changes. When trying to fetch from a remote with a trailing
colon with libgit2, though, the fetch actually fails while it
works when the trailing colon is left out. So obviously, libgit2
does _not_ treat these two refspec formats the same for fetches.

The problem results from parsing refspecs, where the resulting
refspec has its destination set to an empty string in the case of
a trailing colon and to a `NULL` pointer in the case of no
trailing colon. When passing this to our DWIM machinery, the
empty string gets translated to "refs/heads/", which is simply
wrong.

Fix the problem by having the parsing machinery treat both cases
the same for fetch refspecs.
src/refspec.c
tests/online/fetchhead.c