summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2670b33)
The standard procedure 'tmp=mktemp; trap "rm $tmp" 0' was broken with the
introduction of the pager. Which overwrites the trap itself to close and
remove the pager fifo.
Now tg provides a temp playground and all other temp files should be created
inside this directory and only this directory will be removed with the exit
trap. setup_pager still overwrites the trap, but keeps the rm command from
the global temp directory. To simplify this the new function get_temp() is
provided.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
done
# check for repetitions of deps
done
# check for repetitions of deps
-depdir="$(mktemp -t -d tg-depdir.XXXXXX)" ||
+depdir="$(get_temp tg-depdir -d)" ||
die "Can't check for multiple occurrences of deps"
die "Can't check for multiple occurrences of deps"
-trap "rm -rf '$depdir'" 0
cat_file "(i):.topdeps" |
while read dep; do
[ ! -d "$depdir/$dep" ] ||
cat_file "(i):.topdeps" |
while read dep; do
[ ! -d "$depdir/$dep" ] ||
-playground="$(mktemp -d -t tg-export.XXXXXX)"
-trap 'rm -rf "$playground"' EXIT
+playground="$(get_temp tg-export -d)"
git cat-file blob "$name:.topdeps" |
sed '1{ s/^/Depends: /; n; }; s/^/ /;'
git cat-file blob "$name:.topdeps" |
sed '1{ s/^/Depends: /; n; }; s/^/ /;'
-depcheck="$(mktemp -t tg-depcheck.XXXXXX)"
+depcheck="$(get_temp tg-depcheck)"
missing_deps=
needs_update "$name" >"$depcheck" || :
if [ -n "$missing_deps" ]; then
missing_deps=
needs_update "$name" >"$depcheck" || :
if [ -n "$missing_deps" ]; then
else
echo "Up-to-date."
fi
else
echo "Up-to-date."
fi
-patchfile="$(mktemp -t tg-mail.XXXXXX)"
+patchfile="$(get_temp tg-mail)"
$tg patch "$name" >"$patchfile"
$tg patch "$name" >"$patchfile"
# NOTE: git-send-email handles cc itself
eval git send-email $send_email_args "$people" "$patchfile"
# NOTE: git-send-email handles cc itself
eval git send-email $send_email_args "$people" "$patchfile"
[ -n "$(git grep $diff_opts '^[-]--' ${diff_committed_only:+"$name"} -- ".topmsg")" ] || echo '---'
# Evil obnoxious hack to work around the lack of git diff --exclude
[ -n "$(git grep $diff_opts '^[-]--' ${diff_committed_only:+"$name"} -- ".topmsg")" ] || echo '---'
# Evil obnoxious hack to work around the lack of git diff --exclude
-git_is_stupid="$(mktemp -t tg-patch-changes.XXXXXX)"
+git_is_stupid="$(get_temp tg-patch-changes)"
git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- |
fgrep -vx ".topdeps" |
fgrep -vx ".topmsg" >"$git_is_stupid" || : # fgrep likes to fail randomly?
git diff --name-only $diff_opts "$base_rev" ${diff_committed_only:+"$name"} -- |
fgrep -vx ".topdeps" |
fgrep -vx ".topmsg" >"$git_is_stupid" || : # fgrep likes to fail randomly?
else
echo "No changes."
fi
else
echo "No changes."
fi
echo '-- '
echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"
echo '-- '
echo "tg: ($base_rev..) $name (depends on: $(cat_file "$topic:.topdeps" | paste -s -d' '))"
ref_exists "$name" || die "detached HEAD? Can't push $name"
done
ref_exists "$name" || die "detached HEAD? Can't push $name"
done
-_listfile="$(mktemp -t tg-push-listfile.XXXXXX)"
-trap "rm -f \"$_listfile\"" 0
+_listfile="$(get_temp tg-push-listfile)"
fi
if [ -n "$sort" ]; then
fi
if [ -n "$sort" ]; then
+ tsort_input="$(get_temp tg-summary-sort)"
exec 4>$tsort_input
exec 5<$tsort_input
exec 4>$tsort_input
exec 5<$tsort_input
## First, take care of our base
## First, take care of our base
-depcheck="$(mktemp -t tg-depcheck.XXXXXX)"
+depcheck="$(get_temp tg-depcheck)"
missing_deps=
needs_update "$name" >"$depcheck" || :
[ -z "$missing_deps" ] || die "some dependencies are missing: $missing_deps"
missing_deps=
needs_update "$name" >"$depcheck" || :
[ -z "$missing_deps" ] || die "some dependencies are missing: $missing_deps"
else
info "The base is up-to-date."
fi
else
info "The base is up-to-date."
fi
# Home, sweet home...
# (We want to always switch back, in case we were on the base from failed
# Home, sweet home...
# (We want to always switch back, in case we were on the base from failed
_name="$1"; # no shift
_depchain="$*"
_name="$1"; # no shift
_depchain="$*"
- _depsfile="$(mktemp -t tg-depsfile.XXXXXX)"
+ _depsfile="$(get_temp tg-depsfile)"
# If no_remotes is unset check also our base against remote base.
# Checking our head against remote head has to be done in the helper.
if test -z "$no_remotes" && has_remote "top-bases/$_name"; then
# If no_remotes is unset check also our base against remote base.
# Checking our head against remote head has to be done in the helper.
if test -z "$no_remotes" && has_remote "top-bases/$_name"; then
eval "$_cmd"
done <"$_depsfile"
missing_deps="${missing_deps# }"
eval "$_cmd"
done <"$_depsfile"
missing_deps="${missing_deps# }"
# now spawn pager
export LESS="${LESS:-FRSX}" # as in pager.c:pager_preexec()
# now spawn pager
export LESS="${LESS:-FRSX}" # as in pager.c:pager_preexec()
- _pager_fifo_dir="$(mktemp -t -d tg-pager-fifo.XXXXXX)"
- _pager_fifo="$_pager_fifo_dir/0"
- mkfifo -m 600 "$_pager_fifo"
+ # setup_pager should be called only once per command
+ pager_fifo="$tg_tmp_dir/pager"
+ mkfifo -m 600 "$pager_fifo"
- "$TG_PAGER" < "$_pager_fifo" &
- exec > "$_pager_fifo" # dup2(pager_fifo.in, 1)
+ "$TG_PAGER" < "$pager_fifo" &
+ exec > "$pager_fifo" # dup2(pager_fifo.in, 1)
# this is needed so e.g. `git diff` will still colorize it's output if
# requested in ~/.gitconfig with color.diff=auto
export GIT_PAGER_IN_USE=1
# atexit(close(1); wait pager)
# this is needed so e.g. `git diff` will still colorize it's output if
# requested in ~/.gitconfig with color.diff=auto
export GIT_PAGER_IN_USE=1
# atexit(close(1); wait pager)
- trap "exec >&-; rm \"$_pager_fifo\"; rmdir \"$_pager_fifo_dir\"; wait" EXIT
+ # deliberately overwrites the global EXIT trap
+ trap "exec >&-; rm -rf \"$tg_tmp_dir\"; wait" EXIT
+}
+
+# get_temp NAME [-d]
+# creates a new temporary file (or directory with -d) in the global
+# temporary directory $tg_tmp_dir with pattern prefix NAME
+get_temp()
+{
+ mktemp ${2-} "$tg_tmp_dir/$1.XXXXXX"
# make sure merging the .top* files will always behave sanely
setup_ours
setup_hook "pre-commit"
# make sure merging the .top* files will always behave sanely
setup_ours
setup_hook "pre-commit"
+# create global temporary directories, inside GIT_DIR
+tg_tmp_dir="$(mktemp -d "$git_dir/tg-tmp.XXXXXX")"
+trap "rm -rf \"$tg_tmp_dir\"" EXIT