Allow to change directory from the next argument#1079
Closed
deeagle001 wants to merge 1 commit intojonas:masterfrom
Closed
Allow to change directory from the next argument#1079deeagle001 wants to merge 1 commit intojonas:masterfrom
deeagle001 wants to merge 1 commit intojonas:masterfrom
Conversation
Collaborator
|
To be honest, if I had to name one contribution I wished I didn't do it would probably be diff --git a/src/tig.c b/src/tig.c
index ed4388f..f02566a 100644
--- a/src/tig.c
+++ b/src/tig.c
@@ -389,7 +389,7 @@ static const char usage_string[] =
" +<number> Select line <number> in the first view\n"
" -v, --version Show version and exit\n"
" -h, --help Show help message and exit\n"
-" -C<path> Start in <path>";
+" -C <path> Start in <path>";
void
usage(const char *message)
@@ -489,9 +489,10 @@ parse_options(int argc, const char *argv[], bool pager_mode)
/* Options that must come before any subcommand. */
for (i = 1; i < argc; i++) {
const char *opt = argv[i];
- if (!strncmp(opt, "-C", 2)) {
- if (chdir(opt + 2))
- die("Failed to change directory to %s", opt + 2);
+ if (!strcmp(opt, "-C") && i + 1 < argc && *argv[i + 1] != '-') {
+ const char *dir = argv[++i];
+ if (chdir(dir))
+ die("Failed to change directory to %s", dir);
continue;
} else {
break;That would allow the |
Contributor
|
Yeah, the earlier we change this, the better. With |
koutcher
pushed a commit
that referenced
this pull request
Feb 10, 2021
This introduces an incompatibility with previous versions. Replace the syntax `tig -C/path/to/repo` with `tig -C /path/to/repo` to be consistent with Git and allow the use of `tig -C` to detect copies. [tk: tweak patch and commit message]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The -C change directory option only accepts dir within the same argv argument. The git tool allows this value to be in the next argument. This PR allows providing the change directory as the next argument after -C.