Skip to content
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

fix bash completion for "git -C <path>" #198

Closed
wants to merge 1 commit into from
Closed

Conversation

hanyong
Copy link

@hanyong hanyong commented Feb 14, 2016

take care "-C" option from "__git_main",
fix "__git_dir" relative to "-C ".
make completion work for
"git -C xxx ", "git -C xxx checkout " and so on.

take care "-C" option from "__git_main",
fix "__git_dir" relative to "-C <path>".
make completion work for
"git -C xxx ", "git -C xxx checkout " and so on.
@dscho
Copy link
Member

dscho commented Jun 4, 2019

This is still a feature that Git lacks, so maybe I can ask you to rebase it and submit it to the Git mailing list for review?

One important thing before that, though, is that the reviewers on the Git mailing list are very picky about commit messages. So please allow me to try my hand at modifying the commit message in a way that I think will be accepted more readily:

completion: handle `git -C <path> --git-dir=<directory>` correctly

The combination of `-C` and `--git-dir` needs to be handled specially
when the latter specifies a relative path: Git would first change the
current working directory to the path indicated via `-C`, and the Git
directory would be relative to *that* directory.

One interesting quirk is that the `-C` option may come after
the `--git-dir` option, or that either option is passed multiple times.

Therefore, we must be careful to remember the values and to combine them
only after we saw all options.

Signed-off-by: 涧泉 <observer.hany@alibaba-inc.com>

You will notice a couple of things:

  • The commit message is wrapped at <=76 columns per line.
  • The first line is like a super-short summary, starting with the prefix "completion:".
  • The commit message explains why the __cwd variable is necessary, without actually talking about the actual implementation details.
  • Finally, there is a sign off (which is required by the Git project).

Feel free to use this commit message verbatim when rebasing.

After you rebased this to the current master, please send the patch to the mailing list for review. You can use GitGitGadget, submitGit or send it manually.

@hanyong
Copy link
Author

hanyong commented Jun 18, 2019

@dscho Thank you very much for educate me a lot about submit patches to Git.

After try to rebase the commit to current master, I found that -C and --git-dir already been take into account (for commit 80ac0744b180f815aca190059705c0aed80d16f9 ), so I will close this PR .

@hanyong hanyong closed this Jun 18, 2019
derrickstolee added a commit to derrickstolee/git that referenced this pull request Oct 24, 2019
…kout file on error

If the index has an unstaged change in a file that will be dropped
by a change to the sparse-checkout file, then the index update
will fail. If this happens during 'git sparse-checkout set', then
the entire command will fail. However, the sparse-checkout file is
still updated, so the working directory is in a half-finished state.

Update the sparse-checkout builtin to run `unpack_trees()`
directly instead of through an external `git read-tree` process.
While doing so, allow passing a set of patterns, so we can
validate the patterns before trying to write to the sparse-checkout
file.

Also, write sparse-checkout under a .lock and take the
sparse-checkout lock around the unpack_trees() check.

Resolves git#198.

Merging with admin privileges because mac builds are broken
due to external dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants