I am trying to export multiple commits (those that contain a specific ticket number 1234 in a commit message) to fix the files.
EDIT Working script is located at https://github.com/amenk/SelfScripts/blob/master/git-extract-patches
This is what I have
#!/bin/bash -x commits=`git log --pretty=oneline | grep "#1234" | cut -f1 -d" "` no=1; for COMMIT in $commits do git format-patch -1 $COMMIT --start-number=$no no=$(($no+1)) done
But for some reason, git format-patch execution fails:
$ ./getpatches.sh ++ git log --pretty=oneline ++ grep '#6809' ++ cut -f1 '-d ' + commits='da591d66f05513488ee06857edc9d24a046c179d 4fd781da9cc503b961f8e4c42bbb136d9e3c1806 3a9311f5507f91f830b44673c57f672e7aabaac0' + no=1 + for COMMIT in '$commits' + git format-patch -1 'da591d66f05513488ee06857edc9d24a046c179d' --start-number=1 fatal: ambiguous argument 'da591d66f05513488ee06857edc9d24a046c179d': unknown revision or path not in the working tree. Use '--' to separate paths from revisions
When I call git format-patch -1 'da591d66f05513488ee06857edc9d24a046c179d' --start-number=1
manually, everything is fine.
EDIT:
I think this is something with quotes. If I add git log | grep $COMMIT
git log | grep $COMMIT
in a loop, I get the following error:
+ grep '992ab41d3539539bd609209beed33a9de2f4277a' grep: Unmatched [ or [^
Another effect of interworking is that if I hard code grep '992ab41d3539539bd609209beed33a9de2f4277a'
in a for loop, the output of the command (because of the -x
option for bash
does not contain quotes, and it works.
+ grep 992ab41d3539539bd609209beed33a9de2f4277a
Where do these quotes come from and how can I get rid of them?
source share