3 # Copyright (c) Josef "Jeff" Sipek, 2006
6 function find_git_dir_nice
8 git-rev-parse
--git-dir
15 [ $?
-ne 0 -o -z "$d" ] && exit 1
22 git-symbolic-ref HEAD |
sed -e 's,^refs/heads/,,'
25 function get_branch_verify
29 [ ! -d "$GIT_DIR/patches/$b" ] && echo "Branch $b is not initialized, try gq-init" >&2 && exit 1
30 [ ! -f "$GIT_DIR/patches/$b/series" ] && echo "Branch $b does not have a series file" >&2 && exit 1
31 [ ! -f "$GIT_DIR/patches/$b/status" ] && echo "Branch $b does not have a status file" >&2 && exit 1
32 [ -f "$GIT_DIR/patches/$b/applied" ] && echo "Warning: Branch $b has 'applied' file - gq is not compatible with stgit" >&2
39 tail -1 $GQ_DIR/$branch/status
44 n
=`wc -l < $GQ_DIR/$branch/status`
48 for p
in `cat $GQ_DIR/$branch/status`; do
50 [ $idx -lt $n ] && continue
51 [ $idx -gt $n ] && break
57 function index_update_magic
60 fil
=`echo $l | cut -d: -f 2`
61 git-update-index
--add --remove "$fil"
65 # usage: do_get_header patchfile
66 function do_get_header
68 cat $1 |
awk 'BEGIN{ok=1}/^(diff|---)/{ok=0}{if (ok==1) print $0}'
71 # usage: push_patch patchname
74 local p
="$GQ_DIR/$branch/$1"
80 ( git-apply
--numstat $p |
awk '{print "changed:" $3}';
81 #git-apply --summary $p | awk '
82 # /^ (create|delete)/{print $1 ":" $4}
83 # /^ mode change/{print "mode:" $6}'
86 # grab a commit message out of the patch
87 do_get_header
$p > /tmp
/gq.msg.$$
89 # make a default commit message if patch doesn't contain one
90 [ ! -s /tmp
/gq.msg.$$
] && echo "patch $pname" > /tmp
/gq.msg.$$
93 local treeish
=`git-write-tree`
94 local commitish
=`git-commit-tree $treeish -p HEAD < /tmp/gq.msg.$$`
95 echo $commitish > $GIT_DIR/`git-symbolic-ref HEAD`
102 function must_commit_first
104 [ `git-diff-files | wc -l` -eq 0 ]