test suite: remove pointless redirection.
[guilt.git] / guilt
blob3fc524ecf057ecd9565e9b2d2dd8c0416693de64
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2006-2013
6 GUILT_VERSION="0.35"
7 GUILT_NAME="Gloria"
9 GUILT="$(basename "$0")"
11 # If the first argument is one of the below, display the man page instead of
12 # the rather silly and mostly useless usage string
13 case $1 in
14 -h|--h|--he|--hel|--help)
15 shift
16 exec guilt help "$@"
17 exit
19 -V|--ver|--versi|--versio|--version)
20 echo "Guilt version $GUILT_VERSION"
21 exit
23 esac
25 # we change directories ourselves
26 SUBDIRECTORY_OK=1
28 . "$(git --exec-path)/git-sh-setup"
31 # Shell library
33 usage()
35 echo "Usage: guilt $CMDNAME $USAGE" >&2
36 exit 1
39 # echo -n is a bashism, use printf instead
40 _disp()
42 printf "%b" "$*"
45 # echo -e is a bashism, use printf instead
46 disp()
48 printf "%b\n" "$*"
51 noerr()
53 "$@" 2>/dev/null
56 silent()
58 "$@" >/dev/null 2>/dev/null
61 ########
63 GUILT_PATH="$(dirname "$0")"
65 guilt_commands()
67 find "$GUILT_PATH/../lib/guilt" -maxdepth 1 -name "guilt-*" -type f -perm +111 2> /dev/null | sed -e "s/.*\\/$GUILT-//"
68 find "$GUILT_PATH" -maxdepth 1 -name "guilt-*" -type f -perm +111 | sed -e "s/.*\\/$GUILT-//"
71 # by default, we shouldn't fail
72 cmd=
74 if [ $# -ne 0 ]; then
75 # take first arg, and try to execute it
77 arg="$1"
78 dir="$GUILT_PATH"
79 libdir="$GUILT_PATH/../lib/guilt"
81 if [ -x "$dir/guilt-$arg" ]; then
82 cmd="$dir/guilt-$arg"
83 CMDNAME=$arg
84 elif [ -x "$libdir/guilt-$arg" ]; then
85 cmd="$libdir/guilt-$arg"
86 CMDNAME=$arg
87 else
88 # might be a short handed
89 for command in $(guilt_commands); do
90 case $command in
91 $arg*)
92 if [ -x "$dir/guilt-$command" ]; then
93 cmd="$dir/guilt-$command"
94 CMDNAME=$command
95 elif [ -x "$libdir/guilt-$command" ]; then
96 cmd="$libdir/guilt-$command"
97 CMDNAME=$command
100 esac
101 done
103 if [ -z "$cmd" ]; then
104 disp "Command $arg not found" >&2
105 disp "" >&2
106 exit 1
109 shift
110 else
111 # no args passed or invalid command entered, just output help summary
113 disp "Guilt v$GUILT_VERSION"
114 disp ""
115 disp "Pick a command:"
116 guilt_commands | sort | column | column -t | sed -e 's/^/ /'
118 disp ""
119 disp "Example:"
120 disp "\tguilt push"
122 # now, let's exit
123 exit 1
126 ########
129 # Library goodies
132 # usage: valid_patchname <patchname>
133 valid_patchname()
135 case "$1" in
136 /*|./*|../*|*/./*|*/../*|*/.|*/..|*/|*\ *|*\ *)
137 return 1;;
138 *:*)
139 return 1;;
141 return 0;;
142 esac
145 get_branch()
147 silent git symbolic-ref HEAD || \
148 die "Working on a detached HEAD is unsupported."
150 git symbolic-ref HEAD | sed -e 's,^refs/heads/,,'
153 verify_branch()
155 [ ! -d "$GIT_DIR/patches" ] &&
156 die "Patches directory doesn't exist, try guilt init"
157 [ ! -d "$GIT_DIR/patches/$branch" ] &&
158 die "Branch $branch is not initialized, try guilt init"
159 [ ! -f "$GIT_DIR/patches/$branch/series" ] &&
160 die "Branch $branch does not have a series file"
161 [ ! -f "$GIT_DIR/patches/$branch/status" ] &&
162 die "Branch $branch does not have a status file"
163 [ -f "$GIT_DIR/patches/$branch/applied" ] &&
164 die "Warning: Branch $branch has 'applied' file - guilt is not compatible with stgit"
167 get_top()
169 tail -n 1 "$GUILT_DIR/$branch/status"
172 get_prev()
174 if [ `wc -l < "$GUILT_DIR/$branch/status"` -gt 1 ]; then
175 tail -n 2 "$GUILT_DIR/$branch/status" | head_n 1
179 get_full_series()
181 # ignore all lines matching:
182 # - empty lines
183 # - whitespace only
184 # - optional whitespace followed by '#' followed by more
185 # optional whitespace
186 # also remove comments from end of lines
187 sed -n -e "/^[[:space:]]*\(#.*\)*\$/ ! {
188 s/[[:space:]]*#.*\$//
192 " "$series"
195 get_series()
197 get_full_series | while read p; do
198 check_guards "$p" && echo "$p"
199 done
202 # usage: check_guards <patch>
203 # Returns 0 if the patch should be pushed
204 check_guards()
206 get_guards "$1" | while read guard; do
207 g=`echo $guard | sed "s/^[+-]//"`
208 case "$guard" in
210 # Push +guard *only if* guard selected
211 silent grep -F "$g" "$guards_file" || return 1
214 # Push -guard *unless* guard selected
215 silent grep -F "$g" "$guards_file" && return 1
216 true
218 esac
219 done
221 # propagate return from subshell
222 return $?
225 # usage: get_guards <patch>
226 get_guards()
228 awk -v pname="$1" '
229 ($1 == pname) {
230 guards = "";
232 for(i=2; i<=NF; i++) {
233 sub(/#[^+-]*/, "", $i);
234 if (length($i)) {
235 if (length(guards))
236 guards = guards " " $i;
237 else
238 guards = $i;
242 print guards;
243 }' < "$series"
246 # usage: set_guards <patch> <guards...>
247 set_guards()
250 p="$1"
251 shift
252 for x in "$@"; do
253 case "$x" in
254 [+-]*)
255 awk -v pname="$p" -v newguard="$x" '{
256 if ($1 == pname)
257 print $0 " #" newguard;
258 else
259 print $0;
260 }' < "$series" > "$series.tmp"
261 mv "$series.tmp" "$series"
264 echo "'$x' is not a valid guard name" >&2
266 esac
267 done
271 # usage: unset_guards <patch> <guards...>
272 unset_guards()
275 p="$1"
276 shift
277 for x in "$@"; do
278 awk -v pname="$p" -v oldguard="$x" '{
279 if ($1 == pname) {
280 guards = "";
282 for(i=2; i<=NF; i++) {
283 if ($i == "#" oldguard)
284 continue;
286 if (length(guards))
287 guards = guards " " $i;
288 else
289 guards = $i;
292 if (length(guards))
293 print $1 " " guards;
294 else
295 print $1;
296 } else
297 print $0;
298 }' < "$series" > "$series.tmp"
299 mv "$series.tmp" "$series"
300 done
304 # usage: do_make_header <hash>
305 do_make_header()
307 # we should try to work with commit objects only
308 if [ `git cat-file -t "$1"` != "commit" ]; then
309 disp "Hash $1 is not a commit object" >&2
310 disp "Aborting..." >&2
311 exit 2
314 git cat-file -p "$1" | awk '
315 BEGIN{headers=1; firstline=1}
316 /^author / && headers {
317 sub(/^author +/, "");
318 sub(/ [0-9]* [+-]*[0-9][0-9]*$/, "");
319 author=$0
321 !headers {
322 print
323 if (firstline) {
324 firstline = 0;
325 print "\nFrom: " author;
328 /^$/ && headers { headers = 0 }
332 # usage: do_get_patch patchfile
333 do_get_patch()
335 awk '
336 BEGIN{}
337 /^(diff |--- )/ {patch = 1}
338 patch == 1 {print $0}
339 END{}
340 ' < "$1"
343 # usage: do_get_header patchfile
344 do_get_header()
346 # The complexity arises from the fact that we want to ignore all but the
347 # Subject line of the header, and any empty lines after it, if these
348 # exist, and inject only the Subject line as the first line of the
349 # commit message.
351 # We also need to strip "from:" lines from the body of the patch
352 # description as these are used by people to manually set the author of
353 # the patch to be different to their local email address and failing to
354 # strip them results in duplicate from: lines in output from guilt
355 # patchbomb.
357 # 1st line prints first encountered Subject line plus empty line.
358 # 2nd line skips standard email/git patch header lines.
359 # 3th line skips "from:" lines throughout the patch description
360 # 4rd line skips tip's additional header lines.
361 # 5th line skips any empty lines thereafter.
362 # 6th line turns off empty line skip upon seeing a non-empty line.
363 # 7th line terminates execution when we encounter the diff
364 awk '
365 BEGIN{body=0; subj=0}
366 /^Subject:/ && (body == 0 && subj == 0){subj=1; print substr($0, 10) "\n"; next}
367 /^(Subject:|Author:|Date:|commit)/ && (body == 0){next}
368 /^From:/ {body=0; next}
369 /^(Commit-ID:|Gitweb:|AuthorDate:|Committer:CommitDate:)/ && (body == 0){next}
370 /^[ \t\f\n\r\v]*$/ && (body==0){next}
371 /^.*$/ && (body==0){body=1}
372 /^(diff |---$|--- )/{exit}
373 {print $0}
374 END{}
375 ' < "$1"
378 # usage: do_get_full_header patchfile
379 do_get_full_header()
381 # 2nd line checks for the begining of a patch
382 # 3rd line outputs the line if it didn't get pruned by the above rules
383 awk '
384 BEGIN{}
385 /^(diff |---$|--- )/{exit}
386 {print $0}
387 END{}
388 ' < "$1"
391 # usage: assert_head_check
392 assert_head_check()
394 if ! head_check refs/patches/$branch/`get_top`; then
395 die "aborting..."
399 # usage: head_check <expected hash>
400 head_check()
402 # make sure we're not doing funky things to commits that don't
403 # belong to us
405 case "$1" in
407 # the expected hash is empty
408 return 0 ;;
409 refs/patches/$branch/)
410 # the expected hash is an invalid rev
411 return 0 ;;
412 esac
414 if [ "`git rev-parse refs/heads/\`git_branch\``" != "`git rev-parse $1`" ]; then
415 disp "Expected HEAD commit $1" >&2
416 disp " got `git rev-parse refs/heads/\`git_branch\``" >&2
417 return 1
419 return 0
422 # usage: series_insert_patch <patchname>
423 series_insert_patch()
425 awk -v top="`get_top`" -v new="$1" \
426 'BEGIN{if (top == "") print new;}
428 print $0;
429 if (top != "" && top == $0) print new;
430 }' "$series" > "$series.tmp"
431 mv "$series.tmp" "$series"
434 # usage: series_remove_patch <patchname>
435 series_remove_patch()
437 grep -v "^$1\([[:space:]].*\)\?$" < "$series" > "$series.tmp"
438 mv "$series.tmp" "$series"
441 # usage: series_rename_patch <oldname> <newname>
442 series_rename_patch()
444 # Rename the patch, but preserve comments on the line
445 awk -v old="$1" -v new="$2" '
447 if (index($0, old) == 1)
448 print new substr($0, length(old) + 1);
449 else
450 print $0;
451 }' "$series" > "$series.tmp"
453 mv "$series.tmp" "$series"
456 # usage: series_rename_patch <oldpatchname> <newpatchname>
457 ref_rename_patch()
459 git update-ref "refs/patches/$branch/$2" `git rev-parse "refs/patches/$branch/$1"`
460 remove_ref "refs/patches/$branch/$1"
463 # Beware! This is one of the few (only?) places where we modify the applied
464 # file directly
466 # usage: applied_rename_patch <oldname> <newname>
467 applied_rename_patch()
469 awk -v old="$1" -v new="$2" \
470 'BEGIN{FS=":"}
471 { if ($0 == old)
472 print new;
473 else
474 print;
475 }' "$applied" > "$applied.tmp"
477 mv "$applied.tmp" "$applied"
480 # usage: remove_patch_refs
481 # reads patch names from stdin
482 remove_patch_refs()
484 while read pname; do
485 remove_ref "refs/patches/$branch/$pname"
486 done
489 # usage: pop_many_patches <commitish> <number of patches>
490 pop_many_patches()
492 assert_head_check
495 cd_to_toplevel
497 # remove the patches refs
498 tail -n $2 < "$applied" | remove_patch_refs
500 git reset --hard "$1" > /dev/null
502 n=`wc -l < "$applied"`
503 n=`expr $n - $2`
504 head_n "$n" < "$applied" > "$applied.tmp"
505 mv "$applied.tmp" "$applied"
506 if [ -z "`get_top 2>/dev/null`" ] && [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix
507 then
508 git symbolic-ref HEAD refs/heads/$branch
509 git update-ref -d refs/heads/$GUILT_PREFIX$branch
514 # usage: pop_all_patches
515 pop_all_patches()
517 pop_many_patches \
518 `git rev-parse refs/patches/$branch/$(head_n 1 "$applied")^` \
519 `wc -l < "$applied"`
522 # usage: remove_ref <refname>
523 remove_ref()
526 # does the ref exist?
527 r=`git show-ref --verify -s "$1" 2> /dev/null`
528 [ $? -ne 0 ] && exit 0
530 # remove it
531 git update-ref -d "$1" "$r"
535 # usage: commit patchname parent
536 commit()
539 TMP_MSG=`get_tmp_file msg`
541 p="$GUILT_DIR/$branch/$1"
542 pname="$1"
543 cd_to_toplevel
545 git diff-files --name-only | (while read n; do git update-index "$n" ; done)
547 # grab a commit message out of the patch
548 do_get_header "$p" > "$TMP_MSG"
550 # make a default commit message if patch doesn't contain one
551 [ ! -s "$TMP_MSG" ] && echo "patch $pname" > "$TMP_MSG"
553 # extract author and date lines from the patch header, and set
554 # GIT_AUTHOR_{NAME,EMAIL,DATE}
555 # prefering Author/AuthorDate lines if available.
556 author_str=`sed -n -e '/^Author:/ { s/^Author: //; p; q; }; /^(diff |---$|--- )/ q' "$p"`
557 if [ -z "$author_str" ]; then
558 author_str=`sed -n -e '/^From:/ { s/^From: //; p; q; }; /^(diff |---$|--- )/ q' "$p"`
561 if [ ! -z "$author_str" ]; then
562 GIT_AUTHOR_NAME=`echo $author_str | sed -e 's/ *<.*$//'`
563 export GIT_AUTHOR_NAME="${GIT_AUTHOR_NAME:-" "}"
564 export GIT_AUTHOR_EMAIL="`echo $author_str | sed -e 's/[^<]*//'`"
566 author_date_str=`sed -n -e '/^AuthorDate:/ { s/^AuthorDate: //; p; q; }; /^(diff |---$|--- )/ q' "$p"`
567 if [ -z "$author_date_str" ]; then
568 author_date_str=`sed -n -e '/^Date:/ { s/^Date: //; p; q; }; /^(diff |---$|--- )/ q' "$p"`
570 if [ ! -z "$author_date_str" ]; then
571 export GIT_AUTHOR_DATE="$author_date_str"
575 # `git log -1 --pretty=%ct` doesn't work on Git 1.5.x
576 ct=`git cat-file commit HEAD | awk '/^committer /{ print $(NF-1); exit; }'`
577 if [ $ct -gt `last_modified "$p"` ]; then
578 ct=`expr $ct + 60`
579 if [ $ct -gt `date +%s` ]; then
580 touch "$p"
581 else
582 touch_date $ct "$p"
586 export GIT_COMMITTER_DATE="`format_last_modified "$p"`"
588 # export GIT_AUTHOR_DATE only if a Date line was unavailable
589 if [ -z "$author_date_str" ]; then
590 export GIT_AUTHOR_DATE="$GIT_COMMITTER_DATE"
593 # commit
594 treeish=`git write-tree`
595 commitish=`git commit-tree $treeish -p $2 < "$TMP_MSG"`
596 if $old_style_prefix || git rev-parse --verify --quiet refs/heads/$GUILT_PREFIX$branch >/dev/null
597 then
598 git update-ref HEAD $commitish
599 else
600 git branch $GUILT_PREFIX$branch $commitish
601 git symbolic-ref HEAD refs/heads/$GUILT_PREFIX$branch
604 # mark patch as applied
605 git update-ref "refs/patches/$branch/$pname" HEAD
607 rm -f "$TMP_MSG"
611 # usage: push_patch patchname [bail_action]
612 push_patch()
614 __push_patch_bail=0
617 TMP_LOG=`get_tmp_file log`
619 p="$GUILT_DIR/$branch/$1"
620 pname="$1"
621 bail_action="$2"
622 reject="--reject"
624 assert_head_check
625 cd_to_toplevel
627 # apply the patch if and only if there is something to apply
628 if [ `do_get_patch "$p" | wc -l` -gt 0 ]; then
629 if [ "$bail_action" = abort ]; then
630 reject=""
632 git apply -C$guilt_push_diff_context --index \
633 $reject "$p" > /dev/null 2> "$TMP_LOG"
634 __push_patch_bail=$?
636 if [ $__push_patch_bail -ne 0 ]; then
637 cat "$TMP_LOG" >&2
638 if [ "$bail_action" = "abort" ]; then
639 rm -f "$TMP_LOG" "$TMP_MSG"
640 return $__push_patch_bail
645 commit "$pname" HEAD
647 echo "$pname" >> "$applied"
649 rm -f "$TMP_LOG"
652 # sub-shell funky-ness
653 __push_patch_bail=$?
655 return $__push_patch_bail
658 # usage: must_commit_first
659 must_commit_first()
661 git update-index --refresh --unmerged -q > /dev/null
662 [ `git diff-files | wc -l` -eq 0 ] || return $?
663 [ `git diff-index HEAD | wc -l` -eq 0 ]
664 return $?
667 # usage: fold_patch patchname
668 fold_patch()
670 set -- "$1" "`get_top`"
672 assert_head_check
674 push_patch "$1"
676 # merge the patch headers
678 pcur="$GUILT_DIR/$branch/$2"
679 pnext="$GUILT_DIR/$branch/$1"
680 TMP_CUR=`get_tmp_file diff-cur`
681 TMP_NEXT=`get_tmp_file diff-next`
682 TMP_DIFF=`get_tmp_file diff`
683 do_get_full_header "$pcur" > "$TMP_CUR"
684 do_get_full_header "$pnext" > "$TMP_NEXT"
685 do_get_patch "$pcur" > "$TMP_DIFF"
687 case "`stat -c %s \"$TMP_CUR\"`,`stat -c %s \"$TMP_NEXT\"`" in
688 *,0)
689 # since the new patch header is empty, we
690 # don't have to do anything
692 0,*)
693 # current is empty; new is not
694 mv "$pcur" "$pcur~"
695 cat "$TMP_NEXT" > "$pcur"
696 cat "$TMP_DIFF" >> "$pcur"
698 *,*)
699 mv "$pcur" "$pcur~"
700 cat "$TMP_CUR" > "$pcur"
701 echo >> "$pcur"
702 echo "Header from folded patch '$1':" >> "$pcur"
703 echo >> "$pcur"
704 cat "$TMP_NEXT" >> "$pcur"
705 cat "$TMP_DIFF" >> "$pcur"
707 esac
709 rm -f "$TMP_CUR" "$TMP_NEXT" "$TMP_DIFF"
712 __refresh_patch "$2" HEAD^^ 2 "" ""
714 series_remove_patch "$1"
717 # usage: refresh_patch patchname gengitdiff incldiffstat
718 refresh_patch()
720 __refresh_patch "$1" HEAD^ 1 "$2" "$3"
723 # usage: __refresh_patch patchname commitish number_of_commits gengitdiff
724 # incldiffstat
725 __refresh_patch()
727 assert_head_check
730 TMP_DIFF=`get_tmp_file diff`
732 cd_to_toplevel
733 p="$GUILT_DIR/$branch/$1"
734 pname="$1"
736 # get the patch header
737 do_get_full_header "$p" > "$TMP_DIFF"
739 [ ! -z "$4" ] && diffopts="-C -M --find-copies-harder"
741 if [ -n "$5" -o $diffstat = "true" ]; then
743 echo "---"
744 git diff --stat $diffopts "$2"
745 echo ""
746 ) >> "$TMP_DIFF"
749 # get the new patch
750 git diff --binary $diffopts "$2" >> "$TMP_DIFF"
752 # move the new patch in
753 mv "$p" "$p~"
754 mv "$TMP_DIFF" "$p"
756 # commit
757 commit "$pname" "HEAD~$3"
759 # drop folded patches
760 N=`expr "$3" - 1`
762 # remove the patches refs
763 tail -n $N < "$applied" | remove_patch_refs
765 n=`wc -l < "$applied"`
766 n=`expr $n - $N`
767 head_n "$n" < "$applied" > "$applied.tmp"
768 mv "$applied.tmp" "$applied"
772 # usage: munge_hash_range <hash range>
774 # this means:
775 # <hash> - one commit
776 # <hash>.. - hash until head (excludes hash, includes head)
777 # ..<hash> - until hash (includes hash)
778 # <hash1>..<hash2> - from hash to hash (inclusive)
780 # The output of this function is suitable to be passed to "git rev-list"
781 munge_hash_range()
783 case "$1" in
784 *..*..*|*\ *)
785 # double .. or space is illegal
786 return 1;;
787 ..*)
788 # e.g., "..v0.10"
789 echo ${1#..};;
790 *..)
791 # e.g., "v0.19.."
792 echo ${1%..}..HEAD;;
793 *..*)
794 # e.g., "v0.19-rc1..v0.19"
795 echo ${1%%..*}..${1#*..};;
797 # e.g., "v0.19"
798 echo $1^..$1;;
799 *) # empty
800 return 1;;
801 esac
802 return 0
805 # usage: get_tmp_file <prefix> [<opts>]
807 # Get a unique filename and create the file in a non-racy way
808 get_tmp_file()
810 while true; do
811 mktemp $2 "/tmp/guilt.$1.XXXXXXXXXXXXXXX" && break
812 done
815 # usage: guilt_hook <hook name> <args....>
816 guilt_hook()
818 __hookname="$1"
819 [ ! -x "$GIT_DIR/hooks/guilt/$__hookname" ] && return 0
821 shift
823 "$GIT_DIR/hooks/guilt/$__hookname" "$@"
824 return $?
828 # source the command
830 . "$cmd"
833 # Some constants
836 # used for: git apply -C <val>
837 guilt_push_diff_context=1
839 # default diffstat value: true or false
840 DIFFSTAT_DEFAULT="false"
842 # Prefix for guilt branches.
843 GUILT_PREFIX=guilt/
846 # Parse any part of .git/config that belongs to us
849 # generate diffstat?
850 diffstat=`git config --bool guilt.diffstat`
851 [ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT
854 # The following gets run every time this file is source'd
857 GUILT_DIR="$GIT_DIR/patches"
859 # To make it harder to accidentally do "git push" with a guilt patch
860 # applied, "guilt push" changes branch from e.g. "master" to
861 # "guilt/master". Set $git_branch to the full branch name, and
862 # $branch to the abbreviated name that the user sees most of the time.
863 # Note: old versions of guilt did not add the "guilt/" prefix. This
864 # code handles that case as well. The prefix will be added when you
865 # have no patches applied and do a "guilt push".
866 raw_git_branch=`get_branch`
867 branch=`echo "$raw_git_branch" | sed -e 's,^'$GUILT_PREFIX',,'`
869 git_branch()
871 if $old_style_prefix
872 then
873 echo $branch
874 elif [ -z "`get_top 2>/dev/null`" ]
875 then
876 echo $branch
877 else
878 echo $GUILT_PREFIX$branch
882 # most of the time we want to verify that the repo's branch has been
883 # initialized, but every once in a blue moon (e.g., we want to run guilt init),
884 # we must avoid the checks
885 if [ -z "$DO_NOT_CHECK_BRANCH_EXISTENCE" ]; then
886 verify_branch
888 # do not check the status file format (guilt repair needs this,
889 # otherwise nothing can do what's necessary to bring the repo into a
890 # useable state)
891 if [ -z "$DO_NOT_CHECK_STATUS_FILE_FORMAT" ]; then
892 [ -s "$GIT_DIR/patches/$branch/status" ] &&
893 grep "^[0-9a-f]\{40\}:" "$GIT_DIR/patches/$branch/status" > /dev/null &&
894 die "Status file appears to use old format, try guilt repair --status"
898 # very useful files
899 series="$GUILT_DIR/$branch/series"
900 applied="$GUILT_DIR/$branch/status"
901 guards_file="$GUILT_DIR/$branch/guards"
903 # determine a pager to use for anything interactive (fall back to more)
904 pager="more"
905 [ ! -z "$PAGER" ] && pager="$PAGER"
907 UNAME_S=`uname -s`
909 if [ -r "$GUILT_PATH/os.$UNAME_S" ]; then
910 . "$GUILT_PATH/os.$UNAME_S"
911 elif [ -r "$GUILT_PATH/../lib/guilt/os.$UNAME_S" ]; then
912 . "$GUILT_PATH/../lib/guilt/os.$UNAME_S"
913 else
914 die "Unsupported operating system: $UNAME_S"
917 if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]
918 then
919 # This is for compat with old repositories that still have a
920 # pushed patch without the new-style branch prefix.
921 old_style_prefix=true
922 else
923 old_style_prefix=false
926 _main "$@"