From: "David A. Wheeler" <dwheeler@dwheeler.com>
To: Petr Baudis <pasky@ucw.cz>
Cc: git@vger.kernel.org
Subject: [PATCH] Eliminate use of mktemp's "-t" option
Date: Thu, 21 Apr 2005 23:13:00 -0400 [thread overview]
Message-ID: <42686BBC.9050703@dwheeler.com> (raw)
In-Reply-To: <20050422024010.GE7443@pasky.ji.cz>
[-- Attachment #1: Type: text/plain, Size: 551 bytes --]
It turns out that mktemp's "-t" option, while useful, isn't
available on many systems (Mandrake & Red Hat Linux 9 at least,
and probably piles of others). So, here's a portability
patch that removes all use of mktemp's "-t" option.
Unlike the quick hack I posted earlier, this should be
"clean everywhere" (assuming you have mktemp).
This is a patch against git-pasky 0.6.3.
This is my first attempt to _post_ a patch using git itself,
and I'm not entirely sure how you want it. Let me know
if you have a problem with it!
--- David A. Wheeler
[-- Attachment #2: rm-mktemp-dash-t.patch --]
[-- Type: text/plain, Size: 4612 bytes --]
commit 5f926b684025b83e34386bf8e4ef30a97e2ae5ec
tree 61059575269ed1027cfb66543251e182f87d1064
parent dd69ca5f806c8b10bb29ecb8d77c88be007c981c
author David A. Wheeler <dwheeler@dwheeler.com> 1114138972 -0400
committer David A. Wheeler <dwheeler@dwheeler.com> 1114138972 -0400
Eliminated use of mktemp's "-t" option; older mktemps don't support it.
Index: README
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/README (mode:100644 sha1:a71b5fbdbdac0bf2e2d021e422b9f49dd5481165)
+++ 61059575269ed1027cfb66543251e182f87d1064/README (mode:100644 sha1:80952e2f67b28f64c10cfb913df375a5dd244cd9)
@@ -141,7 +141,7 @@
C compiler
bash
basic shell environment (sed, grep, textutils, ...)
- mktemp 1.5+ (Mandrake users beware!)
+ mktemp
diff, patch
libssl
rsync
Index: gitapply.sh
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/gitapply.sh (mode:100755 sha1:7703809dc0743c6e4c1fa5b7d922a4efc16b4276)
+++ 61059575269ed1027cfb66543251e182f87d1064/gitapply.sh (mode:100755 sha1:14a13ff23cff2a80f9a44c053002f837fec13e2c)
@@ -8,9 +8,13 @@
#
# Takes the diff on stdin.
-gonefile=$(mktemp -t gitapply.XXXXXX)
-todo=$(mktemp -t gitapply.XXXXXX)
-patchfifo=$(mktemp -t gitapply.XXXXXX)
+if [ -z "$TMPDIR"]; then
+ TMPDIR=/tmp
+fi
+
+gonefile=$(mktemp "$TMPDIR/gitapply.XXXXXX")
+todo=$(mktemp "$TMPDIR/gitapply.XXXXXX")
+patchfifo=$(mktemp "$TMPDIR/gitapply.XXXXXX")
rm $patchfifo && mkfifo -m 600 $patchfifo
show-files --deleted >$gonefile
Index: gitcommit.sh
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/gitcommit.sh (mode:100755 sha1:a13bef2c84492ed75679d7d52bb710df35544f8a)
+++ 61059575269ed1027cfb66543251e182f87d1064/gitcommit.sh (mode:100755 sha1:ee777605dccdc9737cf743f4f8c96b9bacd97f10)
@@ -16,6 +16,9 @@
exit 1
}
+if [ -z "$TMPDIR"]; then
+ TMPDIR=/tmp
+fi
[ -s .git/blocked ] && die "committing blocked: $(cat .git/blocked)"
@@ -67,7 +70,7 @@
fi
echo "Enter commit message, terminated by ctrl-D on a separate line:"
-LOGMSG=$(mktemp -t gitci.XXXXXX)
+LOGMSG=$(mktemp "$TMPDIR/gitci.XXXXXX")
if [ "$merging" ]; then
echo -n 'Merge with ' >>$LOGMSG
echo -n 'Merge with '
@@ -111,7 +114,7 @@
if [ ! "$customfiles" ]; then
rm -f .git/add-queue .git/rm-queue
else
- greptmp=$(mktemp -t gitci.XXXXXX)
+ greptmp=$(mktemp "$TMPDIR/gitci.XXXXXX")
for file in $customfiles; do
if [ -s .git/add-queue ]; then
fgrep -vx "$file" .git/add-queue >$greptmp
Index: gitdiff-do
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/gitdiff-do (mode:100755 sha1:218dfabeb4a5dcbd2cf58bd6f672f385690ec397)
+++ 61059575269ed1027cfb66543251e182f87d1064/gitdiff-do (mode:100755 sha1:caf20ae034b8dc9f88922ee9f82809bb32a56231)
@@ -32,7 +32,11 @@
[ "$labelapp" ] && label="$label ($labelapp)"
}
-diffdir=$(mktemp -d -t gitdiff.XXXXXX)
+if [ -z "$TMPDIR"]; then
+ TMPDIR=/tmp
+fi
+
+diffdir=$(mktemp -d "$TMPDIR/gitdiff.XXXXXX")
diffdir1="$diffdir/$id1"
diffdir2="$diffdir/$id2"
mkdir "$diffdir1" "$diffdir2"
Index: gitdiff.sh
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/gitdiff.sh (mode:100755 sha1:195c3b9962c764855ec6168a78babf5867ea3046)
+++ 61059575269ed1027cfb66543251e182f87d1064/gitdiff.sh (mode:100755 sha1:278511a3f491ed7d5e41bbd642acfd9b5a1d8257)
@@ -80,6 +80,10 @@
shift
fi
+if [ -z "$TMPDIR"]; then
+ TMPDIR=/tmp
+fi
+
if [ "$parent" ]; then
id2="$id1"
id1=$(parent-id "$id2" | head -n 1)
@@ -88,7 +92,7 @@
if [ "$id2" = " " ]; then
if [ "$id1" != " " ]; then
- export GIT_INDEX_FILE=$(mktemp -t gitdiff.XXXXXX)
+ export GIT_INDEX_FILE=$(mktemp "$TMPDIR/gitdiff.XXXXXX")
read-tree $(gitXnormid.sh "$id1")
update-cache --refresh
fi
Index: gitmerge.sh
===================================================================
--- 6a612d42afdba20fd2150e319a689ed451b010e4/gitmerge.sh (mode:100755 sha1:683755729b6f689ea43c692712fad6e51eeac354)
+++ 61059575269ed1027cfb66543251e182f87d1064/gitmerge.sh (mode:100755 sha1:1c733bbdb9fe54c41787d962d0f55bb5f67d4c63)
@@ -19,6 +19,10 @@
exit 1
}
+if [ -z "$TMPDIR"]; then
+ TMPDIR=/tmp
+fi
+
head=$(commit-id)
@@ -58,7 +62,7 @@
echo "Fast-forwarding $base -> $branch" >&2
echo -e "\ton top of $head..." >&2
- patchfile=$(mktemp -t gitmerge.XXXXXX)
+ patchfile=$(mktemp "$TMPDIR/gitmerge.XXXXXX")
gitdiff.sh >$patchfile
read-tree -m $(tree-id $branch)
next prev parent reply other threads:[~2005-04-22 3:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-22 1:55 [PATCH] git-pasky spec file Chris Wright
2005-04-22 2:40 ` Petr Baudis
2005-04-22 2:48 ` Chris Wright
2005-04-25 21:24 ` Paul Dickson
2005-04-25 22:21 ` Chris Wright
2005-04-22 3:13 ` David A. Wheeler [this message]
2005-04-22 14:16 ` Kevin Smith
2005-04-22 15:21 ` Chris Wright
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42686BBC.9050703@dwheeler.com \
--to=dwheeler@dwheeler.com \
--cc=git@vger.kernel.org \
--cc=pasky@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).