Re: [BUG] branch renamed to 'HEAD'

2017-02-26 Thread Karthik Nayak
reset 'orig' to point to 'HEAD', rather this renames 'orig' to 'HEAD'. What you actually want to do (to reset 'orig' to 'HEAD') is: $ git branch -f orig @ This would make orig point to the current HEAD. -- Regards, Karthik Nayak

Re: [PATCH v10 00/20] port branch.c to use ref-filter's printing options

2017-01-14 Thread Karthik Nayak
On Wed, Jan 11, 2017 at 2:21 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> index 81db67d74..08be8462c 100644 >> --- a/Documentation/git-for-each-ref.txt >> +++ b/Documentation/git-for-each-re

Re: [PATCH v10 03/20] ref-filter: implement %(if:equals=) and %(if:notequals=)

2017-01-14 Thread Karthik Nayak
Hello, On Wed, Jan 11, 2017 at 2:15 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> + if_then_else->condition_satisfied = 1; >> + } else if (if_then_else->cmp_status == COMPARE_UNEQUAL

Re: [PATCH v10 19/20] branch: use ref-filter printing APIs

2017-01-14 Thread Karthik Nayak
Hello, On Thu, Jan 12, 2017 at 5:17 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Jan 10, 2017 at 12:49 AM, Karthik Nayak <karthik@gmail.com> wrote: >> diff --git a/builtin/branch.c b/builtin/branch.c >> index 34cd61cd9..f293ee5b0 100644 >> --- a/

[PATCH v10 12/20] ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Use the recently introduced refname_atom_parser_internal() within remote_ref_atom_parser(), this provides a common base for all the ref printing atoms, allowing %(upstream) and %(push) to also use the ':strip' option. The atoms '

[PATCH v10 13/20] ref-filter: rename the 'strip' option to 'lstrip'

2017-01-10 Thread Karthik Nayak
In preparation for the upcoming patch, where we introduce the 'rstrip' option. Rename the 'strip' option to 'lstrip' to remove ambiguity. Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c | 4 ++-

[PATCH v10 14/20] ref-filter: Do not abruptly die when using the 'lstrip=' option

2017-01-10 Thread Karthik Nayak
an empty string whenever the value 'N' is greater than the number of components available, instead of calling die(). Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 3 +-- ref-filter.c | 3 +-- t/t6300-for-each-ref.sh

[PATCH v10 08/20] ref-filter: add support for %(upstream:track,nobracket)

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(upstream:track,nobracket) which will print the tracking information without the brackets (i.e. "ahead N, behind M"). This is needed when we port branch.c to use ref-filter's printing APIs. Add test and documentat

[PATCH v10 19/20] branch: use ref-filter printing APIs

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Port branch.c to use ref-filter APIs for printing. This clears out most of the code used in branch.c for printing and replaces them with calls made to the ref-filter library. Introduce build_format() which gets the format required for printing o

[PATCH v10 01/20] ref-filter: implement %(if), %(then), and %(else) atoms

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if), %(then) and %(else) atoms. Used as %(if)...%(then)...%(end) or %(if)...%(then)...%(else)...%(end). If the format string between %(if) and %(then) expands to an empty string, or to only whitespaces, then the whole %(if)...%(end) e

[PATCH v10 18/20] branch, tag: use porcelain output

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Call ref-filter's setup_ref_filter_porcelain_msg() to enable translated messages for the %(upstream:tack) atom. Although branch.c doesn't currently use ref-filter's printing API's, this will ensure that when it does in the future patches, we do no

[PATCH v10 03/20] ref-filter: implement %(if:equals=) and %(if:notequals=)

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if:equals=) wherein the if condition is only satisfied if the value obtained between the %(if:...) and %(then) atom is the same as the given ''. Similarly, implement (if:notequals=) wherein the if condition is only satisfied if the

[PATCH v10 16/20] ref-filter: add an 'rstrip=' option to atoms which deal with refnames

2017-01-10 Thread Karthik Nayak
Complimenting the existing 'lstrip=' option, add an 'rstrip=' option which strips `` slash-separated path components from the end of the refname (e.g., `%(refname:rstrip=2)` turns `refs/tags/foo` into `refs`). Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-fo

[PATCH v10 11/20] ref-filter: introduce refname_atom_parser()

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Using refname_atom_parser_internal(), introduce refname_atom_parser() which will parse the %(symref) and %(refname) atoms. Store the parsed information into the 'used_atom' structure based on the modifiers used along with the atoms. Now the '%(

[PATCH v10 20/20] branch: implement '--format' option

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement the '--format' option provided by 'ref-filter'. This lets the user list branches as per desired format similar to the implementation in 'git for-each-ref'. Add tests and documentation for the same. Mentored-by: Christian

[PATCH v10 09/20] ref-filter: make "%(symref)" atom work with the ':short' modifier

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> The "%(symref)" atom doesn't work when used with the ':short' modifier because we strictly match only 'symref' for setting the 'need_symref' indicator. Fix this by comparing with the valid_atom rather than the used_atom. Add te

[PATCH v10 17/20] ref-filter: allow porcelain to translate messages in the output

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Introduce setup_ref_filter_porcelain_msg() so that the messages used in the atom %(upstream:track) can be translated if needed. By default, keep the messages untranslated, which is the right behavior for plumbing commands. This is needed as w

[PATCH v10 07/20] ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Borrowing from branch.c's implementation print "[gone]" whenever an unknown upstream ref is encountered instead of just ignoring it. This makes sure that when branch.c is ported over to using ref-filter APIs for printing, this fea

[PATCH v10 15/20] ref-filter: modify the 'lstrip=' option to work with negative ''

2017-01-10 Thread Karthik Nayak
the right-most end. For e.g. %(refname:lstrip=-1) would make 'foo/goo/abc' into 'abc'. Add documentation and tests for the same. Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 7 ++- ref-filter.c

[PATCH v10 02/20] ref-filter: include reference to 'used_atom' within 'atom_value'

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Ensure that each 'atom_value' has a reference to its corresponding 'used_atom'. This lets us use values within 'used_atom' in the 'handler' function. Hence we can get the %(align) atom's parameters directly from the 'used_atom' therefore re

[PATCH v10 10/20] ref-filter: introduce refname_atom_parser_internal()

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Since there are multiple atoms which print refs ('%(refname)', '%(symref)', '%(push)', '%(upstream)'), it makes sense to have a common ground for parsing them. This would allow us to share implementations of the atom modifiers between these

[PATCH v10 05/20] ref-filter: move get_head_description() from branch.c

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Move the implementation of get_head_description() from branch.c to ref-filter. This gives a description of the HEAD ref if called. This is used as the refname for the HEAD ref whenever the FILTER_REFS_DETACHED_HEAD option is used. Make it

[PATCH v10 04/20] ref-filter: modify "%(objectname:short)" to take length

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(objectname:short=) which would print the abbreviated unique objectname of given length. When no length is specified, the length is 'DEFAULT_ABBREV'. The minimum length is 'MINIMUM_ABBREV'. The length may be exceeded to

[PATCH v10 00/20] port branch.c to use ref-filter's printing options

2017-01-10 Thread Karthik Nayak
the previous version. Interdiff at the bottom. Karthik Nayak (20): ref-filter: implement %(if), %(then), and %(else) atoms ref-filter: include reference to 'used_atom' within 'atom_value' ref-filter: implement %(if:equals=) and %(if:notequals=) ref-filter: modify "%(objectname:

[PATCH v10 06/20] ref-filter: introduce format_ref_array_item()

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> To allow column display, we will need to first render the output in a string list to allow print_columns() to compute the proper size of each column before starting the actual output. Introduce the function format_ref_array_item() tha

Re: [PATCH v9 19/20] branch: use ref-filter printing APIs

2016-12-28 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:47 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> static char branch_colors[][COLOR_MAXLEN] = { >> - GIT_COLOR_RESET, >> - GIT_COLOR_NORMAL, /* PLAIN */ >&g

Re: [PATCH v9 15/20] ref-filter: modify the 'lstrip=' option to work with negative ''

2016-12-28 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:41 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> Currently the 'lstrip=' option only takes a positive value '' >> and strips '' slash-separated path components from the left. Modify >&

Re: [PATCH v9 11/20] ref-filter: introduce refname_atom_parser()

2016-12-28 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:34 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> +symref:: >> + The ref which the given symbolic ref refers to. If not a >> + symbolic ref, nothing is printed. Respects the `:

Re: [PATCH v9 02/20] ref-filter: include reference to 'used_atom' within 'atom_value'

2016-12-27 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:29 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> From: Karthik Nayak <karthik@gmail.com> >> >> Ensure that each 'atom_value' has a reference to its corresponding >&

Re: [PATCH v9 03/20] ref-filter: implement %(if:equals=) and %(if:notequals=)

2016-12-27 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:30 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> This is done by introducing 'if_atom_parser()' which parses the given >> %(if) atom and then stores the data in used_atom which is later

Re: [PATCH v9 01/20] ref-filter: implement %(if), %(then), and %(else) atoms

2016-12-27 Thread Karthik Nayak
On Wed, Dec 28, 2016 at 2:28 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> >> +Some atoms like %(align) and %(if) always require a matching %(end). >> +We call them "opening atoms" and sometimes deno

[PATCH v9 11/20] ref-filter: introduce refname_atom_parser()

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Using refname_atom_parser_internal(), introduce refname_atom_parser() which will parse the %(symref) and %(refname) atoms. Store the parsed information into the 'used_atom' structure based on the modifiers used along with the atoms. Now the '%(

[PATCH v9 08/20] ref-filter: add support for %(upstream:track,nobracket)

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(upstream:track,nobracket) which will print the tracking information without the brackets (i.e. "ahead N, behind M"). This is needed when we port branch.c to use ref-filter's printing APIs. Add test and documentat

[PATCH v9 10/20] ref-filter: introduce refname_atom_parser_internal()

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Since there are multiple atoms which print refs ('%(refname)', '%(symref)', '%(push)', '%(upstream)'), it makes sense to have a common ground for parsing them. This would allow us to share implementations of the atom modifiers between these

[PATCH v9 13/20] ref-filter: rename the 'strip' option to 'lstrip'

2016-12-27 Thread Karthik Nayak
In preparation for the upcoming patch, where we introduce the 'rstrip' option. Rename the 'strip' option to 'lstrip' to remove ambiguity. Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c | 4 ++-

[PATCH v9 16/20] ref-filter: add an 'rstrip=' option to atoms which deal with refnames

2016-12-27 Thread Karthik Nayak
Complimenting the existing 'lstrip=' option, add an 'rstrip=' option which strips `` slash-separated path components from the end of the refname (e.g., `%(refname:rstrip=2)` turns `refs/tags/foo` into `refs`). Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-fo

[PATCH v9 05/20] ref-filter: move get_head_description() from branch.c

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Move the implementation of get_head_description() from branch.c to ref-filter. This gives a description of the HEAD ref if called. This is used as the refname for the HEAD ref whenever the FILTER_REFS_DETACHED_HEAD option is used. Make it

[PATCH v9 12/20] ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Use the recently introduced refname_atom_parser_internal() within remote_ref_atom_parser(), this provides a common base for all the ref printing atoms, allowing %(upstream) and %(push) to also use the ':strip' option. The atoms '

[PATCH v9 19/20] branch: use ref-filter printing APIs

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Port branch.c to use ref-filter APIs for printing. This clears out most of the code used in branch.c for printing and replaces them with calls made to the ref-filter library. Introduce build_format() which gets the format required for printing o

[PATCH v9 14/20] ref-filter: Do not abruptly die when using the 'lstrip=' option

2016-12-27 Thread Karthik Nayak
an empty string whenever the value 'N' is greater than the number of components available, instead of calling die(). Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 3 +-- ref-filter.c | 3 +-- t/t6300-for-each-ref.sh

[PATCH v9 18/20] branch, tag: use porcelain output

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Call ref-filter's setup_ref_filter_porcelain_msg() to enable translated messages for the %(upstream:tack) atom. Although branch.c doesn't currently use ref-filter's printing API's, this will ensure that when it does in the future patches, we do no

[PATCH v9 06/20] ref-filter: introduce format_ref_array_item()

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> To allow column display, we will need to first render the output in a string list to allow print_columns() to compute the proper size of each column before starting the actual output. Introduce the function format_ref_array_item() tha

[PATCH v9 07/20] ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Borrowing from branch.c's implementation print "[gone]" whenever an unknown upstream ref is encountered instead of just ignoring it. This makes sure that when branch.c is ported over to using ref-filter APIs for printing, this fea

[PATCH v9 09/20] ref-filter: make "%(symref)" atom work with the ':short' modifier

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> The "%(symref)" atom doesn't work when used with the ':short' modifier because we strictly match only 'symref' for setting the 'need_symref' indicator. Fix this by comparing with the valid_atom rather than the used_atom. Add te

[PATCH v9 04/20] ref-filter: modify "%(objectname:short)" to take length

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(objectname:short=) which would print the abbreviated unique objectname of given length. When no length is specified, the length is 'DEFAULT_ABBREV'. The minimum length is 'MINIMUM_ABBREV'. The length may be exceeded to

[PATCH v9 20/20] branch: implement '--format' option

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement the '--format' option provided by 'ref-filter'. This lets the user list branches as per desired format similar to the implementation in 'git for-each-ref'. Add tests and documentation for the same. Mentored-by: Christian

[PATCH v9 01/20] ref-filter: implement %(if), %(then), and %(else) atoms

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if), %(then) and %(else) atoms. Used as %(if)...%(then)...%(end) or %(if)...%(then)...%(else)...%(end). If the format string between %(if) and %(then) expands to an empty string, or to only whitespaces, then the whole %(if)...%(end) e

[PATCH v9 03/20] ref-filter: implement %(if:equals=) and %(if:notequals=)

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if:equals=) wherein the if condition is only satisfied if the value obtained between the %(if:...) and %(then) atom is the same as the given ''. Similarly, implement (if:notequals=) wherein the if condition is only satisfied if the

[PATCH v9 02/20] ref-filter: include reference to 'used_atom' within 'atom_value'

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Ensure that each 'atom_value' has a reference to its corresponding 'used_atom'. This let's us use values within 'used_atom' in the 'handler' function. Hence we can get the %(align) atom's parameters directly from the 'used_atom' therefore re

[PATCH v9 00/20] port branch.c to use ref-filter's printing options

2016-12-27 Thread Karthik Nayak
components. Thanks Jacob, Junio, Jeff, Ramsay for their suggestions and help. Karthik Nayak (20): ref-filter: implement %(if), %(then), and %(else) atoms ref-filter: include reference to 'used_atom' within 'atom_value' ref-filter: implement %(if:equals=) and %(if:notequals=) ref-filter

Re: What's cooking in git.git (Dec 2016, #04; Fri, 16)

2016-12-17 Thread Karthik Nayak
On Sat, Dec 17, 2016 at 7:13 PM, Ramsay Jones <ram...@ramsayjones.plus.com> wrote: > > > On 17/12/16 08:38, Karthik Nayak wrote: >> Hello, >> >>> >>> * kn/ref-filter-branch-list (2016-12-08) 20 commits >>> - branch: implement '--form

Re: What's cooking in git.git (Dec 2016, #04; Fri, 16)

2016-12-17 Thread Karthik Nayak
p://marc.info/?l=git=148112502029302=2) I'll start working on returning empty rather than die. Also Jeff suggested some changes, which I've incorporated into my local branch. (http://marc.info/?t=14811250361=1=2). I'll reroll if no further changes are suggested soon :) -- Regards, Karthik Nayak

Re: [PATCH v8 18/19] branch: use ref-filter printing APIs

2016-12-12 Thread Karthik Nayak
On Mon, Dec 12, 2016 at 10:10 PM, Jeff King <p...@peff.net> wrote: > On Mon, Dec 12, 2016 at 09:59:49PM +0530, Karthik Nayak wrote: > >> >> > This caller never stores the return value, and it ends up leaking. So I >> >> > wonder if you wanted

Re: [PATCH v8 18/19] branch: use ref-filter printing APIs

2016-12-12 Thread Karthik Nayak
On Mon, Dec 12, 2016 at 5:45 PM, Jeff King <p...@peff.net> wrote: > On Mon, Dec 12, 2016 at 04:50:20PM +0530, Karthik Nayak wrote: > >> > This caller never stores the return value, and it ends up leaking. So I >> > wonder if you wanted "static struct strbuf"

Re: [PATCH v8 18/19] branch: use ref-filter printing APIs

2016-12-12 Thread Karthik Nayak
On Fri, Dec 9, 2016 at 7:33 PM, Jeff King <p...@peff.net> wrote: > On Wed, Dec 07, 2016 at 09:06:26PM +0530, Karthik Nayak wrote: > >> +const char *quote_literal_for_format(const char *s) >> { >> + struct strbuf buf = STRBUF_INIT; >> >>

Re: [PATCH v8 00/19] port branch.c to use ref-filter's printing options

2016-12-12 Thread Karthik Nayak
On Fri, Dec 9, 2016 at 5:28 AM, Junio C Hamano wrote: > Thanks. > > Will replace, with the attached stylistic fixes squashed in for > minor issues that were spotted by my mechanical pre-acceptance > filter. > Thanks for this. Will add it to my local branch too if there's a

Re: [PATCH v8 00/19] port branch.c to use ref-filter's printing options

2016-12-12 Thread Karthik Nayak
, we keep up to > what we said, while potentially keeping the entire string. I feel > that's a better alternative than a die() in the middle of a ref > filter.. > > What are other people's thoughts on this? I am _for_ this. Even I think it'd be better to return an empty string rather than just die in the middle. -- Regards, Karthik Nayak

[PATCH v8 08/19] ref-filter: add support for %(upstream:track,nobracket)

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(upstream:track,nobracket) which will print the tracking information without the brackets (i.e. "ahead N, behind M"). This is needed when we port branch.c to use ref-filter's printing APIs. Add test and documentat

[PATCH v8 09/19] ref-filter: make "%(symref)" atom work with the ':short' modifier

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> The "%(symref)" atom doesn't work when used with the ':short' modifier because we strictly match only 'symref' for setting the 'need_symref' indicator. Fix this by comparing with the valid_atom rather than the used_atom. Add te

[PATCH v8 03/19] ref-filter: implement %(if:equals=) and %(if:notequals=)

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if:equals=) wherein the if condition is only satisfied if the value obtained between the %(if:...) and %(then) atom is the same as the given ''. Similarly, implement (if:notequals=) wherein the if condition is only satisfied if the

[PATCH v8 06/19] ref-filter: introduce format_ref_array_item()

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> To allow column display, we will need to first render the output in a string list to allow print_columns() to compute the proper size of each column before starting the actual output. Introduce the function format_ref_array_item() tha

[PATCH v8 01/19] ref-filter: implement %(if), %(then), and %(else) atoms

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement %(if), %(then) and %(else) atoms. Used as %(if)...%(then)...%(end) or %(if)...%(then)...%(else)...%(end). If the format string between %(if) and %(then) expands to an empty string, or to only whitespaces, then the whole %(if)...%(end) e

[PATCH v8 05/19] ref-filter: move get_head_description() from branch.c

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Move the implementation of get_head_description() from branch.c to ref-filter. This gives a description of the HEAD ref if called. This is used as the refname for the HEAD ref whenever the FILTER_REFS_DETACHED_HEAD option is used. Make it

[PATCH v8 04/19] ref-filter: modify "%(objectname:short)" to take length

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Add support for %(objectname:short=) which would print the abbreviated unique objectname of given length. When no length is specified, the length is 'DEFAULT_ABBREV'. The minimum length is 'MINIMUM_ABBREV'. The length may be exceeded to

[PATCH v8 19/19] branch: implement '--format' option

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Implement the '--format' option provided by 'ref-filter'. This lets the user list branches as per desired format similar to the implementation in 'git for-each-ref'. Add tests and documentation for the same. Mentored-by: Christian

[PATCH v8 18/19] branch: use ref-filter printing APIs

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Port branch.c to use ref-filter APIs for printing. This clears out most of the code used in branch.c for printing and replaces them with calls made to the ref-filter library. Introduce build_format() which gets the format required for printing o

[PATCH v8 17/19] branch, tag: use porcelain output

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Call ref-filter's setup_ref_filter_porcelain_msg() to enable translated messages for the %(upstream:tack) atom. Although branch.c doesn't currently use ref-filter's printing API's, this will ensure that when it does in the future patches, we do no

[PATCH v8 07/19] ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Borrowing from branch.c's implementation print "[gone]" whenever an unknown upstream ref is encountered instead of just ignoring it. This makes sure that when branch.c is ported over to using ref-filter APIs for printing, this fea

[PATCH v8 13/19] ref-filter: rename the 'strip' option to 'lstrip'

2016-12-07 Thread Karthik Nayak
In preparation for the upcoming patch, where we introduce the 'rstrip' option. Rename the 'strip' option to 'lstrip' to remove ambiguity. Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c | 4 ++-

[PATCH v8 14/19] ref-filter: modify the 'lstrip=' option to work with negative ''

2016-12-07 Thread Karthik Nayak
for the same. Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-for-each-ref.txt | 5 +++-- ref-filter.c | 26 +- t/t6300-for-each-ref.sh| 15 --- 3 files changed, 32 insertions(+), 14 deletions(-)

[PATCH v8 10/19] ref-filter: introduce refname_atom_parser_internal()

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Since there are multiple atoms which print refs ('%(refname)', '%(symref)', '%(push)', '%(upstream)'), it makes sense to have a common ground for parsing them. This would allow us to share implementations of the atom modifiers between these

[PATCH v8 11/19] ref-filter: introduce refname_atom_parser()

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Using refname_atom_parser_internal(), introduce refname_atom_parser() which will parse the %(symref) and %(refname) atoms. Store the parsed information into the 'used_atom' structure based on the modifiers used along with the atoms. Now the '%(

[PATCH v8 15/19] ref-filter: add an 'rstrip=' option to atoms which deal with refnames

2016-12-07 Thread Karthik Nayak
Complimenting the existing 'lstrip=' option, add an 'rstrip=' option which strips `` slash-separated path components from the end of the refname (e.g., `%(refname:rstrip=2)` turns `refs/tags/foo` into `refs`). Signed-off-by: Karthik Nayak <karthik@gmail.com> --- Documentation/git-fo

[PATCH v8 16/19] ref-filter: allow porcelain to translate messages in the output

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Introduce setup_ref_filter_porcelain_msg() so that the messages used in the atom %(upstream:track) can be translated if needed. By default, keep the messages untranslated, which is the right behavior for plumbing commands. This is needed as w

[PATCH v8 12/19] ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Use the recently introduced refname_atom_parser_internal() within remote_ref_atom_parser(), this provides a common base for all the ref printing atoms, allowing %(upstream) and %(push) to also use the ':strip' option. The atoms '

[PATCH v8 00/19] port branch.c to use ref-filter's printing options

2016-12-07 Thread Karthik Nayak
and Matthieu for their inputs on the previous version. Interdiff below. Karthik Nayak (19): ref-filter: implement %(if), %(then), and %(else) atoms ref-filter: include reference to 'used_atom' within 'atom_value' ref-filter: implement %(if:equals=) and %(if:notequals=) ref-filter

[PATCH v8 02/19] ref-filter: include reference to 'used_atom' within 'atom_value'

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak <karthik@gmail.com> Ensure that each 'atom_value' has a reference to its corresponding 'used_atom'. This let's us use values within 'used_atom' in the 'handler' function. Hence we can get the %(align) atom's parameters directly from the 'used_atom' therefore re

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-22 Thread Karthik Nayak
On Sun, Nov 20, 2016 at 11:02 PM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> We could have lstrip and rstrip as you suggested and perhaps make it work >> together too. But I see this going off the scope of this s

Re: [PATCH v7 14/17] ref-filter: allow porcelain to translate messages in the output

2016-11-22 Thread Karthik Nayak
On Mon, Nov 21, 2016 at 2:11 PM, Matthieu Moy <matthieu@grenoble-inp.fr> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> cc'in Matthieu since he wrote the patch. >> >> On Sat, Nov 19, 2016 at 4:16 AM, Jakub Narębski <jna...@gmail.com> wro

Re: [PATCH v7 16/17] branch: use ref-filter printing APIs

2016-11-22 Thread Karthik Nayak
') { > strbuf_addstr(, "%%"); > s = ep + 1; > } else { > s = ep; > } > } > return buf.buf; > } > Perfect. I get what you're saying, I'll add this in :) -- Regards, Karthik Nayak

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-20 Thread Karthik Nayak
On Sun, Nov 20, 2016 at 8:46 PM, Karthik Nayak <karthik@gmail.com> wrote: > On Fri, Nov 18, 2016 at 11:48 PM, Junio C Hamano <gits...@pobox.com> wrote: >> Jacob Keller <jacob.kel...@gmail.com> writes: >> >>>>>> to get remotes from /refs/

Re: [PATCH v7 14/17] ref-filter: allow porcelain to translate messages in the output

2016-11-20 Thread Karthik Nayak
cc'in Matthieu since he wrote the patch. On Sat, Nov 19, 2016 at 4:16 AM, Jakub Narębski <jna...@gmail.com> wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> From: Karthik Nayak <karthik@gmail.com> >> >> Introduce setup_ref_filter_porcelai

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-20 Thread Karthik Nayak
>>>> >>>> You can "strip to leave only 2 components" and compare the result >>>> with refs/remotes instead, no? >>>> >>> >>> Of course, my only objective was that someone would find it useful to >>> have these two add

Re: [PATCH v7 10/17] ref-filter: introduce refname_atom_parser_internal()

2016-11-19 Thread Karthik Nayak
On Sat, Nov 19, 2016 at 3:06 AM, Jakub Narębski <jna...@gmail.com> wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> From: Karthik Nayak <karthik@gmail.com> >> >> Since there are multiple atoms which print refs ('%(refname)', >> '%(symref)',

Re: [PATCH v7 09/17] ref-filter: make "%(symref)" atom work with the ':short' modifier

2016-11-19 Thread Karthik Nayak
On Sat, Nov 19, 2016 at 3:04 AM, Jakub Narębski <jna...@gmail.com> wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> >> Helped-by: Junio C Hamano <gits...@pobox.com> >> Signed-off-by: Karthik Nayak <karthik@gmail.com> >> --- > [

Re: [PATCH v7 03/17] ref-filter: implement %(if:equals=) and %(if:notequals=)

2016-11-19 Thread Karthik Nayak
On Sat, Nov 19, 2016 at 1:28 AM, Jakub Narębski <jna...@gmail.com> wrote: > W dniu 08.11.2016 o 21:11, Karthik Nayak pisze: >> From: Karthik Nayak <karthik@gmail.com> >> >> Implement %(if:equals=) wherein the if condition is only >>

Re: [PATCH v7 00/17] port branch.c to use ref-filter's printing options

2016-11-19 Thread Karthik Nayak
On Sat, Nov 19, 2016 at 5:01 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> Thanks, will add it in. > > OK, here is a reroll of what I sent earlier in > > > http://public-inbox.org/git/<xmqq7

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-17 Thread Karthik Nayak
Hey, On Fri, Nov 18, 2016 at 12:05 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> On Tue, Nov 15, 2016 at 11:12 PM, Junio C Hamano <gits...@pobox.com> wrote: >>> Jacob Keller <jacob.kel...@gmail.com&

Re: [PATCH v7 00/17] port branch.c to use ref-filter's printing options

2016-11-16 Thread Karthik Nayak
On Wed, Nov 16, 2016 at 2:13 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >> This is part of unification of the commands 'git tag -l, git branch -l >> and git for-each-ref'. This ports over branch.c to use re

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-15 Thread Karthik Nayak
ith negative > numbers would be most ideal. The necessity is that we need to do different formatting as per the ref type in branch -l. If you see the last but one patch, we do strbuf_addf(, "%%(if:notequals=remotes)%%(refname:base)%%(then)%s%%(else)%s%%(end)", local.buf, remote.buf); where its using ':base' to check for the ref type and do conditional printing along with the %(if)...%(end) atoms. -- Regards, Karthik Nayak

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-14 Thread Karthik Nayak
On Tue, Nov 15, 2016 at 1:21 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >>> - More importantly, what do these do? I do not think of a good >>>description that generalizes "base of refs/foo/bar

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-14 Thread Karthik Nayak
On Mon, Nov 14, 2016 at 7:25 AM, Junio C Hamano <gits...@pobox.com> wrote: > Karthik Nayak <karthik@gmail.com> writes: > >>>> diff --git a/Documentation/git-for-each-ref.txt >>>> b/Documentation/git-for-each-ref.txt >>>> index 600b703

Re: [PATCH v7 00/17] port branch.c to use ref-filter's printing options

2016-11-14 Thread Karthik Nayak
Hello, On Wed, Nov 9, 2016 at 5:45 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Nov 8, 2016 at 12:11 PM, Karthik Nayak <karthik@gmail.com> wrote: >> This is part of unification of the commands 'git tag -l, git branch -l >> and git for-each-ref'. This

Re: [PATCH v7 16/17] branch: use ref-filter printing APIs

2016-11-14 Thread Karthik Nayak
Hello On Wed, Nov 9, 2016 at 5:44 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak <karthik@gmail.com> wrote: >> From: Karthik Nayak <karthik@gmail.com> >> >> Port branch.c to use ref-filter API

Re: [PATCH v7 13/17] ref-filter: add `:dir` and `:base` options for ref printing atoms

2016-11-13 Thread Karthik Nayak
Hello, On Wed, Nov 9, 2016 at 5:28 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak <karthik@gmail.com> wrote: >> From: Karthik Nayak <karthik@gmail.com> >> Add tests and documentation for the same. &

Re: [PATCH v7 11/17] ref-filter: introduce symref_atom_parser() and refname_atom_parser()

2016-11-12 Thread Karthik Nayak
On Wed, Nov 9, 2016 at 5:22 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak <karthik@gmail.com> wrote: >> From: Karthik Nayak <karthik@gmail.com> > > What's the reasoning for using separate functions her

Re: [PATCH v7 08/17] ref-filter: add support for %(upstream:track,nobracket)

2016-11-12 Thread Karthik Nayak
On Wed, Nov 9, 2016 at 5:15 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak <karthik@gmail.com> wrote: >> From: Karthik Nayak <karthik@gmail.com> >> >> Add support for %(upstream:track,nobracket) which

Re: [PATCH v7 07/17] ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreams

2016-11-12 Thread Karthik Nayak
t; silent, but I think this could be considered a bug. > Didn't get you. >> Mentored-by: Christian Couder <christian.cou...@gmail.com> >> Mentored-by: Matthieu Moy <matthieu@grenoble-inp.fr> >> Helped-by : Jacob Keller <jacob.kel...@gmail.com> >> Sig

Re: [PATCH v7 04/17] ref-filter: modify "%(objectname:short)" to take length

2016-11-12 Thread Karthik Nayak
Hello, On Fri, Nov 11, 2016 at 10:59 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: > On Thu, Nov 10, 2016 at 9:36 AM, Karthik Nayak <karthik@gmail.com> wrote: >> On Wed, Nov 9, 2016 at 4:57 AM, Jacob Keller <jacob.kel...@gmail.com> wrote: >> >> That d

Re: [PATCH v7 03/17] ref-filter: implement %(if:equals=) and %(if:notequals=)

2016-11-12 Thread Karthik Nayak
f-equals-case-insensitively). That's a rather good point you make there, I think using an enum with a string constant would be ideal for future extensibility too. Thanks for the explanation, I shall change it. -- Regards, Karthik Nayak

  1   2   3   4   5   6   7   8   9   10   >