Re: [PATCH v3 08/31] parse_pathspec: add PATHSPEC_EMPTY_MATCH_ALL

2013-01-21 Thread Martin von Zweigbergk
Hi,

I was tempted to ask this before, and the recent thread regarding add
-u/A [1] convinced me to.

On Sun, Jan 13, 2013 at 4:35 AM, Nguyễn Thái Ngọc Duy pclo...@gmail.com wrote:
 We have two ways of dealing with empty pathspec:

 1. limit it to current prefix
 2. match the entire working directory

 Some commands go with #1, some with #2. get_pathspec() and
 parse_pathspec() only supports #1. Make it support #2 too via
 PATHSPEC_EMPTY_MATCH_ALL flag.

If #2 is indeed the direction we want to go, then maybe we should make
that the default behavior from parse_pathspec()? I.e. rename the flag
PATHSPEC_EMPTY_MATCH_PREFIX (or something). Makes sense?

Btw, Matthieu was asking where we use #1. If you do invert the name
and meaning of the flag, then the answer to that question should be
(mostly?) obvious from a re-roll of your series (i.e. all the places
where PATHSPEC_EMPTY_MATCH_PREFIX is used).

Martin

 [1] http://thread.gmane.org/gmane.comp.version-control.git/213988/focus=214113
--
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 v3 08/31] parse_pathspec: add PATHSPEC_EMPTY_MATCH_ALL

2013-01-21 Thread Duy Nguyen
On Tue, Jan 22, 2013 at 6:12 AM, Martin von Zweigbergk
martinv...@gmail.com wrote:
 Hi,

 I was tempted to ask this before, and the recent thread regarding add
 -u/A [1] convinced me to.

 On Sun, Jan 13, 2013 at 4:35 AM, Nguyễn Thái Ngọc Duy pclo...@gmail.com 
 wrote:
 We have two ways of dealing with empty pathspec:

 1. limit it to current prefix
 2. match the entire working directory

 Some commands go with #1, some with #2. get_pathspec() and
 parse_pathspec() only supports #1. Make it support #2 too via
 PATHSPEC_EMPTY_MATCH_ALL flag.

 If #2 is indeed the direction we want to go, then maybe we should make
 that the default behavior from parse_pathspec()? I.e. rename the flag
 PATHSPEC_EMPTY_MATCH_PREFIX (or something). Makes sense?

No problem with me. Will do unless someone objects.

 Btw, Matthieu was asking where we use #1. If you do invert the name
 and meaning of the flag, then the answer to that question should be
 (mostly?) obvious from a re-roll of your series (i.e. all the places
 where PATHSPEC_EMPTY_MATCH_PREFIX is used).

 Martin

  [1] 
 http://thread.gmane.org/gmane.comp.version-control.git/213988/focus=214113
-- 
Duy
--
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


[PATCH v3 08/31] parse_pathspec: add PATHSPEC_EMPTY_MATCH_ALL

2013-01-13 Thread Nguyễn Thái Ngọc Duy
We have two ways of dealing with empty pathspec:

1. limit it to current prefix
2. match the entire working directory

Some commands go with #1, some with #2. get_pathspec() and
parse_pathspec() only supports #1. Make it support #2 too via
PATHSPEC_EMPTY_MATCH_ALL flag.

Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 cache.h | 3 +++
 setup.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/cache.h b/cache.h
index 1f51423..32231d8 100644
--- a/cache.h
+++ b/cache.h
@@ -503,6 +503,9 @@ struct pathspec {
__FILE__, __LINE__, (ps)-magic  ~(mask)); \
} while (0)
 
+/* parse_pathspec flags */
+#define PATHSPEC_EMPTY_MATCH_ALL (10) /* No args means match everything */
+
 extern int init_pathspec(struct pathspec *, const char **);
 extern void parse_pathspec(struct pathspec *pathspec, unsigned magic_mask,
   unsigned flags, const char *prefix,
diff --git a/setup.c b/setup.c
index 0c9fc75..d0b1d1f 100644
--- a/setup.c
+++ b/setup.c
@@ -289,6 +289,9 @@ void parse_pathspec(struct pathspec *pathspec,
if (!entry  !prefix)
return;
 
+   if (!*argv  (flags  PATHSPEC_EMPTY_MATCH_ALL))
+   return;
+
/* No arguments with prefix - prefix pathspec */
if (!entry) {
static const char *raw[2];
-- 
1.8.0.rc2.23.g1fb49df

--
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