Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-23 Thread Karthik Nayak
On Tue, Jun 23, 2015 at 4:08 AM, Eric Sunshine sunsh...@sunshineco.com wrote:
 On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak karthik@gmail.com wrote:
 Add the '--points-at' option provided by 'ref-filter'. The
 option lets the user to pick only refs which point to a particular
 commit.

 Add documentation and tests for the same.

 Based-on-patch-by: Jeff King p...@peff.net
 Mentored-by: Christian Couder christian.cou...@gmail.com
 Mentored-by: Matthieu Moy matthieu@grenoble-inp.fr
 Signed-off-by: Karthik Nayak karthik@gmail.com
 ---
 diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh
 index b1fa8d4..67de3a7 100755
 --- a/t/t6301-for-each-ref-filter.sh
 +++ b/t/t6301-for-each-ref-filter.sh
 @@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '
 git update-ref refs/odd/spot master
  '

 +test_expect_success 'filtering with --points-at' '
 +   cat expect -\EOF 
 +   refs/heads/master
 +   refs/odd/spot
 +   refs/tags/three
 +   EOF
 +   git for-each-ref --format=%(refname) --points-at=master actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success 'check signed tags with --points-at' '
 +   cat expect -\EOF 
 +   refs/heads/side
 +   refs/tags/four
 +   refs/tags/signed-tag four
 +   EOF
 +   git for-each-ref  --format=%(refname) %(*subject) --points-at=side 
 actual 

 s/for-each-ref\s+/for-each-ref /


Will change! thanks :)


-- 
Regards,
Karthik Nayak
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Karthik Nayak
On Tue, Jun 23, 2015 at 12:54 AM, Junio C Hamano gits...@pobox.com wrote:
 Matthieu Moy matthieu@grenoble-inp.fr writes:

 Karthik Nayak karthik@gmail.com writes:

 On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano gits...@pobox.com wrote:
  3  4 as a single patch may make more sense, if we were to tolerate the
 let's copy  paste first and then later remove the duplicate as a way to
 postpone touching tag.c side in order to first concentrate on 
 for-each-ref.

 I have not formed a firm opinion on what the right split of the series is, 
 but
 so far (assuming that the temporary duplication is the best we can do) what
 I am seeing in this series makes sense to me.

 Thanks.

 That would mean squashing 34, 67 and 1011 also on similar lines.

 I have a slight preference for keeping the pairs not squashed. This way,
 we have a clear separation write reusable library code / use it. But
 I'm fine with squashing if others prefer.

 As I cannot firmly say that copy  paste first and then later
 clean-up is bad and we should split them in different way, I
 am fine with leaving them separate as they are.

Even I think it's better to leave them separate, on the lines of what
Matthieu said.

-- 
Regards,
Karthik Nayak
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Eric Sunshine
On Sun, Jun 21, 2015 at 4:48 PM, Karthik Nayak karthik@gmail.com wrote:
 Add the '--points-at' option provided by 'ref-filter'. The
 option lets the user to pick only refs which point to a particular
 commit.

 Add documentation and tests for the same.

 Based-on-patch-by: Jeff King p...@peff.net
 Mentored-by: Christian Couder christian.cou...@gmail.com
 Mentored-by: Matthieu Moy matthieu@grenoble-inp.fr
 Signed-off-by: Karthik Nayak karthik@gmail.com
 ---
 diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh
 index b1fa8d4..67de3a7 100755
 --- a/t/t6301-for-each-ref-filter.sh
 +++ b/t/t6301-for-each-ref-filter.sh
 @@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '
 git update-ref refs/odd/spot master
  '

 +test_expect_success 'filtering with --points-at' '
 +   cat expect -\EOF 
 +   refs/heads/master
 +   refs/odd/spot
 +   refs/tags/three
 +   EOF
 +   git for-each-ref --format=%(refname) --points-at=master actual 
 +   test_cmp expect actual
 +'
 +
 +test_expect_success 'check signed tags with --points-at' '
 +   cat expect -\EOF 
 +   refs/heads/side
 +   refs/tags/four
 +   refs/tags/signed-tag four
 +   EOF
 +   git for-each-ref  --format=%(refname) %(*subject) --points-at=side 
 actual 

s/for-each-ref\s+/for-each-ref /

 +   test_cmp expect actual
 +'
 +
  test_done
 --
 2.4.3.439.gfea0c2a.dirty
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Junio C Hamano
Junio C Hamano gits...@pobox.com writes:

 I have a slight preference for keeping the pairs not squashed. This way,
 we have a clear separation write reusable library code / use it. But
 I'm fine with squashing if others prefer.

 As I cannot firmly say that copy  paste first and then later
 clean-up is bad and we should split them in different way, I
 am fine with leaving them separate as they are.

Having said that, I have a slight preference that a split does not
break my build in the middle of the series by introducing an
unused function, which is noticed by the compiler as a warning, and
turned into an error with -Werror.
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Junio C Hamano
Matthieu Moy matthieu@grenoble-inp.fr writes:

 Karthik Nayak karthik@gmail.com writes:

 On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano gits...@pobox.com wrote:
  3  4 as a single patch may make more sense, if we were to tolerate the
 let's copy  paste first and then later remove the duplicate as a way to
 postpone touching tag.c side in order to first concentrate on 
 for-each-ref.

 I have not formed a firm opinion on what the right split of the series is, 
 but
 so far (assuming that the temporary duplication is the best we can do) what
 I am seeing in this series makes sense to me.

 Thanks.

 That would mean squashing 34, 67 and 1011 also on similar lines.

 I have a slight preference for keeping the pairs not squashed. This way,
 we have a clear separation write reusable library code / use it. But
 I'm fine with squashing if others prefer.

As I cannot firmly say that copy  paste first and then later
clean-up is bad and we should split them in different way, I
am fine with leaving them separate as they are.
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Karthik Nayak
On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano gits...@pobox.com wrote:
  3  4 as a single patch may make more sense, if we were to tolerate the
 let's copy  paste first and then later remove the duplicate as a way to
 postpone touching tag.c side in order to first concentrate on for-each-ref.

 I have not formed a firm opinion on what the right split of the series is, but
 so far (assuming that the temporary duplication is the best we can do) what
 I am seeing in this series makes sense to me.

 Thanks.

That would mean squashing 34, 67 and 1011 also on similar lines.

-- 
Regards,
Karthik Nayak
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-22 Thread Matthieu Moy
Karthik Nayak karthik@gmail.com writes:

 On Mon, Jun 22, 2015 at 6:15 AM, Junio C Hamano gits...@pobox.com wrote:
  3  4 as a single patch may make more sense, if we were to tolerate the
 let's copy  paste first and then later remove the duplicate as a way to
 postpone touching tag.c side in order to first concentrate on for-each-ref.

 I have not formed a firm opinion on what the right split of the series is, 
 but
 so far (assuming that the temporary duplication is the best we can do) what
 I am seeing in this series makes sense to me.

 Thanks.

 That would mean squashing 34, 67 and 1011 also on similar lines.

I have a slight preference for keeping the pairs not squashed. This way,
we have a clear separation write reusable library code / use it. But
I'm fine with squashing if others prefer.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line unsubscribe git in


Re: [PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-21 Thread Junio C Hamano
 3  4 as a single patch may make more sense, if we were to tolerate the
let's copy  paste first and then later remove the duplicate as a way to
postpone touching tag.c side in order to first concentrate on for-each-ref.

I have not formed a firm opinion on what the right split of the series is, but
so far (assuming that the temporary duplication is the best we can do) what
I am seeing in this series makes sense to me.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe git in


[PATCH v4 04/19] for-each-ref: add '--points-at' option

2015-06-21 Thread Karthik Nayak
Add the '--points-at' option provided by 'ref-filter'. The
option lets the user to pick only refs which point to a particular
commit.

Add documentation and tests for the same.

Based-on-patch-by: Jeff King p...@peff.net
Mentored-by: Christian Couder christian.cou...@gmail.com
Mentored-by: Matthieu Moy matthieu@grenoble-inp.fr
Signed-off-by: Karthik Nayak karthik@gmail.com
---
 Documentation/git-for-each-ref.txt |  3 +++
 builtin/for-each-ref.c |  9 +++--
 t/t6301-for-each-ref-filter.sh | 20 
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-for-each-ref.txt 
b/Documentation/git-for-each-ref.txt
index 7f8d9a5..0ede41d 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -10,6 +10,7 @@ SYNOPSIS
 [verse]
 'git for-each-ref' [--count=count] [--shell|--perl|--python|--tcl]
   [(--sort=key)...] [--format=format] [pattern...]
+  [--points-at object]
 
 DESCRIPTION
 ---
@@ -62,6 +63,8 @@ OPTIONS
the specified host language.  This is meant to produce
a scriptlet that can directly be `eval`ed.
 
+--points-at object::
+   Only list refs pointing to the given object.
 
 FIELD NAMES
 ---
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 7919206..46f9b05 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -7,6 +7,7 @@
 
 static char const * const for_each_ref_usage[] = {
N_(git for-each-ref [options] [pattern]),
+   N_(git for-each-ref [--points-at object]),
NULL
 };
 
@@ -34,9 +35,15 @@ int cmd_for_each_ref(int argc, const char **argv, const char 
*prefix)
OPT_STRING(  0 , format, format, N_(format), N_(format to 
use for the output)),
OPT_CALLBACK(0 , sort, sorting_tail, N_(key),
N_(field name to sort on), 
parse_opt_ref_sorting),
+   OPT_CALLBACK(0, points-at, filter.points_at,
+N_(object), N_(print only refs pointing to the 
given object),
+parse_opt_object_name),
OPT_END(),
};
 
+   memset(array, 0, sizeof(array));
+   memset(filter, 0, sizeof(filter));
+
parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);
if (maxcount  0) {
error(invalid --count argument: `%d', maxcount);
@@ -55,8 +62,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char 
*prefix)
/* for warn_ambiguous_refs */
git_config(git_default_config, NULL);
 
-   memset(array, 0, sizeof(array));
-   memset(filter, 0, sizeof(filter));
filter.name_patterns = argv;
filter_refs(array, filter, FILTER_REFS_ALL | 
FILTER_REFS_INCLUDE_BROKEN);
ref_array_sort(sorting, array);
diff --git a/t/t6301-for-each-ref-filter.sh b/t/t6301-for-each-ref-filter.sh
index b1fa8d4..67de3a7 100755
--- a/t/t6301-for-each-ref-filter.sh
+++ b/t/t6301-for-each-ref-filter.sh
@@ -16,4 +16,24 @@ test_expect_success 'setup some history and refs' '
git update-ref refs/odd/spot master
 '
 
+test_expect_success 'filtering with --points-at' '
+   cat expect -\EOF 
+   refs/heads/master
+   refs/odd/spot
+   refs/tags/three
+   EOF
+   git for-each-ref --format=%(refname) --points-at=master actual 
+   test_cmp expect actual
+'
+
+test_expect_success 'check signed tags with --points-at' '
+   cat expect -\EOF 
+   refs/heads/side 
+   refs/tags/four 
+   refs/tags/signed-tag four
+   EOF
+   git for-each-ref  --format=%(refname) %(*subject) --points-at=side 
actual 
+   test_cmp expect actual
+'
+
 test_done
-- 
2.4.3.439.gfea0c2a.dirty

--
To unsubscribe from this list: send the line unsubscribe git in