summaryrefslogtreecommitdiffstats
path: root/bin/git/git-re-edit
diff options
context:
space:
mode:
Diffstat (limited to 'bin/git/git-re-edit')
-rwxr-xr-xbin/git/git-re-edit25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/git/git-re-edit b/bin/git/git-re-edit
new file mode 100755
index 0000000..7172acd
--- /dev/null
+++ b/bin/git/git-re-edit
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+#
+# Still fails when files may contain spaces
+#
+# Run the editor on all the files that have been modified from the
+# current index. Useful to resume work when you left the working tree
+# dirty. Useful following a "git reset HEAD^" to continue work on the
+# stuff you were working on before. Useful following a failed merge.
+#
+
+chomp(my @changed = qx{git status --porcelain});
+exit 1 unless $? == 0;
+s/^.. // or die "<$_>???\n" for @changed;
+die "Fucking shell, how does it work?\n"
+ if grep / /, @changed;
+
+@changed = qw(.) unless @changed;
+chomp(my @lines = qx{find @changed -type f });
+exit 1 unless $? == 0;
+
+# maybe should use output of "git var GIT_EDITOR" here?
+# But then I have to involve the !@&*!@*(&!@ shell
+my $ed = $ENV{VISUAL} || $ENV{EDITOR} || "emacs";
+exec $ed, @lines;
+die "exec $ed: $!\n";