aboutsummaryrefslogtreecommitdiff
path: root/ref-filter.c
Commit message (Collapse)AuthorAge
* ref-filter: drop sprintf and strcpy callsJeff King2015-09-25
| | | | | | | | | | | | The ref-filter code comes from for-each-ref, and inherited a number of raw sprintf and strcpy calls. These are generally all safe, as we custom-size the buffers, or are formatting numbers into sufficiently large buffers. But we can make the resulting code even simpler and more obviously correct by using some of our helper functions. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jk/date-mode-format'Junio C Hamano2015-08-03
| | | | | | | | | | | Teach "git log" and friends a new "--date=format:..." option to format timestamps using system's strftime(3). * jk/date-mode-format: strbuf: make strbuf_addftime more robust introduce "format" date-mode convert "enum date_mode" into a struct show-branch: use DATE_RELATIVE instead of magic number
* Merge branch 'kn/for-each-ref'Junio C Hamano2015-08-03
| | | | | | | | | | | | | | | | | | GSoC project to rebuild ref listing by branch and tag based on the for-each-ref machinery. This is its first part. * kn/for-each-ref: ref-filter: make 'ref_array_item' use a FLEX_ARRAY for refname for-each-ref: introduce filter_refs() ref-filter: move code from 'for-each-ref' ref-filter: add 'ref-filter.h' for-each-ref: rename variables called sort to sorting for-each-ref: rename some functions and make them public for-each-ref: introduce 'ref_array_clear()' for-each-ref: introduce new structures for better organisation for-each-ref: rename 'refinfo' to 'ref_array_item' for-each-ref: clean up code for-each-ref: extract helper functions out of grab_single_ref()
* ref-filter: make 'ref_array_item' use a FLEX_ARRAY for refnameKarthik Nayak2015-08-03
| | | | | | | | | | This would remove the need of using a pointer to store refname. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* for-each-ref: introduce filter_refs()Karthik Nayak2015-08-03
| | | | | | | | | | | | | | | | | | | | | | | | | | Introduce filter_refs() which will act as an API for filtering a set of refs. Based on the type of refs the user has requested, we iterate through those refs and apply filters as per the given ref_filter structure and finally store the filtered refs in the ref_array structure. Currently this will wrap around ref_filter_handler(). Hence, ref_filter_handler is made file scope static. As users of this API will no longer send a ref_filter_cbdata structure directly, we make the elements of ref_filter_cbdata pointers. We can now use the information given by the users to obtain our own ref_filter_cbdata structure. Changes are made to support the change in ref_filter_cbdata structure. Make 'for-each-ref' use this API. Helped-by: Junio C Hamano <gitster@pobox.com> Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* ref-filter: move code from 'for-each-ref'Karthik Nayak2015-08-03
Move most of the code from 'for-each-ref' to 'ref-filter' to make it publicly available to other commands, this is to unify the code of 'tag -l', 'branch -l' and 'for-each-ref' so that they can share their implementations with each other. Add 'ref-filter' to the Makefile, this completes the movement of code from 'for-each-ref' to 'ref-filter'. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Matthieu Moy <matthieu.moy@grenoble-inp.fr> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>