5 # Copyright (c) 2014 Jonas Fonseca <jonas.fonseca@gmail.com>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
18 if [ -n "${BASH_VERSION:-}" ]; then
23 author_date
=1234567890
24 author_date_delta
=735730
26 IDENT_A
="A. U. Thor <a.u.thor@example.com>"
27 IDENT_B
="René Lévesque <rene.levesque@example.qc.ca>"
28 IDENT_C
="作者 <zuozhea@example.ch>"
29 IDENT_D
="Jørgen Thygesen Brahe <brache@example.dk>"
30 IDENT_E
="Max Power <power123@example.org>"
34 (cd "$work_dir" && $@
)
39 git config
--local user.name
"Committer"
40 git config
--local user.email
"c.ommitter@example.net"
47 if [ ! -d "$dir/.git" ]; then
49 (cd "$dir" && git_config
)
55 [ -d .git
] || die
"git_add called outside of git repo"
58 mkdir
-p "$(dirname "$path")"
65 [ -d .git
] || die
"git_commit called outside of git repo"
67 GIT_COMMITTER_NAME
="$0"
68 GIT_COMMITTER_EMAIL
="$0"
70 export GIT_AUTHOR_DATE
="$author_date"
71 author_date
="$(expr $author_date + $author_date_delta)"
72 [ -z "${GIT_COMMITTER_DATE:-}" ] &&
73 export GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
75 git commit
-q --allow-empty "$@"
76 unset GIT_COMMITTER_DATE
79 create_dirty_workdir
()
84 echo "*.o" > .gitignore
85 echo "*~" > .git
/info
/exclude
87 for file in a b.c
"d~" e
/f
"g h" i.o .j
"h~/k"; do
88 dir
="$(dirname "$file")"
89 [ -n "$dir" ] && mkdir
-p "$dir"
90 printf "%s\n%s" "$file" "$(seq 1 10)" > "$file"
94 git_commit
--author="$IDENT_A" --message="Initial commit"
96 for file in a b.c
"d~" e
/f
"g h" i.o .j
"h~/k"; do
97 printf "%s\n%s" "$file CHANGED" "$(seq 1 8)" > "$file"
106 for i
in $
(seq 1 10); do
107 git_commit
--author="$IDENT_A" --message="Commit $i A"
108 git_commit
--author="$IDENT_B" --message="Commit $i B"
109 git_commit
--author="$IDENT_C" --message="Commit $i C"
110 git_commit
--author="$IDENT_D" --message="Commit $i D"
111 git_commit
--author="$IDENT_E" --message="Commit $i E"
115 git remote add
$remote http
://example.org
/repo.git
116 mkdir
-p .git
/refs
/remotes
/$remote
117 echo 5633519083f21695dda4fe1f546272abb80668cd
> .git
/refs
/remotes
/$remote/master
119 tagged
=957f2b368e6fa5c0757f36b1441e32729ee5e9c7
126 repo_name
="$(basename "$1")"
129 git submodule foreach git checkout master
130 git submodule foreach git pull
136 repo
="$(basename "$repo")"
137 repos
="$repos$repos_sep$repo"
140 summary
="$(git submodule summary "$repo")"
141 revspec
="$(git diff --submodule=log "$repo" | sed -n '/Submodule/,1 s/Submodule [^ ]* \([^:]*\):/\1/p')"
142 diffstat
="$(cd "$repo" && git diff --stat "$revspec")"
151 git_commit
--author="$IDENT_A" --message="[$repo_name] Integrate feature from $repos"
156 repo_name
="$(basename "$1")"
160 mkdir
-p "$(dirname "$file")"
161 echo "$file" >> "$file"
164 git_commit
--author="$IDENT_A" --message="[$repo_name] Commit $(git rev-list HEAD 2> /dev/null | wc -l | sed 's/ *//')"
169 repo_name
="$(basename "$1")"
174 git submodule add
"../../git-repos/$(basename "$repo")"
177 git_commit
--author="$IDENT_A" --message="[$repo_name] Creating repository"
187 for repo
in "$repo_main" "$repo_a" "$repo_b" "$repo_c"; do
190 submodule_commit
"$repo" Makefile
191 submodule_commit
"$repo" include
/api.h
192 submodule_commit
"$repo" src
/impl.c
195 submodule_create
"$repo_main" "$repo_a" "$repo_b" "$repo_c"
197 submodule_commit
"$repo_a" include
/api.h
198 submodule_commit
"$repo_a" src
/impl.c
200 submodule_commit
"$repo_c" README
201 submodule_commit
"$repo_c" INSTALL
203 submodule_pull
"$repo_main" "$repo_a" "$repo_c"
205 submodule_commit
"$repo_b" README
206 submodule_commit
"$repo_b" Makefile
208 submodule_pull
"$repo_main" "$repo_b"
210 submodule_commit
"$repo_a" README
211 submodule_commit
"$repo_c" src
/impl.c
212 submodule_commit
"$repo_b" include
/api.h
214 submodule_pull
"$repo_main" "$repo_a" "$repo_b" "$repo_c"
219 if [ ! -d "$1" ]; then
220 case "$(basename "$1")" in
221 repo-one
) create_repo_one
"$1" ;;
222 repo-two
) (create_repo_two
"$1") ;;
223 *) die
"No generator for $(basname "$1")" ;;
228 create_repo_from_tgz
()
237 create_repo
"$tmp_dir/git-repos/$1"
239 clone_dir
="${2:-$work_dir}"
240 git clone
-q "$tmp_dir/git-repos/$1" "$clone_dir"
241 (cd "$clone_dir" && git_config
)