Skip to content

Instantly share code, notes, and snippets.

@nobeans
Forked from toshi-kawanishi/git-now
Created March 20, 2011 02:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nobeans/878015 to your computer and use it in GitHub Desktop.
Save nobeans/878015 to your computer and use it in GitHub Desktop.
nnoremap <Space>gn :<C-u>w<CR>:Git now<CR>
nnoremap <Space>gN :<C-u>w<CR>:Git now --all<CR>
#!/bin/sh
PREFIX="from now"
MESSAGE="[${PREFIX}] `date +\"%Y/%m/%d %T\"`"
if [ $# -eq 0 ]
then
git add -u
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
elif [ $1 != "--rebase" ]
then
if [ $1 != "--all" ]
then
git add $@
else
git add -u
git add .
fi
printf "${MESSAGE}\n\n%s" "`git diff --cached`" | git commit -F -
else
FIRST_NOW_COMMIT=`git log --pretty=oneline --grep="${PREFIX}" | tail -n 1 | cut -d " " -f 1`
INITIAL_COMMIT=`git log --pretty=oneline | tail -n 1 | cut -d " " -f 1`
if [ ${FIRST_NOW_COMMIT} != ${INITIAL_COMMIT} ]
then
git rebase -i ${FIRST_NOW_COMMIT}^
else
WORKING_BRANCH=`git branch -l | grep "*" | cut -d " " -f 2`
git checkout ${FIRST_NOW_COMMIT}
git commit --amend
git rebase --onto HEAD ${FIRST_NOW_COMMIT} ${WORKING_BRANCH}
fi
fi
;;; git-now.el - Call "git now" command
(provide 'git-now)
(defun now ()
(interactive)
(call-process "git" nil "*git now*" nil "now")
(pop-to-buffer "*git now*" t nil)
(other-window -1)
(message "git now!"))
require 'formula'
class GitNow < GithubGistFormula
url 'https://raw.github.com/gist/878015/8a7158b2bfce40415b3a0394afd45c442addfe06/git-now'
md5 '144c3759343e59187dffd8a7c4cf61a2'
homepage 'https://gist.github.com/878015/'
end
#!/bin/sh
PREFIX="from now"
if [ ! "`git log --pretty=oneline $3 | head -n 1 | grep "${PREFIX}"`" ]
then
exit 0
else
echo "error: There are tmp log messages in the received objects." 1>&2
echo "error: Change these messages by 'git now --rebase'." 1>&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment