#!/usr/bin/perl -w use strict; use Scriptalicious; getopt(); my $commit = `git cat-file commit HEAD`; my ($branch) = map { s{^\*\s*}{}; chomp; $_ } grep m{^\*}, `git branch`; mutter "current branch is : $branch"; my $tmp = ".tmp_commit_$$"; open X, ">$tmp"; print X $commit; close X; my $revised; if ( -t STDIN ) { my $EDITOR = "$ENV{EDITOR}" || $ENV{VISUAL} || "vi"; system("$EDITOR", $tmp); $revised = `cat $tmp`; } else { local($/); $revised = ; open X, ">$tmp"; print X $revised; close X; } if ($revised eq $commit) { say "no change"; exit(0); } my $commit_id = capture(-in => $tmp, qw(git hash-object -w -t commit --stdin)); mutter "commit ID is $commit_id"; run("git update-ref", "refs/heads/$branch", $commit_id); unlink($tmp, "$tmp~");