Skip to content

Instantly share code, notes, and snippets.

@daragh
Last active December 17, 2015 06:28
Show Gist options
  • Save daragh/5565623 to your computer and use it in GitHub Desktop.
Save daragh/5565623 to your computer and use it in GitHub Desktop.
A bash script to show the commit that git is trying to apply a patch for in a rebase/apply.
#!/bin/bash
set -e
git_dir=$(git rev-parse --git-dir)
rebase_dir=$git_dir/rebase-apply
if [ ! -d $rebase_dir ]
then
echo 'rebase/apply not in progress' >&2
exit 1
fi
patch_number=$(cat $rebase_dir/next)
padded_patch_number=$(printf %04d $patch_number)
commit_id=$(head -n 1 $rebase_dir/$padded_patch_number | cut -d ' ' -f 2)
git show $commit_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment