Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ If you aren't using any ZSH frameworks, or if you're a `bash` user, do the follo
| `git-what-the-hell-just-happened` | Gary Bernhardt's [dotfiles](https://github.com/garybernhardt/dotfiles/blob/master/bin/git-what-the-hell-just-happened) | Show what just happened. |
| `git-when-merged` | Michael Haggerty [git-when-merged](https://github.com/mhagger/git-when-merged) | Find when a commit was merged into one or more branches. |
| `git-where` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Shows where a particular commit falls between releases. |
| `git-whoami` | Peter Eisentraut | Shows what username & email you have configured for the repo you're in |
| `git-winner` | Garry Dolley [https://github.com/up_the_irons/git-winner](https://github.com/up_the_irons/git-winner) | Shows what authors have made the most commits, both by number of commits and by number of lines changed. |
| `git-wtf` | William Morgan <wmorgan-git-wt-add@masanjin.net> | `git-wtf` displays the state of your repository in a readable, easy-to-scan format. It's useful for getting a summary of how a branch relates to a remote server, and for wrangling many topic branches. |
| `github-open` | Ryan Tomayko's [dotfiles](http://github.com/rtomayko/dotfiles) | |
Expand Down
33 changes: 33 additions & 0 deletions bin/git-whoami
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

# git-whoami
# Author: Peter Eisentraut <peter@eisentraut.org>
# Created: 2011-10-27
# License: WTFPL; see http://sam.zoy.org/wtfpl/

# exact logic in ident.c in git source tree

set -e

get_email() {
git config user.email || ( [ -n "$EMAIL" ] && echo "$EMAIL" ) || echo "$(id -nu)@$(hostname --fqdn)"
}

get_name() {
git config user.name || getent passwd "$(id -un)" | cut -d : -f 5 | cut -d , -f 1
}

: ${GIT_AUTHOR_NAME="$(get_name)"}

Choose a reason for hiding this comment

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

Double quote to prevent globbing and word splitting.

: ${GIT_COMMITTER_NAME="$(get_name)"}

Choose a reason for hiding this comment

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

Double quote to prevent globbing and word splitting.

: ${GIT_AUTHOR_EMAIL="$(get_email)"}

Choose a reason for hiding this comment

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

Double quote to prevent globbing and word splitting.

: ${GIT_COMMITTER_EMAIL="$(get_email)"}

Choose a reason for hiding this comment

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

Double quote to prevent globbing and word splitting.


author="$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
commit="$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"

if [ "$author" = "$commit" ]; then
echo "$author"
else
echo "Author: $author"
echo "Commit: $commit"
fi