All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] builtin/mv: Get rid of the last caller of get_pathspec
@ 2015-08-03 17:53 Stefan Beller
  2015-08-03 22:48 ` Eric Sunshine
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Beller @ 2015-08-03 17:53 UTC (permalink / raw)
  To: git
  Cc: Stefan Beller, Johannes Schindelin, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

`get_pathspec` is deprecated and builtin/mv is its last caller, so getting
rid of `get_pathspec` is rather easy. By getting rid of `get_pathspec`,
the documentation such as 'technical/api-setup.txt' becomes easier to read
as the reader doesn't need to bear with the additional fact that
`get_pathspec` is deprecated.

The code in 'builtin/mv' still requires some work to make it less ugly.

CC: Johannes Schindelin <Johannes.Schindelin@gmx.de>
CC: Junio C Hamano <gitster@pobox.com>
CC: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/technical/api-setup.txt |  2 --
 builtin/mv.c                          | 19 ++++++++++++++++---
 cache.h                               |  1 -
 pathspec.c                            | 30 ------------------------------
 4 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/Documentation/technical/api-setup.txt b/Documentation/technical/api-setup.txt
index 540e455..eb1fa98 100644
--- a/Documentation/technical/api-setup.txt
+++ b/Documentation/technical/api-setup.txt
@@ -27,8 +27,6 @@ parse_pathspec(). This function takes several arguments:
 
 - prefix and args come from cmd_* functions
 
-get_pathspec() is obsolete and should never be used in new code.
-
 parse_pathspec() helps catch unsupported features and reject them
 politely. At a lower level, different pathspec-related functions may
 not support the same set of features. Such pathspec-sensitive
diff --git a/builtin/mv.c b/builtin/mv.c
index d1d4316..b89d90a 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -10,6 +10,7 @@
 #include "string-list.h"
 #include "parse-options.h"
 #include "submodule.h"
+#include "pathspec.h"
 
 static const char * const builtin_mv_usage[] = {
 	N_("git mv [<options>] <source>... <destination>"),
@@ -20,13 +21,19 @@ static const char * const builtin_mv_usage[] = {
 #define KEEP_TRAILING_SLASH 2
 
 static const char **internal_copy_pathspec(const char *prefix,
-					   const char **pathspec,
+					   const char **argv,
 					   int count, unsigned flags)
 {
 	int i;
+	struct pathspec ps;
 	const char **result = xmalloc((count + 1) * sizeof(const char *));
-	memcpy(result, pathspec, count * sizeof(const char *));
+	memcpy(result, argv, count * sizeof(const char *));
 	result[count] = NULL;
+
+	/*
+	 * NEEDSWORK: instead of preprocessing, pass the right flags to
+	 * parse_pathspec below.
+	 */
 	for (i = 0; i < count; i++) {
 		int length = strlen(result[i]);
 		int to_copy = length;
@@ -42,7 +49,13 @@ static const char **internal_copy_pathspec(const char *prefix,
 				result[i] = it;
 		}
 	}
-	return get_pathspec(prefix, result);
+
+	parse_pathspec(&ps,
+		       PATHSPEC_ALL_MAGIC &
+		       ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
+		       PATHSPEC_PREFER_CWD,
+		       prefix, result);
+	return ps._raw;
 }
 
 static const char *add_slash(const char *path)
diff --git a/cache.h b/cache.h
index 4f55466..d4e22e2 100644
--- a/cache.h
+++ b/cache.h
@@ -452,7 +452,6 @@ extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
-extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern void setup_work_tree(void);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
diff --git a/pathspec.c b/pathspec.c
index 9304ee3..b0e14e5 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -450,36 +450,6 @@ void parse_pathspec(struct pathspec *pathspec,
 	}
 }
 
-/*
- * N.B. get_pathspec() is deprecated in favor of the "struct pathspec"
- * based interface - see pathspec.c:parse_pathspec().
- *
- * Arguments:
- *  - prefix - a path relative to the root of the working tree
- *  - pathspec - a list of paths underneath the prefix path
- *
- * Iterates over pathspec, prepending each path with prefix,
- * and return the resulting list.
- *
- * If pathspec is empty, return a singleton list containing prefix.
- *
- * If pathspec and prefix are both empty, return an empty list.
- *
- * This is typically used by built-in commands such as add.c, in order
- * to normalize argv arguments provided to the built-in into a list of
- * paths to process, all relative to the root of the working tree.
- */
-const char **get_pathspec(const char *prefix, const char **pathspec)
-{
-	struct pathspec ps;
-	parse_pathspec(&ps,
-		       PATHSPEC_ALL_MAGIC &
-		       ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
-		       PATHSPEC_PREFER_CWD,
-		       prefix, pathspec);
-	return ps._raw;
-}
-
 void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
 {
 	*dst = *src;
-- 
2.5.0.2.g6ffee06.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] builtin/mv: Get rid of the last caller of get_pathspec
  2015-08-03 17:53 [PATCH] builtin/mv: Get rid of the last caller of get_pathspec Stefan Beller
@ 2015-08-03 22:48 ` Eric Sunshine
  2015-08-06 18:27   ` [PATCH 0/2] Remove get_pathspec finally Stefan Beller
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Sunshine @ 2015-08-03 22:48 UTC (permalink / raw)
  To: Stefan Beller
  Cc: Git List, Johannes Schindelin, Junio C Hamano,
	Nguyễn Thái Ngọc Duy

On Mon, Aug 3, 2015 at 1:53 PM, Stefan Beller <sbeller@google.com> wrote:
> `get_pathspec` is deprecated and builtin/mv is its last caller, so getting
> rid of `get_pathspec` is rather easy. By getting rid of `get_pathspec`,
> the documentation such as 'technical/api-setup.txt' becomes easier to read
> as the reader doesn't need to bear with the additional fact that
> `get_pathspec` is deprecated.
>
> The code in 'builtin/mv' still requires some work to make it less ugly.

Perhaps split this into two patches? One to free git-mv of
get_pathspec() dependence, and the second to actually retire
get_pathspec().

> Signed-off-by: Stefan Beller <sbeller@google.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 0/2] Remove get_pathspec finally
  2015-08-03 22:48 ` Eric Sunshine
@ 2015-08-06 18:27   ` Stefan Beller
  2015-08-06 18:27     ` [PATCH 1/2] builtin/mv: remove get_pathspec() Stefan Beller
  2015-08-06 18:27     ` [PATCH 2/2] pathspec: remove deprecated get_pathspec Stefan Beller
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Beller @ 2015-08-06 18:27 UTC (permalink / raw)
  To: git, gitster; +Cc: Stefan Beller, pclouds, sunshine

Remove the last caller of the get_pathspec function and the get_pathspec function
itself.

I stumbled into this as I was reading the documentation on pathspec, and the
first sentence

  get_pathspec() is obsolete and should never be used in new code.

made me wonder.

This replaces sb/remove-get-pathspec

Stefan Beller (2):
  builtin/mv: remove get_pathspec()
  pathspec: remove deprecated get_pathspec

 Documentation/technical/api-setup.txt |  2 --
 builtin/mv.c                          | 16 +++++++++++++---
 cache.h                               |  1 -
 pathspec.c                            | 36 -----------------------------------
 pathspec.h                            |  2 +-
 5 files changed, 14 insertions(+), 43 deletions(-)

-- 
2.5.0.239.g9728e1d.dirty

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] builtin/mv: remove get_pathspec()
  2015-08-06 18:27   ` [PATCH 0/2] Remove get_pathspec finally Stefan Beller
@ 2015-08-06 18:27     ` Stefan Beller
  2015-08-06 18:46       ` Eric Sunshine
  2015-08-06 18:27     ` [PATCH 2/2] pathspec: remove deprecated get_pathspec Stefan Beller
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Beller @ 2015-08-06 18:27 UTC (permalink / raw)
  To: git, gitster; +Cc: Stefan Beller, pclouds, sunshine

`get_pathspec` is deprecated and builtin/mv.c is its last caller, so
reimplement `get_pathspec` literally in builtin/mv.c

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 builtin/mv.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/builtin/mv.c b/builtin/mv.c
index d1d4316..99e9b3c 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -10,6 +10,7 @@
 #include "string-list.h"
 #include "parse-options.h"
 #include "submodule.h"
+#include "pathspec.h"
 
 static const char * const builtin_mv_usage[] = {
 	N_("git mv [<options>] <source>... <destination>"),
@@ -20,13 +21,16 @@ static const char * const builtin_mv_usage[] = {
 #define KEEP_TRAILING_SLASH 2
 
 static const char **internal_copy_pathspec(const char *prefix,
-					   const char **pathspec,
+					   const char **argv,
 					   int count, unsigned flags)
 {
 	int i;
+	struct pathspec ps;
 	const char **result = xmalloc((count + 1) * sizeof(const char *));
-	memcpy(result, pathspec, count * sizeof(const char *));
+	memcpy(result, argv, count * sizeof(const char *));
 	result[count] = NULL;
+
+	/* NEEDSWORK: Move these preprocessing steps into parse_pathspec */
 	for (i = 0; i < count; i++) {
 		int length = strlen(result[i]);
 		int to_copy = length;
@@ -42,7 +46,13 @@ static const char **internal_copy_pathspec(const char *prefix,
 				result[i] = it;
 		}
 	}
-	return get_pathspec(prefix, result);
+
+	parse_pathspec(&ps,
+		       PATHSPEC_ALL_MAGIC &
+		       ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
+		       PATHSPEC_PREFER_CWD,
+		       prefix, result);
+	return ps._raw;
 }
 
 static const char *add_slash(const char *path)
-- 
2.5.0.239.g9728e1d.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] pathspec: remove deprecated get_pathspec
  2015-08-06 18:27   ` [PATCH 0/2] Remove get_pathspec finally Stefan Beller
  2015-08-06 18:27     ` [PATCH 1/2] builtin/mv: remove get_pathspec() Stefan Beller
@ 2015-08-06 18:27     ` Stefan Beller
  1 sibling, 0 replies; 9+ messages in thread
From: Stefan Beller @ 2015-08-06 18:27 UTC (permalink / raw)
  To: git, gitster; +Cc: Stefan Beller, pclouds, sunshine

The function `get_pathspec` is no longer used, so remove it.

The NEEDSWORK comment in pathspec.c is outdated as that happened in
(fadf96aba, 2013-09-09, Merge branch 'nd/magic-pathspec')

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/technical/api-setup.txt |  2 --
 cache.h                               |  1 -
 pathspec.c                            | 36 -----------------------------------
 pathspec.h                            |  2 +-
 4 files changed, 1 insertion(+), 40 deletions(-)

diff --git a/Documentation/technical/api-setup.txt b/Documentation/technical/api-setup.txt
index 540e455..eb1fa98 100644
--- a/Documentation/technical/api-setup.txt
+++ b/Documentation/technical/api-setup.txt
@@ -27,8 +27,6 @@ parse_pathspec(). This function takes several arguments:
 
 - prefix and args come from cmd_* functions
 
-get_pathspec() is obsolete and should never be used in new code.
-
 parse_pathspec() helps catch unsupported features and reject them
 politely. At a lower level, different pathspec-related functions may
 not support the same set of features. Such pathspec-sensitive
diff --git a/cache.h b/cache.h
index 4f55466..d4e22e2 100644
--- a/cache.h
+++ b/cache.h
@@ -452,7 +452,6 @@ extern void set_git_work_tree(const char *tree);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
-extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern void setup_work_tree(void);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
diff --git a/pathspec.c b/pathspec.c
index 9304ee3..abaec0a 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -94,12 +94,6 @@ static void prefix_short_magic(struct strbuf *sb, int prefixlen,
  *
  * For now, we only parse the syntax and throw out anything other than
  * "top" magic.
- *
- * NEEDSWORK: This needs to be rewritten when we start migrating
- * get_pathspec() users to use the "struct pathspec" interface.  For
- * example, a pathspec element may be marked as case-insensitive, but
- * the prefix part must always match literally, and a single stupid
- * string cannot express such a case.
  */
 static unsigned prefix_pathspec(struct pathspec_item *item,
 				unsigned *p_short_magic,
@@ -450,36 +444,6 @@ void parse_pathspec(struct pathspec *pathspec,
 	}
 }
 
-/*
- * N.B. get_pathspec() is deprecated in favor of the "struct pathspec"
- * based interface - see pathspec.c:parse_pathspec().
- *
- * Arguments:
- *  - prefix - a path relative to the root of the working tree
- *  - pathspec - a list of paths underneath the prefix path
- *
- * Iterates over pathspec, prepending each path with prefix,
- * and return the resulting list.
- *
- * If pathspec is empty, return a singleton list containing prefix.
- *
- * If pathspec and prefix are both empty, return an empty list.
- *
- * This is typically used by built-in commands such as add.c, in order
- * to normalize argv arguments provided to the built-in into a list of
- * paths to process, all relative to the root of the working tree.
- */
-const char **get_pathspec(const char *prefix, const char **pathspec)
-{
-	struct pathspec ps;
-	parse_pathspec(&ps,
-		       PATHSPEC_ALL_MAGIC &
-		       ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
-		       PATHSPEC_PREFER_CWD,
-		       prefix, pathspec);
-	return ps._raw;
-}
-
 void copy_pathspec(struct pathspec *dst, const struct pathspec *src)
 {
 	*dst = *src;
diff --git a/pathspec.h b/pathspec.h
index 0c11262..b345df6 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -19,7 +19,7 @@
 #define PATHSPEC_ONESTAR 1	/* the pathspec pattern satisfies GFNM_ONESTAR */
 
 struct pathspec {
-	const char **_raw; /* get_pathspec() result, not freed by free_pathspec() */
+	const char **_raw; /* not freed by free_pathspec() */
 	int nr;
 	unsigned int has_wildcard:1;
 	unsigned int recursive:1;
-- 
2.5.0.239.g9728e1d.dirty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] builtin/mv: remove get_pathspec()
  2015-08-06 18:27     ` [PATCH 1/2] builtin/mv: remove get_pathspec() Stefan Beller
@ 2015-08-06 18:46       ` Eric Sunshine
  2015-08-06 18:58         ` Stefan Beller
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Sunshine @ 2015-08-06 18:46 UTC (permalink / raw)
  To: Stefan Beller
  Cc: Git List, Junio C Hamano, Nguyễn Thái Ngọc Duy

On Thu, Aug 6, 2015 at 2:27 PM, Stefan Beller <sbeller@google.com> wrote:
>  builtin/mv: remove get_pathspec()

Misleading. Perhaps rephrase as:

    mv: drop dependency upon deprecated get_pathspec

> `get_pathspec` is deprecated and builtin/mv.c is its last caller, so
> reimplement `get_pathspec` literally in builtin/mv.c

Curious. Since this is just moving code around, rather than doing the
actual work to complete the final step as stated by the NEEDSWORK
comment, isn't it just moving the "problem" from one location to
another? Is it worth the code churn?

> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> diff --git a/builtin/mv.c b/builtin/mv.c
> index d1d4316..99e9b3c 100644
> --- a/builtin/mv.c
> +++ b/builtin/mv.c
> @@ -10,6 +10,7 @@
>  #include "string-list.h"
>  #include "parse-options.h"
>  #include "submodule.h"
> +#include "pathspec.h"
>
>  static const char * const builtin_mv_usage[] = {
>         N_("git mv [<options>] <source>... <destination>"),
> @@ -20,13 +21,16 @@ static const char * const builtin_mv_usage[] = {
>  #define KEEP_TRAILING_SLASH 2
>
>  static const char **internal_copy_pathspec(const char *prefix,
> -                                          const char **pathspec,
> +                                          const char **argv,

What is this change about? It doesn't seem to be related to anything
else in the patch or to its stated purpose, and makes the argument's
purpose less clear, so it's not obvious why it is a good change.

>                                            int count, unsigned flags)
>  {
>         int i;
> +       struct pathspec ps;
>         const char **result = xmalloc((count + 1) * sizeof(const char *));
> -       memcpy(result, pathspec, count * sizeof(const char *));
> +       memcpy(result, argv, count * sizeof(const char *));
>         result[count] = NULL;
> +
> +       /* NEEDSWORK: Move these preprocessing steps into parse_pathspec */
>         for (i = 0; i < count; i++) {
>                 int length = strlen(result[i]);
>                 int to_copy = length;
> @@ -42,7 +46,13 @@ static const char **internal_copy_pathspec(const char *prefix,
>                                 result[i] = it;
>                 }
>         }
> -       return get_pathspec(prefix, result);
> +
> +       parse_pathspec(&ps,
> +                      PATHSPEC_ALL_MAGIC &
> +                      ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
> +                      PATHSPEC_PREFER_CWD,
> +                      prefix, result);
> +       return ps._raw;
>  }
>
>  static const char *add_slash(const char *path)
> --
> 2.5.0.239.g9728e1d.dirty

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] builtin/mv: remove get_pathspec()
  2015-08-06 18:46       ` Eric Sunshine
@ 2015-08-06 18:58         ` Stefan Beller
  2015-08-06 20:18           ` Eric Sunshine
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Beller @ 2015-08-06 18:58 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Git List, Junio C Hamano, Nguyễn Thái Ngọc Duy

On Thu, Aug 6, 2015 at 11:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Thu, Aug 6, 2015 at 2:27 PM, Stefan Beller <sbeller@google.com> wrote:
>>  builtin/mv: remove get_pathspec()
>
> Misleading. Perhaps rephrase as:
>
>     mv: drop dependency upon deprecated get_pathspec
>
>> `get_pathspec` is deprecated and builtin/mv.c is its last caller, so
>> reimplement `get_pathspec` literally in builtin/mv.c
>
> Curious. Since this is just moving code around, rather than doing the
> actual work to complete the final step as stated by the NEEDSWORK
> comment, isn't it just moving the "problem" from one location to
> another? Is it worth the code churn?

Yeah it is moving around the problem a bit. And the code churn is
unfortunate. Though when I was reading the documentation on
pathspecs, literally the first sentence was "Do not use get_pathspec,
it is out dated". And that was a sad taste for reading documentation.

It's ok to have such warnings in the docs, but as the first sentence as if
there was nothing more important than avoiding the out dated stuff? I
mean I want to understand the actual code and how I can use it, right?

And there are different approaches to solving the problem.
I could have just reworded or even just rearranged the documentation.

The approach I take here includes a bit of code churn, but it moves the
problematic pieces all in one spot.

>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>> diff --git a/builtin/mv.c b/builtin/mv.c
>> index d1d4316..99e9b3c 100644
>> --- a/builtin/mv.c
>> +++ b/builtin/mv.c
>> @@ -10,6 +10,7 @@
>>  #include "string-list.h"
>>  #include "parse-options.h"
>>  #include "submodule.h"
>> +#include "pathspec.h"
>>
>>  static const char * const builtin_mv_usage[] = {
>>         N_("git mv [<options>] <source>... <destination>"),
>> @@ -20,13 +21,16 @@ static const char * const builtin_mv_usage[] = {
>>  #define KEEP_TRAILING_SLASH 2
>>
>>  static const char **internal_copy_pathspec(const char *prefix,
>> -                                          const char **pathspec,
>> +                                          const char **argv,
>
> What is this change about? It doesn't seem to be related to anything
> else in the patch or to its stated purpose, and makes the argument's
> purpose less clear, so it's not obvious why it is a good change.
>
>>                                            int count, unsigned flags)
>>  {
>>         int i;
>> +       struct pathspec ps;
>>         const char **result = xmalloc((count + 1) * sizeof(const char *));
>> -       memcpy(result, pathspec, count * sizeof(const char *));
>> +       memcpy(result, argv, count * sizeof(const char *));
>>         result[count] = NULL;
>> +
>> +       /* NEEDSWORK: Move these preprocessing steps into parse_pathspec */
>>         for (i = 0; i < count; i++) {
>>                 int length = strlen(result[i]);
>>                 int to_copy = length;
>> @@ -42,7 +46,13 @@ static const char **internal_copy_pathspec(const char *prefix,
>>                                 result[i] = it;
>>                 }
>>         }
>> -       return get_pathspec(prefix, result);
>> +
>> +       parse_pathspec(&ps,
>> +                      PATHSPEC_ALL_MAGIC &
>> +                      ~(PATHSPEC_FROMTOP | PATHSPEC_LITERAL),
>> +                      PATHSPEC_PREFER_CWD,
>> +                      prefix, result);
>> +       return ps._raw;
>>  }
>>
>>  static const char *add_slash(const char *path)
>> --
>> 2.5.0.239.g9728e1d.dirty

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] builtin/mv: remove get_pathspec()
  2015-08-06 18:58         ` Stefan Beller
@ 2015-08-06 20:18           ` Eric Sunshine
  2015-08-06 20:59             ` Stefan Beller
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Sunshine @ 2015-08-06 20:18 UTC (permalink / raw)
  To: Stefan Beller
  Cc: Git List, Junio C Hamano, Nguyễn Thái Ngọc Duy

On Thu, Aug 6, 2015 at 2:58 PM, Stefan Beller <sbeller@google.com> wrote:
> On Thu, Aug 6, 2015 at 11:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Thu, Aug 6, 2015 at 2:27 PM, Stefan Beller <sbeller@google.com> wrote:
>>> `get_pathspec` is deprecated and builtin/mv.c is its last caller, so
>>> reimplement `get_pathspec` literally in builtin/mv.c
>>
>> Curious. Since this is just moving code around, rather than doing the
>> actual work to complete the final step as stated by the NEEDSWORK
>> comment, isn't it just moving the "problem" from one location to
>> another? Is it worth the code churn?
>
> Yeah it is moving around the problem a bit. And the code churn is
> unfortunate. Though when I was reading the documentation on
> pathspecs, literally the first sentence was "Do not use get_pathspec,
> it is out dated". And that was a sad taste for reading documentation.

By loudly warning you about deprecation and, more importantly,
pointing you at the accepted alternative, this documentation saves you
from wasting time (both time spent reading and time spent going down a
dead-end path). It would be a "sad taste" if it warned you quietly
only at the end of the documentation or not at all.

> It's ok to have such warnings in the docs, but as the first sentence as if
> there was nothing more important than avoiding the out dated stuff?

>From a documentation standpoint, there is nothing more important than
warning you to avoid it since it is outdated and likely to go away in
the future.

> I mean I want to understand the actual code and how I can use it, right?

No. It's deprecated and not meant for your use.

It's a different matter if you want to understand what the function
does because you've encountered a call in existing code, but that case
is covered by the existing documentation still being intact (that is,
it wasn't removed when the deprecation notice was added).

> And there are different approaches to solving the problem.
> I could have just reworded or even just rearranged the documentation.

The documentation seems fine as-is.

> The approach I take here includes a bit of code churn, but it moves the
> problematic pieces all in one spot.

Indeed, I had the "localizing the problem to one spot" argument in
mind, and even wrote it as an answer to my own question, but deleted
it before hitting "Send". The counterargument (aside from code churn)
is, that by leaving it alone, it serves as a good reminder of the
"problem" and is more likely to get noticed and (perhaps) fixed by
someone than if it is hidden away in builtin/mv.c.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] builtin/mv: remove get_pathspec()
  2015-08-06 20:18           ` Eric Sunshine
@ 2015-08-06 20:59             ` Stefan Beller
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Beller @ 2015-08-06 20:59 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Git List, Junio C Hamano, Nguyễn Thái Ngọc Duy

On Thu, Aug 6, 2015 at 1:18 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Thu, Aug 6, 2015 at 2:58 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Thu, Aug 6, 2015 at 11:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>>> On Thu, Aug 6, 2015 at 2:27 PM, Stefan Beller <sbeller@google.com> wrote:
>>>> `get_pathspec` is deprecated and builtin/mv.c is its last caller, so
>>>> reimplement `get_pathspec` literally in builtin/mv.c
>>>
>>> Curious. Since this is just moving code around, rather than doing the
>>> actual work to complete the final step as stated by the NEEDSWORK
>>> comment, isn't it just moving the "problem" from one location to
>>> another? Is it worth the code churn?
>>
>> Yeah it is moving around the problem a bit. And the code churn is
>> unfortunate. Though when I was reading the documentation on
>> pathspecs, literally the first sentence was "Do not use get_pathspec,
>> it is out dated". And that was a sad taste for reading documentation.
>
> By loudly warning you about deprecation and, more importantly,
> pointing you at the accepted alternative, this documentation saves you
> from wasting time (both time spent reading and time spent going down a
> dead-end path). It would be a "sad taste" if it warned you quietly
> only at the end of the documentation or not at all.
>
>> It's ok to have such warnings in the docs, but as the first sentence as if
>> there was nothing more important than avoiding the out dated stuff?
>
> From a documentation standpoint, there is nothing more important than
> warning you to avoid it since it is outdated and likely to go away in
> the future.
>
>> I mean I want to understand the actual code and how I can use it, right?
>
> No. It's deprecated and not meant for your use.

I need to be more precise:
I mean I want to learn how to deal with <pathspec> things in code.
Assume I know nothing of the history of that code and its deprecated
earlier attempts. So I would expect a documentation like:

    foo-bar(int arg): bars the foos with the specific thing equal `arg`

    foobaz(int a, int b, int c): Note: this is outdated, bars the foos with ...

in that order, so if I were to start reading from top to bottom, I would find
the current version first and could jump off starting writing code based on
foo-bar.

If I was reading code and wonder: "What does foobaz exactly do? Oh
I know! I'll consult the documentation", then I would find the note about
it being out dated and preferably its suggested new replacement.

However I perceived the documentation I read more like this:

    some words on foo-bar, a bit too shallow (a good overview,
    but I'd like to know more details, so keep reading)

    note on foobaz being outdated

    more words on foo-bar

>
> It's a different matter if you want to understand what the function
> does because you've encountered a call in existing code, but that case
> is covered by the existing documentation still being intact (that is,
> it wasn't removed when the deprecation notice was added).
>
>> And there are different approaches to solving the problem.
>> I could have just reworded or even just rearranged the documentation.
>
> The documentation seems fine as-is.
>
>> The approach I take here includes a bit of code churn, but it moves the
>> problematic pieces all in one spot.
>
> Indeed, I had the "localizing the problem to one spot" argument in
> mind, and even wrote it as an answer to my own question, but deleted
> it before hitting "Send". The counterargument (aside from code churn)
> is, that by leaving it alone, it serves as a good reminder of the
> "problem" and is more likely to get noticed and (perhaps) fixed by
> someone than if it is hidden away in builtin/mv.c.

Having code just in one ugly spot however helps people in the other areas,
where they can see the shiny new thing in action and don't have the mental
burden of seeing a NEEDSWORK comment and thinking about that instead
of the feature they want to add there.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-06 21:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 17:53 [PATCH] builtin/mv: Get rid of the last caller of get_pathspec Stefan Beller
2015-08-03 22:48 ` Eric Sunshine
2015-08-06 18:27   ` [PATCH 0/2] Remove get_pathspec finally Stefan Beller
2015-08-06 18:27     ` [PATCH 1/2] builtin/mv: remove get_pathspec() Stefan Beller
2015-08-06 18:46       ` Eric Sunshine
2015-08-06 18:58         ` Stefan Beller
2015-08-06 20:18           ` Eric Sunshine
2015-08-06 20:59             ` Stefan Beller
2015-08-06 18:27     ` [PATCH 2/2] pathspec: remove deprecated get_pathspec Stefan Beller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.