Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

.bash_prompt: better git functions #143

Merged
merged 0 commits into from Nov 24, 2012

Conversation

Projects
None yet
4 participants
Contributor

eins78 commented Sep 14, 2012

We don't have to parse/sed/grep/etc the output, git has commands for almost everything one wants to do.
Also, it uses less calls overall (especially when pwd is not a git repo, it uses just 1 call to git)

Contributor

eins78 commented Sep 14, 2012

oops, i messed up the actual prompt. i will look into it in the morning or maybe someone spots the error in the meantime.

Owner

mathiasbynens commented Sep 16, 2012

Looking forward to pulling this in :)

Contributor

necolas commented Oct 27, 2012

These should use plumbing commands like diff-index, diff-files, symbolic-ref, etc. AFAIK, git's porcelain commands aren't recommended for scripting. You can get the same info from the low-level plumbing commands. Although I've noticed that diff-index is problematic for repos without an initial commit to compare against. In the end, I've been looking at how git-prompt.sh does things.

I think the command being used to extract a branch name in this PR is going to throw an error on new repos.

And I think you can drop --exit-code because --quiet implies --exit-code according to the docs. Works for me.

Contributor

eins78 commented Oct 28, 2012

You are right, I was under the wrong impression that parse-rev is plumbing (shure felt like it).
I found a good start to do it "right" on SO which might be helpful if someone wants to fix this before I find the time.

This would be good. Took me a while to figure out why all of a sudden all my repos where showing as "dirty". The reason was pretty stupid haha:

As of git 1.8.0, the "nothing to commit" message is:

nothing to commit, working directory clean

Versus the preview message for git 1.7.*:

nothing to commit (working directory clean)

Which broke the parse_git_dirty in .bash_prompt. I switched the messages in mine, but was wondering what was the status of this pull request?

Cheers

Owner

mathiasbynens commented Nov 23, 2012

I guess @eins78 hasn’t had time to improve this pull request yet.

I’ll tweak parse_git_dirty for now to make it work with Git 1.8.0+. Thanks for the suggestion, @nicolahery!

Contributor

eins78 commented Nov 23, 2012

Yes, I did not have time. Ironically i started working on this exactly beause of the grep, in case the text changes...

No problem, glad I could be of any help :)

Thank you for these dotfiles, they really improved my development experience on my Mac!

Cheers

Contributor

eins78 commented Nov 23, 2012

@necolas nice! I am pulling and cleaning up right now, so maybe this PR can have a happy ending soon ;)

@eins78 eins78 merged commit b96cd30 into mathiasbynens:master Nov 24, 2012

Contributor

eins78 commented Nov 24, 2012

funny.

It seems I hit a github bug, since it was not merged yet…

Anyhow, I integrated the changes in the same branch, but it is not shown since it was 'closed' before I pushed it.

mathiasbynens added a commit that referenced this pull request Nov 24, 2012

.bash_prompt: Fix `parse_git_dirty` for Git v1.8.0+
Git 1.8.0+ says “nothing to commit (working directory clean)”.
Older Git versions return “nothing to commit (working directory clean)”.

Thanks to @nicolahery in #143 for the suggestion.

lwille added a commit to lwille/dotfiles that referenced this pull request Feb 5, 2013

.bash_prompt: Fix `parse_git_dirty` for Git v1.8.0+
Git 1.8.0+ says “nothing to commit (working directory clean)”.
Older Git versions return “nothing to commit (working directory clean)”.

Thanks to @nicolahery in #143 for the suggestion.

Conflicts:
	.bash_prompt

thorsten pushed a commit to thorsten/dotfiles that referenced this pull request Dec 12, 2014

.bash_prompt: Fix `parse_git_dirty` for Git v1.8.0+
Git 1.8.0+ says “nothing to commit (working directory clean)”.
Older Git versions return “nothing to commit (working directory clean)”.

Thanks to @nicolahery in #143 for the suggestion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment