enter_repo(): fix suffix precedence documentation
PATCH 1/1 enter_repo(): fix suffix precedence documentation
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.
--- path.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
path.c +2 -2
@@ -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.
Signature · 1 line
2.1.4
Quoted 4 lines · Paul Tan
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:
path.c +3 -8
@@ -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
Quoted 4 lines · Paul Tan
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,
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
PATCH v2 1/1 enter_repo(): fix docs to match code
Quoted 7 lines · Jeff King
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.
--- path.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
path.c +3 -8
@@ -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
Signature · 1 line
2.1.4
Re: [PATCH v2] enter_repo(): fix docs to match code
Quoted 22 lines · Paul Tan
Quoted 7 lines · Jeff King
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.
Quoted 5 lines
Documentation contributed by Jeff King.
Signed-off-by Jeff King <[email protected]>Signed-off-by Paul Tan <[email protected]>---
It appears to me that Peff's "squash" is nullifying everything you did, so a more truthful attribution might be
From: Jeff King <[email protected]>
commit log message
S-o-b: Jeff
S-o-b: Paul Tan
Thanks.
Quoted 25 lines
path.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)path.c +3
-8@@ -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
PATCH v3 1/1 enter_repo(): fix docs to match code
Hi,
Quoted 9 lines · Junio C Hamano
It appears to me that Peff's "squash" is nullifying everything you did, so a more truthful attribution might be
From: Jeff King <[email protected]>
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 <[email protected]>
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.
--- path.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
path.c +3 -8
@@ -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
Signature · 1 line
2.1.4
Re: [PATCH v2] enter_repo(): fix docs to match code
In reply to Junio C HamanoQuoted 7 lines · Junio C Hamano
Quoted 7 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.
Quoted 8 lines
Quoted 5 lines
Documentation contributed by Jeff King.
Signed-off-by Jeff King <[email protected]>Signed-off-by Paul Tan <[email protected]>---
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
Re: [PATCH v2] enter_repo(): fix docs to match code
Quoted 2 lines · Jeff King
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.