Skip to contentSkip to conversation

git-fixup: automatically create a fixup commit

PATCH New Michael S. Tsirkin 1 participant 1 message Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-fixup: automatically create a fixup commit

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.

---
 contrib/git-fixup | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100755 contrib/git-fixup
contrib/git-fixup new file +8 -0
new file mode 100755
index 0000000..79f4e34
@@ -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
Signature · 1 line
MST