debug messages are off by default; use -d to enable.
Instead of debug messages, we print a progress counter to stderr.
Avery Pennarun committed
Apr 26, 2009 at 18:06 UTC
942dce5578c8eb03fdc7f9109c8418d499e931ff
1 file changed
+18
-2
git-subtree.sh
+18
-2
@@ -15,6 +15,7 @@ git subtree pull --prefix=<prefix> <repository> <refspec...>
15
--
16
h,help show the help
17
q quiet
18
+d show debug messages
19
prefix= the name of the subdir to split out
20
options for 'split'
21
annotate= add a prefix to commit message of new commits
@@ -27,6 +28,7 @@ eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
28
require_work_tree
29
30
quiet=
31
+debug=
32
command=
33
onto=
34
rejoin=
@@ -34,6 +36,13 @@ ignore_joins=
36
annotate=
37
38
debug()
39
+{
40
+ if [ -n "$debug" ]; then
41
+ echo "$@" >&2
42
+ fi
43
+}
44
+
45
+say()
46
{
47
if [ -z "$quiet" ]; then
48
echo "$@" >&2
@@ -57,6 +66,7 @@ while [ $# -gt 0 ]; do
66
shift
67
case "$opt" in
68
-q) quiet=1 ;;
69
+ -d) debug=1 ;;
70
--annotate) annotate="$1"; shift ;;
71
--no-annotate) annotate= ;;
72
--prefix) prefix="$1"; shift ;;
@@ -357,15 +367,21 @@ cmd_split()
367
# We can't restrict rev-list to only $dir here, because some of our
368
# parents have the $dir contents the root, and those won't match.
369
# (and rev-list --follow doesn't seem to solve this)
360
- git rev-list --reverse --parents $revs $unrevs |
370
+ grl='git rev-list --reverse --parents $revs $unrevs'
371
+ revmax=$(eval "$grl" | wc -l)
372
+ revcount=0
373
+ createcount=0
374
+ eval "$grl" |
375
while read rev parents; do
362
- debug
376
+ revcount=$(($revcount + 1))
377
+ say -n "$revcount/$revmax ($createcount)
"
378
debug "Processing commit: $rev"
379
exists=$(cache_get $rev)
380
if [ -n "$exists" ]; then
381
debug " prior: $exists"
382
continue
383
fi
384
+ createcount=$(($createcount + 1))
385
debug " parents: $parents"
386
newparents=$(cache_get $parents)
387
debug " newparents: $newparents"