git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org
Subject: [PATCH] git-fixup: automatically create a fixup commit
Date: Sun, 1 May 2016 12:53:34 +0300	[thread overview]
Message-ID: <1462096410-8813-1-git-send-email-mst@redhat.com> (raw)

Sometimes I get a broken patch, apply it and then need to fix it up. git
commit --fixup is perfect for this, but makes me look up the commit that
created the breakage manually. git-fixup is a tool to speed this up.
Several heuristics would be reasonable for locating the problematic
commit:
1. look up the last commit that touched the
   file(s) affected by the fixup
2. look up the last commit that touched the
   line(s) affected by the fixup

this implements the first heuristic.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 contrib/git-fixup | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100755 contrib/git-fixup

diff --git a/contrib/git-fixup b/contrib/git-fixup
new file mode 100755
index 0000000..79f4e34
--- /dev/null
+++ b/contrib/git-fixup
@@ -0,0 +1,8 @@
+if
+	git diff --cached --quiet 
+then
+	echo "Nothing to commit!"
+	exit 1
+else
+	git commit --fixup=$(git log --pretty=format:%H -1 $(git diff --cached --name-only)) "$@"
+fi
-- 
MST

                 reply	other threads:[~2016-05-01  9:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462096410-8813-1-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).