-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[docs] [refactor] Add help messages for datadir path mangling #12305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Not just this one, all relative files and directories specified either on the command line or through RPC are supposed to be relative to the data directory. |
|
OT: Wasn't walletdir temporarily allowed to be relative to the cwd? |
|
Sounds like we don't have any documentation indicating that all path arguments are relative to datadir; that information should live somewhere (preferably in a single place that isn't easy to miss). One option is to put it in a paragraph between "Usage" and "Options" in |
|
Options that take paths or file names are:
So, adding a general paragraph only makes sense if it holds true for all paths. Otherwise, I'd prefer if each command line help was clarified individually. |
e250904 to
8e1cf5b
Compare
|
@MarcoFalke thanks for that list. I've looked at how each option on the list is parsed (as well as a few others):
So: each of these options is either not allowed to be relative or is put under datadir if relative with the exception of I've also added a refactoring commit which consolidates the "normalization" of relative paths under datadir. |
754baf5 to
d04ffdb
Compare
d04ffdb to
d76f43c
Compare
|
Thanks, utACK |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
src/util.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rename to GetAbsolutePath or more specific GetAbsoluteDataPath:
fs::path GetAbsoluteDataPath(const fs::path& path, bool net_specific)I other contexts/languages, normalization can be interpreted as transforming from foo/../bar/ to bar.
Nit, snake_case arguments.
src/wallet/init.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, unrelated change, remove.
d76f43c to
23d295a
Compare
|
Thanks for the feedback @promag. It's been incorporated and pushed. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 23d295aa9e16cb3591bbd8bb0f5ce026b861b7b6
src/util.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be a little better to return: return fs::absolute(path, GetDataDir(net_specific)) to make it clear this returns an absolute path. You could also drop the is_complete check above if you did this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks.
src/util.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could eliminate this check, but if you will keep it developer notes suggest adding braces or putting if body on same line as condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking your advice below, but the reminder about convention is appreciated.
src/util.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ForArg" in function name seems a little redundant. Just a suggestion, but I might call it something GetDataPath or GetDataDirPath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only reservation here is that the path won't necessarily be in datadir, so a name with Data or DataDir seems confusing. "Arg" here is meant to correspond to an argument to the binary, not the function, but maybe that isn't clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try AbsPathForConfigVal.
23d295a to
fdf0c7d
Compare
|
Thanks for the good feedback, @ryanofsky. Incorporated and pushed. |
|
Could update the commit title to match the renamed function :) |
fdf0c7d to
95963c1
Compare
|
d'oh. Thanks, @ajtowns. Pushed. |
|
Looks good. Minor note that |
|
utACK 95963c120c48ce750fdb2298f3eb70034e578e8d, but needs rebase. |
Change `-conf`'s and others' help messages to indicate that relative path values will be prefixed by the datadir path. This behavior is confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but loading the `bitcoin.conf` file in ~/.bitcoin datadir.
Most commandline/config args are interpreted as relative to datadir if not passed absolute. Consolidate the logic for this normalization.
95963c1 to
5460460
Compare
|
Rebased and incorporated @jnewbery's feedback. |
| * | ||
| * @param path The path to be conditionally prefixed with datadir. | ||
| * @param net_specific Forwarded to GetDataDir(). | ||
| * @return The normalized path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The absolute path?
|
utACK 5460460 |
…ngling 5460460 Add AbsPathForConfigVal to consolidate datadir prefixing for path args (James O'Beirne) a1e1305 Clarify help messages for path args to mention datadir prefix (James O'Beirne) Pull request description: Change `-conf`'s help message to indicate that relative path values will be prefixed by the datadir path. This behavior probably merits clarification; it's kind of confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but instead loading the `bitcoin.conf` file in ~/.bitcoin datadir. ### Edit This PR has been modified to document all cases where relative path configurations are modified to be under datadir. A small refactoring has also been added which consolidates this normalization. Tree-SHA512: be4fc0595fbeba33d17af08f59898af45e76a44f00719ea0282403b155ac6755584604fab765250a3aa14ed6991882c4d1ccbe601184362c5ba97c886bdda344
|
Post-merge utACK 5460460 |
…ngling Summary: 5460460 Add AbsPathForConfigVal to consolidate datadir prefixing for path args (James O'Beirne) a1e1305 Clarify help messages for path args to mention datadir prefix (James O'Beirne) Pull request description: Change `-conf`'s help message to indicate that relative path values will be prefixed by the datadir path. This behavior probably merits clarification; it's kind of confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but instead loading the `bitcoin.conf` file in ~/.bitcoin datadir. ### Edit This PR has been modified to document all cases where relative path configurations are modified to be under datadir. A small refactoring has also been added which consolidates this normalization. Tree-SHA512: be4fc0595fbeba33d17af08f59898af45e76a44f00719ea0282403b155ac6755584604fab765250a3aa14ed6991882c4d1ccbe601184362c5ba97c886bdda344 Backport of Core PR12305 bitcoin/bitcoin#12305 Depends on D3940 Test Plan: make check ./bitcoind -h Verify help messages have been changed. ./bitcoind Verify debug.log, bitcoin.conf, bitcoind.pid, and cookie files exist in their default directories (Likely somewhere in .bitcoin). ./bitcoind -debuglogfile=<absolute path>/debug.log Verify the same debug.log was touched by this instance of `./bitcoind`. ./bitcoind -debuglogfile=<relative path>/debug.log Verify the same debug.log was touched by this instance of `./bitcoind`. Repeat for other files. Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc Differential Revision: https://reviews.bitcoinabc.org/D3939
…path mangling 5460460 Add AbsPathForConfigVal to consolidate datadir prefixing for path args (James O'Beirne) a1e1305 Clarify help messages for path args to mention datadir prefix (James O'Beirne) Pull request description: Change `-conf`'s help message to indicate that relative path values will be prefixed by the datadir path. This behavior probably merits clarification; it's kind of confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but instead loading the `bitcoin.conf` file in ~/.bitcoin datadir. ### Edit This PR has been modified to document all cases where relative path configurations are modified to be under datadir. A small refactoring has also been added which consolidates this normalization. Tree-SHA512: be4fc0595fbeba33d17af08f59898af45e76a44f00719ea0282403b155ac6755584604fab765250a3aa14ed6991882c4d1ccbe601184362c5ba97c886bdda344
…path mangling 5460460 Add AbsPathForConfigVal to consolidate datadir prefixing for path args (James O'Beirne) a1e1305 Clarify help messages for path args to mention datadir prefix (James O'Beirne) Pull request description: Change `-conf`'s help message to indicate that relative path values will be prefixed by the datadir path. This behavior probably merits clarification; it's kind of confusing when attempting to specify a configuration file in the current directory with `-conf=bitcoin.conf`, but instead loading the `bitcoin.conf` file in ~/.bitcoin datadir. ### Edit This PR has been modified to document all cases where relative path configurations are modified to be under datadir. A small refactoring has also been added which consolidates this normalization. Tree-SHA512: be4fc0595fbeba33d17af08f59898af45e76a44f00719ea0282403b155ac6755584604fab765250a3aa14ed6991882c4d1ccbe601184362c5ba97c886bdda344
Change
-conf's help message to indicate that relative path values will be prefixed by the datadir path. This behavior probably merits clarification; it's kind of confusing when attempting to specify a configuration file in the current directory with-conf=bitcoin.conf, but instead loading thebitcoin.conffile in ~/.bitcoin datadir.Edit
This PR has been modified to document all cases where relative path configurations are modified to be under datadir. A small refactoring has also been added which consolidates this normalization.