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 directory truncation inside .git dir #417

Merged
merged 2 commits into from
Nov 21, 2018

Conversation

segevfiner
Copy link
Contributor

Description

Apparently the behavior of git rev-parse --is-inside-work-tree is:

  1. If outside any git repo, exit with an error.
  2. If inside a git repo, print "true".
  3. If inside a git repo but outside the work tree (e.g. git dir), print "false".

(The first might actually be a bug...)

Fixes #388 (again)
Revert PR of the original fix which causes issues: #416

cc @salmanulfarzy

@matchai
Copy link

matchai commented Apr 9, 2018

Unfortunately, this doesn't help us identify where the root of a git directory is from within the .git folder: https://github.com/salmanulfarzy/spaceship-prompt/blob/master/sections/dir.zsh#L30

@segevfiner
Copy link
Contributor Author

Unfortunately, this doesn't help us identify where the root of a git directory is from within the .git folder: https://github.com/salmanulfarzy/spaceship-prompt/blob/master/sections/dir.zsh#L30

As noted in the description. This will make spaceship consider the .git directory as outside a Git repository so as to revert to normal truncation behavior which is better than a messed up prompt.

Copy link
Member

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue with submodules described on #412 still exists.

@segevfiner
Copy link
Contributor Author

Issue with submodules described on #412 still exists.

#416 should fix this. This fixes #388. Which the revert PR #416 will return.

@salmanulfarzy
Copy link
Member

Behaviour: Everything other than git repository directory paths are truncated to SPACESHIP_DIR_TRUNC.

dir trunc

Is this the intended behaviour @segevfiner ?

@segevfiner
Copy link
Contributor Author

segevfiner commented Apr 20, 2018 via email

Apparently the behavior of `git rev-parse --is-inside-work-tree` is:
1. If outside any git repo, exit with an error.
2. If inside a git repo, print "true".
3. If inside a git repo but outside the work tree (e.g. git dir),
   print "false".
(The first might actually be a bug...)

Fixes spaceship-prompt#388 (again)
Copy link
Member

@salmanulfarzy salmanulfarzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Manually tested and tests pass.

@salmanulfarzy salmanulfarzy added the improvement A PR that make small changes for improving UX, performance, readability, etc label Oct 18, 2018
Copy link
Member

@denysdovhan denysdovhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @salmanulfarzy, please, merge if needed.

P.S: Might be better to add a comment with reference to the issue.

@salmanulfarzy salmanulfarzy merged commit b7e5654 into spaceship-prompt:master Nov 21, 2018
@segevfiner segevfiner deleted the git-dir-truncation branch November 21, 2018 10:05
salmanulfarzy added a commit to salmanulfarzy/spaceship-prompt that referenced this pull request Nov 23, 2018
* origin/4.0: (44 commits)
  3.8.0
  Support multiple files for COMPOSE_FILE in docker (spaceship-prompt#395)
  Add Terraform Workspace section (spaceship-prompt#542)
  Document kubecontext showing namepace (spaceship-prompt#566)
  Use Zsh field splitting instead of awk (spaceship-prompt#544)
  Add namespace to k8s section (spaceship-prompt#565)
  3.7.2
  Document go.mod detection in golang section
  Improve package version detection using jq, python and node (spaceship-prompt#441)
  Truncate .git directory and childs like normal directories (spaceship-prompt#417)
  Add option to toggle verbose rust version (spaceship-prompt#521)
  Change font suggestion: Fira Mono → Fira Code
  Support go.mod files and fix GOPATH matching (spaceship-prompt#559)
  Hide PR template guidance behind comments (spaceship-prompt#556)
  Document pyproject.toml in pyenv section (spaceship-prompt#551)
  3.7.1
  Recognize pyproject.toml when showing pyenv section (spaceship-prompt#550)
  Fix orderd list count on CONTRIBUTING page (spaceship-prompt#548)
  Add image in doc for powerline dir lock symbol (spaceship-prompt#517)
  Remove argument from char test shebang (spaceship-prompt#533)
  ...
dedene pushed a commit to zenjoy/spaceship-prompt that referenced this pull request Feb 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement A PR that make small changes for improving UX, performance, readability, etc
Development

Successfully merging this pull request may close these issues.

dir section for .git folders
4 participants