move git-bre into a real command with better filename safety

Tue, 21 Jun 2016 15:14:34 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 21 Jun 2016 15:14:34 -0400
changeset 338
296f4b036ae3
parent 337
1aed142faa16
child 339
a2f7e73ea74b

move git-bre into a real command with better filename safety

.gitconfig file | annotate | diff | comparison | revisions
bin/git-bre file | annotate | diff | comparison | revisions
--- a/.gitconfig
+++ b/.gitconfig
@@ -31,7 +31,6 @@
 	ctags   = "!~/.git_helpers/ctags"
 	glog    = log --graph --pretty=onelinecustom
 	recent  = !sh -c 'git for-each-ref --count=${1:-20} --sort=-committerdate --format=\"%(committerdate:short) %(refname:short)\"' "$@"
-	bre     = !$EDITOR $@ $(git diff --name-only @{u}..)
 
 [pretty]
 	onelinecustom = tformat:%C(magenta)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr)%Creset %C(cyan)<%an>%Creset
new file mode 100755
--- /dev/null
+++ b/bin/git-bre
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -eu
+
+# git-bre:  "branch edit", run $EDITOR with a list of all files touched in this
+# branch compared to upstream.  Any args are passed to the editor, before the
+# file list.
+
+CHANGED=$(
+  git diff --name-only @{u}.. | while read file
+  do
+    echo \'$file\'
+  done
+)
+
+eval "exec $EDITOR $@ ${CHANGED:?[No files to edit]}"

mercurial