[PATCH STABLE] tests-subrepo-git: use "f" to dump pwned.txt, for portability

danek.duvall at oracle.com danek.duvall at oracle.com
Thu Jun 2 23:22:13 UTC 2016


# HG changeset patch
# User Danek Duvall <danek.duvall at oracle.com>
# Date 1464909524 25200
#      Thu Jun 02 16:18:44 2016 -0700
# Branch stable
# Node ID b6f54f37514125e4c10c9a1c78d1e0b5c8f2f67b
# Parent  e82ca7d0967cd10d92562820297c3413abe6fc29
tests-subrepo-git: use "f" to dump pwned.txt, for portability

Rather than sometimes using a complicated shell construct to dump pwned.txt
(if it wasn't expected to exist, but might, if something were broken) or
just cat (if it was expected to exist), just use the "f" utility, which
will be consistent in its behavior across different platforms.

Also make sure that *something* gets put into pwned.txt, even if we ended
up typoing the message variable.

diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -1135,7 +1135,7 @@ make sure we show changed files, rather 
 test for Git CVE-2016-3068
   $ hg init malicious-subrepository
   $ cd malicious-subrepository
-  $ echo "s = [git]ext::sh -c echo% \$PWNED_MSG% >pwned.txt" > .hgsub
+  $ echo "s = [git]ext::sh -c echo% pwned:% \$PWNED_MSG% >pwned.txt" > .hgsub
   $ git init s
   Initialized empty Git repository in $TESTTMP/tc/malicious-subrepository/s/.git/
   $ cd s
@@ -1152,10 +1152,11 @@ test for Git CVE-2016-3068
   Cloning into '$TESTTMP/tc/malicious-subrepository-protected/s'... (glob)
   fatal: transport 'ext' not allowed
   updating to branch default
-  cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt
+  cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
   abort: git clone error 128 in s (in subrepo s)
   [255]
-  $ test -f pwned.txt && cat pwned.txt || true
+  $ f -Dq pwned.txt
+  pwned.txt: file not found
 
 whitelisting of ext should be respected (that's the git submodule behaviour)
   $ rm -f pwned.txt
@@ -1167,8 +1168,8 @@ whitelisting of ext should be respected 
   Please make sure you have the correct access rights
   and the repository exists.
   updating to branch default
-  cloning subrepo s from ext::sh -c echo% $PWNED_MSG% >pwned.txt
+  cloning subrepo s from ext::sh -c echo% pwned:% $PWNED_MSG% >pwned.txt
   abort: git clone error 128 in s (in subrepo s)
   [255]
-  $ cat pwned.txt
-  you asked for it
+  $ f -Dq pwned.txt
+  pwned: you asked for it


More information about the Mercurial-devel mailing list