From a4cf629c2f7d7daf57991ed808ee32f5ad13c09d Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 21 May 2012 17:25:07 -0400 Subject: [PATCH] Refactor the listing of lost Git commits --- modules/git/alias.zsh | 2 +- modules/git/functions/git-commit-lost | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 modules/git/functions/git-commit-lost diff --git a/modules/git/alias.zsh b/modules/git/alias.zsh index 62db3831..f677dc13 100644 --- a/modules/git/alias.zsh +++ b/modules/git/alias.zsh @@ -32,7 +32,7 @@ alias gcP='git cherry-pick --no-commit' alias gcr='git revert' alias gcR='git reset "HEAD^"' alias gcs='git show' -alias gcv='git fsck | awk '\''/dangling commit/ {print $3}'\'' | git show --format="SHA1: %C(green)%h%C(reset) %f" --stdin | awk '\''/SHA1/ {sub("SHA1: ", ""); print}'\''' +alias gcl='git-commit-lost' # Data (d) alias gd='git ls-files' diff --git a/modules/git/functions/git-commit-lost b/modules/git/functions/git-commit-lost new file mode 100644 index 00000000..ed9b0766 --- /dev/null +++ b/modules/git/functions/git-commit-lost @@ -0,0 +1,16 @@ +# +# Lists lost Git commits. +# +# Authors: +# Sorin Ionescu +# + +git fsck 2> /dev/null \ + | grep "^dangling commit" \ + | awk '{print $3}' \ + | git log \ + --date-order \ + --no-walk \ + --stdin \ + ${git_log_format_oneline} +