Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
refspec: convert valid_fetch_refspec to use parse_refspec
author
Brandon Williams
<bmwill@google.com>
Wed, 16 May 2018 22:57:52 +0000
(15:57 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 17 May 2018 21:19:42 +0000
(06:19 +0900)
Convert 'valid_fetch_refspec()' to use the new 'parse_refspec()'
function to only parse a single refspec and eliminate an allocation.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refspec.c
patch
|
blob
|
history
refspec.h
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
6d4c057
)
diff --git
a/refspec.c
b/refspec.c
index af9d0d4b30815b8a78b7c3c7ed12a16648e6aa18..ab37b5ba1ef8303a49e6b96c1c8d709eeb5ccf86 100644
(file)
--- a/
refspec.c
+++ b/
refspec.c
@@
-146,15
+146,6
@@
static struct refspec_item *parse_refspec_internal(int nr_refspec, const char **
die("Invalid refspec '%s'", refspec[i]);
}
die("Invalid refspec '%s'", refspec[i]);
}
-int valid_fetch_refspec(const char *fetch_refspec_str)
-{
- struct refspec_item *refspec;
-
- refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
- free_refspec(1, refspec);
- return !!refspec;
-}
-
struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec)
{
return parse_refspec_internal(nr_refspec, refspec, 1, 0);
struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec)
{
return parse_refspec_internal(nr_refspec, refspec, 1, 0);
@@
-242,3
+233,11
@@
void refspec_clear(struct refspec *rs)
rs->fetch = 0;
}
rs->fetch = 0;
}
+
+int valid_fetch_refspec(const char *fetch_refspec_str)
+{
+ struct refspec_item refspec;
+ int ret = parse_refspec(&refspec, fetch_refspec_str, REFSPEC_FETCH);
+ refspec_item_clear(&refspec);
+ return ret;
+}
diff --git
a/refspec.h
b/refspec.h
index da3135825f93d21db7f8940799a8b2f39f577b28..1063c64ccc245350f03c3066fc6c90026cd7dc60 100644
(file)
--- a/
refspec.h
+++ b/
refspec.h
@@
-14,7
+14,6
@@
struct refspec_item {
char *dst;
};
char *dst;
};
-int valid_fetch_refspec(const char *refspec);
struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
struct refspec_item *parse_fetch_refspec(int nr_refspec, const char **refspec);
struct refspec_item *parse_push_refspec(int nr_refspec, const char **refspec);
@@
-45,4
+44,6
@@
void refspec_append(struct refspec *rs, const char *refspec);
void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
void refspec_clear(struct refspec *rs);
void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
void refspec_clear(struct refspec *rs);
+int valid_fetch_refspec(const char *refspec);
+
#endif /* REFSPEC_H */
#endif /* REFSPEC_H */