Re: [BUG] branch renamed to 'HEAD'

2017-02-26 Thread Karthik Nayak
x27;t 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 wrote: > Karthik Nayak writes: > >> index 81db67d74..08be8462c 100644 >> --- a/Documentation/git-for-each-ref.txt >> +++ b/Documentation/git-for-each-ref.txt >> @@ -95,13 +95,17 @@ refname:: >> The name

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 wrote: > Karthik Nayak writes: > >> + if_then_else->condition_satisfied = 1; >> + } else if (if_then_else->cmp_status == COMPARE_UNEQUAL) { > > Please, no space before tabs (lo

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 wrote: > On Tue, Jan 10, 2017 at 12:49 AM, Karthik Nayak wrote: >> diff --git a/builtin/branch.c b/builtin/branch.c >> index 34cd61cd9..f293ee5b0 100644 >> --- a/builtin/branch.c >> +++ b/builtin/branch.c &g

[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 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 '%(push)' and '%(u

[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 --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c

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

2017-01-10 Thread Karthik Nayak
void this, return an empty string whenever the value 'N' is greater than the number of components available, instead of calling die(). Signed-off-by: Karthik Nayak --- 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 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 documentation for the same. Mentore

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 of refs. Make amendments to

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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) expands to the string following

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 not

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 value obtained betwee

[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 --- Documentation/git-f

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 '%(symref)

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 Couder Men

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 we port branch.c to use ref

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 feature is not lost. Make cha

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

2017-01-10 Thread Karthik Nayak
only 'N' slash-separated path components from 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 --- Documentation/git-for-each-ref.txt | 7 ++- ref-f

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 m

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 public because we need it to

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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 ensure that the pro

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

2017-01-10 Thread Karthik Nayak
85594700011&r=1&w=2) Thanks to Junio and Jacob for their suggestions wrt 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'

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

2017-01-10 Thread Karthik Nayak
From: Karthik Nayak 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() that does the formatting of a ref_array_item

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 wrote: > Karthik Nayak writes: > >> static char branch_colors[][COLOR_MAXLEN] = { >> - GIT_COLOR_RESET, >> - GIT_COLOR_NORMAL, /* PLAIN */ >> - GIT_COLOR_RED, /* REMOTE */ >> -

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 wrote: > Karthik Nayak writes: > >> Currently the 'lstrip=' option only takes a positive value '' >> and strips '' slash-separated path components from the left. Modify >> the 'lstrip&#x

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 wrote: > Karthik Nayak writes: > >> +symref:: >> + The ref which the given symbolic ref refers to. If not a >> + symbolic ref, nothing is printed. Respects the `:short` and >> + `:strip` options in t

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 wrote: > Karthik Nayak writes: > >> From: Karthik Nayak >> >> Ensure that each 'atom_value' has a reference to its corresponding >> 'used_atom'. This let's us use values within 'used_

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 wrote: > Karthik Nayak 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 passed >> on to the used_atom of the %

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 wrote: > Karthik Nayak writes: > >> >> +Some atoms like %(align) and %(if) always require a matching %(end). >> +We call them "opening atoms" and sometimes denote them as %($open). >> + >> +When a sc

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 '%(symref)

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 documentation for the same. Mentore

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 m

[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 --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c

[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 --- Documentation/git-f

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 public because we need it to

[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 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 '%(push)' and '%(u

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 of refs. Make amendments to

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

2016-12-27 Thread Karthik Nayak
void this, return an empty string whenever the value 'N' is greater than the number of components available, instead of calling die(). Signed-off-by: Karthik Nayak --- 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 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 not

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 we port branch.c to use ref

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

2016-12-27 Thread Karthik Nayak
path components from the left. Add documentation and tests for the same. Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 3 ++- ref-filter.c | 27 ++- t/t6300-for-each-ref.sh| 12 ++-- 3 files changed, 30 in

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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() that does the formatting of a ref_array_item

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 feature is not lost. Make cha

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 ensure that the pro

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 Couder Men

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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) expands to the string following

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 value obtained betwee

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

2016-12-27 Thread Karthik Nayak
From: Karthik Nayak 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 '

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

2016-12-27 Thread Karthik Nayak
ic. 3. lstrip and rstrip doesn't die on less 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' re

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 wrote: > > > On 17/12/16 08:38, Karthik Nayak wrote: >> Hello, >> >>> >>> * kn/ref-filter-branch-list (2016-12-08) 20 commits >>> - branch: implement '--format' option >>> - bra

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

2016-12-17 Thread Karthik Nayak
ore reviews, if any. For now we need to come to a conclusion on the die vs empty discussion (http://marc.info/?l=git&m=148112502029302&w=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&r=1&w=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 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 "static struct strbuf&qu

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 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" in the first plac

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 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; >> >> + strbuf_reset(&buf); >

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 need for a re-roll.

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

2016-12-12 Thread Karthik Nayak
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 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 documentation for the same. Mentore

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 value obtained betwee

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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) expands to the string following

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 public because we need it to

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 ensure that the pro

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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() that does the formatting of a ref_array_item

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 Couder Men

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 of refs. Make amendments to

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 not

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 feature is not lost. Make cha

[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 --- Documentation/git-for-each-ref.txt | 10 +- builtin/tag.c

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

2016-12-07 Thread Karthik Nayak
path components from the left. Add documentation and tests for the same. Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 5 +++-- ref-filter.c | 26 +- t/t6300-for-each-ref.sh| 15 --- 3 files changed, 3

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 m

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 '%(symref)

[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 --- Documentation/git-f

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 we port branch.c to use ref

[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 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 '%(push)' and '%(u

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

2016-12-07 Thread Karthik Nayak
From: Karthik Nayak 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 '

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

2016-12-07 Thread Karthik Nayak
char *s) for safer string insertions in branch.c:build_format(). Thanks to Jacob, Jackub, Junio 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

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 wrote: > Karthik Nayak 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 series. Maybe >> I'll follow up >> wi

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 wrote: > Karthik Nayak writes: > >> cc'in Matthieu since he wrote the patch. >> >> On Sat, Nov 19, 2016 at 4:16 AM, Jakub Narębski wrote: >>> W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >>

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

2016-11-22 Thread Karthik Nayak
27;) { > strbuf_addstr(&buf, "%%"); > 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 wrote: > On Fri, Nov 18, 2016 at 11:48 PM, Junio C Hamano wrote: >> Jacob Keller writes: >> >>>>>> to get remotes from /refs/foo/abc/xyz we'd need to do >>>>>> strip=1,strip=-1, whi

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 wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> From: Karthik Nayak >> >> Introduce setup_ref_filter_porcelain_msg() so that the messages used in >> the atom %(u

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

2016-11-20 Thread Karthik Nayak
quot;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 additional >>> atoms. So if you th

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 wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> From: Karthik Nayak >> >> Since there are multiple atoms which print refs ('%(refname)', >> '%(symref)', '%(push)', '%upstrea

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 wrote: > W dniu 08.11.2016 o 21:12, Karthik Nayak pisze: >> >> Helped-by: Junio C Hamano >> Signed-off-by: Karthik Nayak >> --- > [...] > >> +test_expect_success 'Add symbolic ref for the following tests

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 wrote: > W dniu 08.11.2016 o 21:11, Karthik Nayak pisze: >> From: Karthik Nayak >> >> Implement %(if:equals=) wherein the if condition is only >> satisfied if the value obtained between the %(if:...) and %(then) atom

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 wrote: > Karthik Nayak writes: > >> Thanks, will add it in. > > OK, here is a reroll of what I sent earlier in > > > http://public-inbox.org/git/ > > but rebased so that it can happen as a preparatory bugfix

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 wrote: > Karthik Nayak writes: > >> On Tue, Nov 15, 2016 at 11:12 PM, Junio C Hamano wrote: >>> Jacob Keller writes: >>> ... >>> I think you are going in the right direction. I had a similar >&g

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 wrote: > Karthik Nayak 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 ref-filter's >> printing options. &g

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

2016-11-15 Thread Karthik Nayak
uld 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(&fmt, "%%(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 wrote: > Karthik Nayak writes: > >>> - More importantly, what do these do? I do not think of a good >>>description that generalizes "base of refs/foo/bar/boz is foo" to >>>explain your :base. >

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 wrote: > Karthik Nayak writes: > >>>> diff --git a/Documentation/git-for-each-ref.txt >>>> b/Documentation/git-for-each-ref.txt >>>> index 600b703..f4ad297 100644 >>>> --- a/Documentation/git-

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 wrote: > On Tue, Nov 8, 2016 at 12:11 PM, Karthik Nayak wrote: >> 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 ref-fil

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 wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak wrote: >> From: Karthik Nayak >> >> Port branch.c to use ref-filter APIs for printing. This clears out >> most of the code used in branch.c for printing and

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 wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak wrote: >> From: Karthik Nayak >> Add tests and documentation for the same. >> >> Signed-off-by: Karthik Nayak >> --- >>

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 wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak wrote: >> From: Karthik Nayak > > What's the reasoning for using separate functions here if they are > exactly identical except for name? Do we intend to add separate >

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 wrote: > On Tue, Nov 8, 2016 at 12:12 PM, Karthik Nayak wrote: >> From: Karthik Nayak >> >> Add support for %(upstream:track,nobracket) which will print the >> tracking information without the brackets (i.e. "ahead

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

2016-11-12 Thread Karthik Nayak
considered a bug. > Didn't get you. >> Mentored-by: Christian Couder >> Mentored-by: Matthieu Moy >> Helped-by : Jacob Keller >> Signed-off-by: Karthik Nayak >> --- >> Documentation/git-for-each-ref.txt | 3 ++- >> ref-filter.c

  1   2   3   4   5   6   7   8   9   10   >