diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-07 15:00:11 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-09 16:07:43 +0100 |
commit | aad638f3a1e4d98296c2ec9c4ed08f217a652c5c (patch) | |
tree | 4276b661b94c788f5aca4c5757846af758bf89d3 /src/refspec.c | |
parent | b4e5432ff032c7d05c82ad2871e27f990493d6b7 (diff) | |
download | libgit2-cmn/push-refspec-refactor.tar.gz |
push: use the common refspec parsercmn/push-refspec-refactor
There is one well-known and well-tested parser which we should use,
instead of implementing parsing a second time.
The common parser is also augmented to copy the LHS into the RHS if the
latter is empty.
The expressions test had to change a bit, as we now catch a bad RHS of a
refspec locally.
Diffstat (limited to 'src/refspec.c')
-rw-r--r-- | src/refspec.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/refspec.c b/src/refspec.c index 9f0df35a7..a56c44cc0 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -119,6 +119,12 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch) if (!git_reference__is_valid_name(refspec->dst, flags)) goto invalid; } + + /* if the RHS is empty, then it's a copy of the LHS */ + if (!refspec->dst) { + refspec->dst = git__strdup(refspec->src); + GITERR_CHECK_ALLOC(refspec->dst); + } } refspec->string = git__strdup(input); |