]> source.dussan.org Git - jgit.git/commitdiff
FS: Allow cloning an FS instance 12/2712/1
authorShawn O. Pearce <spearce@spearce.org>
Mon, 14 Mar 2011 16:19:39 +0000 (09:19 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 14 Mar 2011 16:19:39 +0000 (09:19 -0700)
This permits an application to create its own copy of FS.DETECTED
before manually setting the userHome or gitPrefix.

Bug: 337101
Change-Id: Ieea33c8d0ebdc801a4656b829d2a4b398559fd45
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX_Java5.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX_Java6.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_Win32_Cygwin.java

index a7c0889219558a696984d236929d0037bd2f1b38..5a48513b670c0627b2e9baf49b1f605adec23036 100644 (file)
@@ -110,6 +110,20 @@ public abstract class FS {
                // Do nothing by default.
        }
 
+       /**
+        * Initialize this FS using another's current settings.
+        *
+        * @param src
+        *            the source FS to copy from.
+        */
+       protected FS(FS src) {
+               userHome = src.userHome;
+               gitPrefix = src.gitPrefix;
+       }
+
+       /** @return a new instance of the same type of FS. */
+       public abstract FS newInstance();
+
        /**
         * Does this operating system and JRE support the execute flag on files?
         *
index 180b016beaadbff44267ad21f7d916390af3f7d7..c181a7a744f5cd3a59a99c808de4a2077dcdc72d 100644 (file)
@@ -77,6 +77,14 @@ abstract class FS_POSIX extends FS {
                return null;
        }
 
+       FS_POSIX() {
+               super();
+       }
+
+       FS_POSIX(FS src) {
+               super(src);
+       }
+
        @Override
        public ProcessBuilder runInShell(String cmd, String[] args) {
                List<String> argv = new ArrayList<String>(4 + args.length);
index ec8175ab5ab04a41b793558baf006e54a8641698..c79bbe69bd4f288aeeca39a828fc3747480dbe3e 100644 (file)
@@ -46,6 +46,19 @@ package org.eclipse.jgit.util;
 import java.io.File;
 
 class FS_POSIX_Java5 extends FS_POSIX {
+       FS_POSIX_Java5() {
+               super();
+       }
+
+       FS_POSIX_Java5(FS src) {
+               super(src);
+       }
+
+       @Override
+       public FS newInstance() {
+               return new FS_POSIX_Java5(this);
+       }
+
        public boolean supportsExecute() {
                return false;
        }
index 2417ae7354855a8646d8a30e6e1e3cf84f28bbe2..09a4db7a2372a2d4d9aa8c3f02f0d75220379c67 100644 (file)
@@ -74,6 +74,19 @@ class FS_POSIX_Java6 extends FS_POSIX {
                }
        }
 
+       FS_POSIX_Java6() {
+               super();
+       }
+
+       FS_POSIX_Java6(FS src) {
+               super(src);
+       }
+
+       @Override
+       public FS newInstance() {
+               return new FS_POSIX_Java6(this);
+       }
+
        public boolean supportsExecute() {
                return true;
        }
index 5838fed6af3555aeb8e3535edf25a9d0d7df3884..b441d2066fd00fa1a2d83b6b686181ececfba914 100644 (file)
@@ -64,6 +64,18 @@ class FS_Win32 extends FS {
                                && StringUtils.toLowerCase(osDotName).indexOf("windows") != -1;
        }
 
+       FS_Win32() {
+               super();
+       }
+
+       FS_Win32(FS src) {
+               super(src);
+       }
+
+       public FS newInstance() {
+               return new FS_Win32(this);
+       }
+
        public boolean supportsExecute() {
                return false;
        }
index 0cc937d59613a0b533f0eef1787845146164d7ae..e5e97c5fb952c0443b61f5e76b4bb571fe7f1efb 100644 (file)
@@ -68,6 +68,18 @@ class FS_Win32_Cygwin extends FS_Win32 {
                return cygpath != null;
        }
 
+       FS_Win32_Cygwin() {
+               super();
+       }
+
+       FS_Win32_Cygwin(FS src) {
+               super(src);
+       }
+
+       public FS newInstance() {
+               return new FS_Win32_Cygwin(this);
+       }
+
        public File resolve(final File dir, final String pn) {
                String w = readPipe(dir, //
                                new String[] { cygpath, "--windows", "--absolute", pn }, //