threads / patch / 38943

patchenter_repo(): fix suffix precedence documentation

Subject: [PATCH] enter_repo(): fix suffix precedence documentation

## tl;dr

8 messages between Mar 30, 2015 and Mar 31, 2015. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Paul Tan· Mar 30, 2015, 10:30 UTC · lore

The ordering of the list of suffixes tested in enter_repo() is documented as "%s.git/.git", "%s/.git", "%s.git", "%s". This does not match the ordering of the list of suffixes tested in the code which is "%s/.git", "%s", "%s.git/.git", "%s.git". Fix this.

Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
 path.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to path.c +2 −2
diff --git a/path.c b/path.c
index e608993..6479352 100644
--- a/path.c
+++ b/path.c
@@ -303,8 +303,8 @@ return_null:
  * (3) "relative/path" to mean cwd relative directory; or
  * (4) "/absolute/path" to mean absolute directory.
  *
- * Unless "strict" is given, we try access() for existence of "%s.git/.git",
- * "%s/.git", "%s.git", "%s" in this order.  The first one that exists is
+ * Unless "strict" is given, we try access() for existence of "%s/.git",
+ * "%s", "%s.git/.git", "%s.git" in this order. The first one that exists is
  * what we try.
  *
  * Second, we try chdir() to that.  Upon failure, we return NULL.
-- 
2.1.4
Matthieu Moy· Mar 30, 2015, 11:08 UTC · re: Paul Tan · lore

Re: [PATCH] enter_repo(): fix suffix precedence documentation

Paul Tan <pyokagan@gmail.com> writes:
> The ordering of the list of suffixes tested in enter_repo() is
> documented as "%s.git/.git", "%s/.git", "%s.git", "%s". This does not
> match the ordering of the list of suffixes tested in the code which is
> "%s/.git", "%s", "%s.git/.git", "%s.git". Fix this.
Indeed:
		static const char *suffix[] = {
			"/.git", "", ".git/.git", ".git", NULL,
		};
So the patch is clearly good. Thanks,
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Paul Tan· Mar 31, 2015, 13:39 UTC · re: Matthieu Moy · lore

[PATCH v2] enter_repo(): fix docs to match code

On Mon, Mar 30, 2015 at 07:44:08AM -0400, Jeff King wrote:
Show 7 quoted lines
> Yes, this was adjusted in b3256eb (standardize and improve lookup rules
> for external local repos, 2012-02-02), but I failed to update the
> comment.
> 
> Your patch is certainly an improvement, but I think there are more
> inaccuracies in the comment caused by that commit. Maybe squash this on
> top:
Thanks for catching.
I've squashed the patches and rewrote the commit message.
-->8--

In b3256eb (standardize and improve lookup rules for external local repos), enter_repo() was modified to use a different precedence ordering of suffixes for DWIM of the repository path, and to ensure that the repository path is actually valid instead of just testing for existence. However, the documentation was not modified to reflect these changes. As such, fix the documentation to match the code.

Documentation contributed by Jeff King.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
 path.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Show changes to path.c +3 −8
diff --git a/path.c b/path.c
index e608993..595da81 100644
--- a/path.c
+++ b/path.c
@@ -303,14 +303,9 @@ return_null:
  * (3) "relative/path" to mean cwd relative directory; or
  * (4) "/absolute/path" to mean absolute directory.
  *
- * Unless "strict" is given, we try access() for existence of "%s.git/.git",
- * "%s/.git", "%s.git", "%s" in this order.  The first one that exists is
- * what we try.
- *
- * Second, we try chdir() to that.  Upon failure, we return NULL.
- *
- * Then, we try if the current directory is a valid git repository.
- * Upon failure, we return NULL.
+ * Unless "strict" is given, we check "%s/.git", "%s", "%s.git/.git", "%s.git"
+ * in this order. We select the first one that is a valid git repository, and
+ * chdir() to it. If none match, or we fail to chdir, we return NULL.
  *
  * If all goes well, we return the directory we used to chdir() (but
  * before ~user is expanded), avoiding getcwd() resolving symbolic
-- 
2.1.4
Junio C Hamano· Mar 31, 2015, 17:35 UTC · re: Paul Tan · lore

Re: [PATCH v2] enter_repo(): fix docs to match code

Paul Tan <pyokagan@gmail.com> writes:
Show 27 quoted lines
> On Mon, Mar 30, 2015 at 07:44:08AM -0400, Jeff King wrote:
>> Yes, this was adjusted in b3256eb (standardize and improve lookup rules
>> for external local repos, 2012-02-02), but I failed to update the
>> comment.
>> 
>> Your patch is certainly an improvement, but I think there are more
>> inaccuracies in the comment caused by that commit. Maybe squash this on
>> top:
>
> Thanks for catching.
>
> I've squashed the patches and rewrote the commit message.
>
> -->8--
>
> In b3256eb (standardize and improve lookup rules for external local
> repos), enter_repo() was modified to use a different precedence ordering
> of suffixes for DWIM of the repository path, and to ensure that the
> repository path is actually valid instead of just testing for existence.
> However, the documentation was not modified to reflect these changes.
> As such, fix the documentation to match the code.
>
> Documentation contributed by Jeff King.
>
> Signed-off-by: Jeff King <peff@peff.net>
> Signed-off-by: Paul Tan <pyokagan@gmail.com>
> ---

It appears to me that Peff's "squash" is nullifying everything you did, so a more truthful attribution might be

	From: Jeff King <peff@peff.net>
	commit log message
	S-o-b: Jeff
        S-o-b: Paul Tan
Thanks.
Show 25 quoted lines
>  path.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/path.c b/path.c
> index e608993..595da81 100644
> --- a/path.c
> +++ b/path.c
> @@ -303,14 +303,9 @@ return_null:
>   * (3) "relative/path" to mean cwd relative directory; or
>   * (4) "/absolute/path" to mean absolute directory.
>   *
> - * Unless "strict" is given, we try access() for existence of "%s.git/.git",
> - * "%s/.git", "%s.git", "%s" in this order.  The first one that exists is
> - * what we try.
> - *
> - * Second, we try chdir() to that.  Upon failure, we return NULL.
> - *
> - * Then, we try if the current directory is a valid git repository.
> - * Upon failure, we return NULL.
> + * Unless "strict" is given, we check "%s/.git", "%s", "%s.git/.git", "%s.git"
> + * in this order. We select the first one that is a valid git repository, and
> + * chdir() to it. If none match, or we fail to chdir, we return NULL.
>   *
>   * If all goes well, we return the directory we used to chdir() (but
>   * before ~user is expanded), avoiding getcwd() resolving symbolic
Jeff King· Mar 31, 2015, 17:41 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] enter_repo(): fix docs to match code

On Tue, Mar 31, 2015 at 10:35:56AM -0700, Junio C Hamano wrote:
Show 15 quoted lines
> > In b3256eb (standardize and improve lookup rules for external local
> > repos), enter_repo() was modified to use a different precedence ordering
> > of suffixes for DWIM of the repository path, and to ensure that the
> > repository path is actually valid instead of just testing for existence.
> > However, the documentation was not modified to reflect these changes.
> > As such, fix the documentation to match the code.
> >
> > Documentation contributed by Jeff King.
> >
> > Signed-off-by: Jeff King <peff@peff.net>
> > Signed-off-by: Paul Tan <pyokagan@gmail.com>
> > ---
> 
> It appears to me that Peff's "squash" is nullifying everything you
> did, so a more truthful attribution might be

I'm not sure that's true. The precedence changed, and the "is it valid" check changed. The fix for the first is from Paul, but the latter is from me. My squash (hopefully) retained his half. My half just took more words to change.

I'm OK with the attribution either way (I do not need the credit, but am happy to take the blame).

-Peff
Junio C Hamano· Mar 31, 2015, 17:57 UTC · re: Jeff King · lore

Re: [PATCH v2] enter_repo(): fix docs to match code

Jeff King <peff@peff.net> writes:
> I'm not sure that's true. The precedence changed, and the "is it valid"
> check changed.
Yeah, I must have misread the review thread.

I only noticed that the postimage does not have any lines that v1 changed from the original, but at the word level there indeed are these changes you listed above.

Thanks.
Paul Tan· Mar 31, 2015, 18:10 UTC · re: Junio C Hamano · lore

[PATCH v3] enter_repo(): fix docs to match code

Hi,
On Wed, Apr 1, 2015 at 1:35 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> It appears to me that Peff's "squash" is nullifying everything you
> did, so a more truthful attribution might be
>
>         From: Jeff King <peff@peff.net>
>
>         commit log message
>
>         S-o-b: Jeff
>         S-o-b: Paul Tan
Thanks, didn't know that could be done. Fixed patch (and fixed scissors line) below,
-- >8 --
From: Jeff King <peff@peff.net>

In b3256eb (standardize and improve lookup rules for external local repos), enter_repo() was modified to use a different precedence ordering of suffixes for DWIM of the repository path, and to ensure that the repository path is actually valid instead of just testing for existence. However, the documentation was not modified to reflect these changes. As such, fix the documentation to match the code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
 path.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
Show changes to path.c +3 −8
diff --git a/path.c b/path.c
index e608993..595da81 100644
--- a/path.c
+++ b/path.c
@@ -303,14 +303,9 @@ return_null:
  * (3) "relative/path" to mean cwd relative directory; or
  * (4) "/absolute/path" to mean absolute directory.
  *
- * Unless "strict" is given, we try access() for existence of "%s.git/.git",
- * "%s/.git", "%s.git", "%s" in this order.  The first one that exists is
- * what we try.
- *
- * Second, we try chdir() to that.  Upon failure, we return NULL.
- *
- * Then, we try if the current directory is a valid git repository.
- * Upon failure, we return NULL.
+ * Unless "strict" is given, we check "%s/.git", "%s", "%s.git/.git", "%s.git"
+ * in this order. We select the first one that is a valid git repository, and
+ * chdir() to it. If none match, or we fail to chdir, we return NULL.
  *
  * If all goes well, we return the directory we used to chdir() (but
  * before ~user is expanded), avoiding getcwd() resolving symbolic
-- 
2.1.4
Jeff King· Mar 30, 2015, 11:44 UTC · re: Paul Tan · lore

Re: [PATCH] enter_repo(): fix suffix precedence documentation

On Mon, Mar 30, 2015 at 06:30:33PM +0800, Paul Tan wrote:
> The ordering of the list of suffixes tested in enter_repo() is
> documented as "%s.git/.git", "%s/.git", "%s.git", "%s". This does not
> match the ordering of the list of suffixes tested in the code which is
> "%s/.git", "%s", "%s.git/.git", "%s.git". Fix this.

Yes, this was adjusted in b3256eb (standardize and improve lookup rules for external local repos, 2012-02-02), but I failed to update the comment.

Your patch is certainly an improvement, but I think there are more inaccuracies in the comment caused by that commit. Maybe squash this on top:

Show changes to path.c +3 −8
diff --git a/path.c b/path.c
index 56f50bd..586f2c9 100644
--- a/path.c
+++ b/path.c
@@ -383,14 +383,9 @@ return_null:
  * (3) "relative/path" to mean cwd relative directory; or
  * (4) "/absolute/path" to mean absolute directory.
  *
- * Unless "strict" is given, we try access() for existence of "%s/.git",
- * "%s", "%s.git/.git", "%s.git" in this order. The first one that exists is
- * what we try.
- *
- * Second, we try chdir() to that.  Upon failure, we return NULL.
- *
- * Then, we try if the current directory is a valid git repository.
- * Upon failure, we return NULL.
+ * Unless "strict" is given, we check "%s/.git", "%s", "%s.git/.git", "%s.git"
+ * in this order. We select the first one that is a valid git repository, and
+ * chdir() to it. If none match, or we fail to chdir, we return NULL.
  *
  * If all goes well, we return the directory we used to chdir() (but
  * before ~user is expanded), avoiding getcwd() resolving symbolic

← back to recent threads