Top Description Inners Fields Constructors Methods
org.eclipse.jgit.util

public Class FS_POSIX

extends FS
Class Inheritance
Static Imports
org.eclipse.jgit.lib.ConfigConstants.CONFIG_CORE_SECTION, .ConfigConstants.CONFIG_KEY_SUPPORTSATOMICFILECREATION

Base FS for POSIX based systems
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private static final Map<FileStore, Boolean>
private static final String
private static final int
private static final Logger
private volatile FS_POSIX.AtomicFileCreation
private volatile int
Inherited from org.eclipse.jgit.util.FS:
DETECTEDNO_ENTRIES

Constructor Summary

AccessConstructor and Description
protected
FS_POSIX()

Default constructor.

protected
FS_POSIX(FS
FS to copy some settings from
src
)

Constructor

Method Summary

Modifier and TypeMethod and Description
private static void
apply(Set<PosixFilePermission> set, int umask, PosixFilePermission perm, int test)

public boolean
canExecute(File
abstract path to test.
f
)

Implements abstract org.eclipse.jgit.util.FS.canExecute.

Determine if the file is executable (or not).

public FS.LockToken

Returns:

LockToken this lock token must be held until the file is no longer needed
createNewFileAtomic
(File
the unique file to be created atomically
file
)

Overrides org.eclipse.jgit.util.FS.createNewFileAtomic.

Create a new file.

protected File
discoverGitExe()

Implements abstract org.eclipse.jgit.util.FS.discoverGitExe.

Discover the path to the Git executable.

public FS.Attributes
getAttributes(File
a java.io.File object.
path
)

Overrides org.eclipse.jgit.util.FS.getAttributes.

Get the file attributes we care for.

public boolean
isCaseSensitive()

Implements abstract org.eclipse.jgit.util.FS.isCaseSensitive.

Is this file system case sensitive

public FS
newInstance()

Implements abstract org.eclipse.jgit.util.FS.newInstance.

Create a new instance of the same type of FS.

public File
normalize(File
a java.io.File object.
file
)

Overrides org.eclipse.jgit.util.FS.normalize.

Normalize the unicode path to composed form.

public String
normalize(String
path name
name
)

Overrides org.eclipse.jgit.util.FS.normalize.

Normalize the unicode path to composed form.

private static int

Returns:

mask returned from running umask command in shell.
readUmask
()

public boolean
retryFailedLockFileCommit()

Implements abstract org.eclipse.jgit.util.FS.retryFailedLockFileCommit.

Does this file system have problems with atomic renames?

public ProcessResult
runHookIfPresent(Repository
The repository for which a hook should be run.
repository
,
String
The name of the hook to be executed.
hookName
,
String[]
Arguments to pass to this hook. Cannot be null, but can be an empty array.
args
,
OutputStream
A print stream on which to redirect the hook's stdout. Can be null, in which case the hook's standard output will be lost.
outRedirect
,
OutputStream
A print stream on which to redirect the hook's stderr. Can be null, in which case the hook's standard error will be lost.
errRedirect
,
String
A string to pass on to the standard input of the hook. May be null.
stdinArgs
)

Overrides org.eclipse.jgit.util.FS.runHookIfPresent.

Checks whether the given hook is defined for the given repository, then runs it with the given arguments.

public ProcessBuilder
runInShell(String
command to execute. This string should originate from the end-user, and thus is platform specific.
cmd
,
String[]
arguments to pass to command. These should be protected from shell evaluation.
args
)

Implements abstract org.eclipse.jgit.util.FS.runInShell.

Initialize a ProcessBuilder to run a command using the system shell.

public boolean
setExecute(File
path to modify the executable status of.
f
,
boolean
true to enable execution; false to disable it.
canExecute
)

Implements abstract org.eclipse.jgit.util.FS.setExecute.

Set a file to be executable by the user.

public void
setHidden(File
a java.io.File object.
path
,
boolean
whether to set the file hidden
hidden
)

Overrides org.eclipse.jgit.util.FS.setHidden.

Set the hidden attribute for file whose name starts with a period.

public void
setUmask(int
mask to apply when creating files.
umask
)

Set the umask, overriding any value observed from the shell.

pack-priv String
shellQuote(String
the String to quote
cmd
)

Overrides org.eclipse.jgit.util.FS.shellQuote.

Quote a string (such as a file system path obtained from a Java File or Path object) such that it can be passed as first argument to runInShell(String, String[]).

public boolean
supportsAtomicCreateNewFile()

Overrides org.eclipse.jgit.util.FS.supportsAtomicCreateNewFile.

Does this file system support atomic file creation via java.io.File#createNewFile()?

public boolean
supportsExecute()

Implements abstract org.eclipse.jgit.util.FS.supportsExecute.

Does this operating system and JRE support the execute flag on files?

private static FS.LockToken
token(boolean created, Path p)

private int
private static String
Inherited from org.eclipse.jgit.util.FS:
createSymLinkdeletedetectdetectdiscoverGitSystemConfigexecuteexistsfileAttributesfindHookgetCommonDirgetFileStoreAttributesgetGitSystemConfiginternalRunHookIfPresentisDirectoryisFileisHiddenisSymLinklastModifiedInstantlastModifiedInstantlengthlistreadPipereadPipereadSymLinkrelativizeresolveresolveGrandparentFilerunHookIfPresentrunProcessrunProcesssearchPathsetGitSystemConfigsetLastModifiedsetUserHomesupportsSymlinksuserHomeuserHomeImpl

Field Detail

DEFAULT_GIT_LOCATIONback to summary
private static final String DEFAULT_GIT_LOCATION
DEFAULT_UMASKback to summary
private static final int DEFAULT_UMASK
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jgit.util.FS.LOG.

supportsAtomicFileCreationback to summary
private volatile FS_POSIX.AtomicFileCreation supportsAtomicFileCreation
umaskback to summary
private volatile int umask

Constructor Detail

FS_POSIXback to summary
protected FS_POSIX()

Default constructor.

FS_POSIXback to summary
protected FS_POSIX(FS src)

Constructor

Parameters
src:FS

FS to copy some settings from

Method Detail

applyback to summary
private static void apply(Set<PosixFilePermission> set, int umask, PosixFilePermission perm, int test)
canExecuteback to summary
public boolean canExecute(File f)

Implements abstract org.eclipse.jgit.util.FS.canExecute.

Doc from org.eclipse.jgit.util.FS.canExecute.

Determine if the file is executable (or not).

Not all platforms and JREs support executable flags on files. If the feature is unsupported this method will always return false.

If the platform supports symbolic links and f is a symbolic link this method returns false, rather than the state of the executable flags on the target file.

Parameters
f:File

abstract path to test.

Returns:boolean

true if the file is believed to be executable by the user.

Annotations
@Override
createNewFileAtomicback to summary
public FS.LockToken createNewFileAtomic(File file) throws IOException

Overrides org.eclipse.jgit.util.FS.createNewFileAtomic.

Doc from org.eclipse.jgit.util.FS.createNewFileAtomic.

Create a new file. See java.io.File#createNewFile(). Subclasses of this class may take care to provide a safe implementation for this even if supportsAtomicCreateNewFile() is false

An implementation of the File#createNewFile() semantics which can create a unique file atomically also on NFS. If the config option core.supportsAtomicCreateNewFile = true (which is the default) then simply Files#createFile() is called. But if core.supportsAtomicCreateNewFile = false then after successful creation of the lock file a hard link to that lock file is created and the attribute nlink of the lock file is checked to be 2. If multiple clients manage to create the same lock file nlink would be greater than 2 showing the error. The hard link needs to be retained until the corresponding file is no longer needed in order to prevent that another process can create the same file concurrently using another NFS client which might not yet see the file due to caching.

Parameters
file:File

the unique file to be created atomically

Returns:FS.LockToken

LockToken this lock token must be held until the file is no longer needed

Annotations
@Override
Exceptions
IOException:
if an IO error occurred
Since
5.0
See Also
https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html
discoverGitExeback to summary
protected File discoverGitExe()

Implements abstract org.eclipse.jgit.util.FS.discoverGitExe.

Doc from org.eclipse.jgit.util.FS.discoverGitExe.

Discover the path to the Git executable.

Returns:File

the path to the Git executable or null if it cannot be determined.

Annotations
@Override
getAttributesback to summary
public FS.Attributes getAttributes(File path)

Overrides org.eclipse.jgit.util.FS.getAttributes.

Doc from org.eclipse.jgit.util.FS.getAttributes.

Get the file attributes we care for.

Parameters
path:File

a java.io.File object.

Returns:FS.Attributes

the file attributes we care for.

Annotations
@Override
isCaseSensitiveback to summary
public boolean isCaseSensitive()

Implements abstract org.eclipse.jgit.util.FS.isCaseSensitive.

Doc from org.eclipse.jgit.util.FS.isCaseSensitive.

Is this file system case sensitive

Returns:boolean

true if this implementation is case sensitive

Annotations
@Override
newInstanceback to summary
public FS newInstance()

Implements abstract org.eclipse.jgit.util.FS.newInstance.

Doc from org.eclipse.jgit.util.FS.newInstance.

Create a new instance of the same type of FS.

Returns:FS

a new instance of the same type of FS.

Annotations
@Override
normalizeback to summary
public File normalize(File file)

Overrides org.eclipse.jgit.util.FS.normalize.

Doc from org.eclipse.jgit.util.FS.normalize.

Normalize the unicode path to composed form.

Parameters
file:File

a java.io.File object.

Returns:File

NFC-format File

Annotations
@Override
normalizeback to summary
public String normalize(String name)

Overrides org.eclipse.jgit.util.FS.normalize.

Doc from org.eclipse.jgit.util.FS.normalize.

Normalize the unicode path to composed form.

Parameters
name:String

path name

Returns:String

NFC-format string

Annotations
@Override
readUmaskback to summary
private static int readUmask()
Returns:int

mask returned from running umask command in shell.

retryFailedLockFileCommitback to summary
public boolean retryFailedLockFileCommit()

Implements abstract org.eclipse.jgit.util.FS.retryFailedLockFileCommit.

Doc from org.eclipse.jgit.util.FS.retryFailedLockFileCommit.

Does this file system have problems with atomic renames?

Returns:boolean

true if the caller should retry a failed rename of a lock file.

Annotations
@Override
runHookIfPresentback to summary
public ProcessResult runHookIfPresent(Repository repository, String hookName, String[] args, OutputStream outRedirect, OutputStream errRedirect, String stdinArgs) throws JGitInternalException

Overrides org.eclipse.jgit.util.FS.runHookIfPresent.

Doc from org.eclipse.jgit.util.FS.runHookIfPresent.

Checks whether the given hook is defined for the given repository, then runs it with the given arguments.

Parameters
repository:Repository

The repository for which a hook should be run.

hookName:String

The name of the hook to be executed.

args:String[]

Arguments to pass to this hook. Cannot be null, but can be an empty array.

outRedirect:OutputStream

A print stream on which to redirect the hook's stdout. Can be null, in which case the hook's standard output will be lost.

errRedirect:OutputStream

A print stream on which to redirect the hook's stderr. Can be null, in which case the hook's standard error will be lost.

stdinArgs:String

A string to pass on to the standard input of the hook. May be null.

Returns:ProcessResult

The ProcessResult describing this hook's execution.

Annotations
@Override
Exceptions
JGitInternalException:
if we fail to run the hook somehow. Causes may include an interrupted process or I/O errors.
runInShellback to summary
public ProcessBuilder runInShell(String cmd, String[] args)

Implements abstract org.eclipse.jgit.util.FS.runInShell.

Doc from org.eclipse.jgit.util.FS.runInShell.

Initialize a ProcessBuilder to run a command using the system shell.

Parameters
cmd:String

command to execute. This string should originate from the end-user, and thus is platform specific.

args:String[]

arguments to pass to command. These should be protected from shell evaluation.

Returns:ProcessBuilder

a partially completed process builder. Caller should finish populating directory, environment, and then start the process.

Annotations
@Override
setExecuteback to summary
public boolean setExecute(File f, boolean canExecute)

Implements abstract org.eclipse.jgit.util.FS.setExecute.

Doc from org.eclipse.jgit.util.FS.setExecute.

Set a file to be executable by the user.

Not all platforms and JREs support executable flags on files. If the feature is unsupported this method will always return false and no changes will be made to the file specified.

Parameters
f:File

path to modify the executable status of.

canExecute:boolean

true to enable execution; false to disable it.

Returns:boolean

true if the change succeeded; false otherwise.

Annotations
@Override
setHiddenback to summary
public void setHidden(File path, boolean hidden) throws IOException

Overrides org.eclipse.jgit.util.FS.setHidden.

Doc from org.eclipse.jgit.util.FS.setHidden.

Set the hidden attribute for file whose name starts with a period.

Parameters
path:File

a java.io.File object.

hidden:boolean

whether to set the file hidden

Annotations
@Override
Exceptions
IOException:
if an IO error occurred
setUmaskback to summary
public void setUmask(int umask)

Set the umask, overriding any value observed from the shell.

Parameters
umask:int

mask to apply when creating files.

Since
4.0
shellQuoteback to summary
pack-priv String shellQuote(String cmd)

Overrides org.eclipse.jgit.util.FS.shellQuote.

Doc from org.eclipse.jgit.util.FS.shellQuote.

Quote a string (such as a file system path obtained from a Java File or Path object) such that it can be passed as first argument to runInShell(String, String[]).

This default implementation returns the string unchanged.

Parameters
cmd:String

the String to quote

Returns:String

the quoted string

Annotations
@Override
supportsAtomicCreateNewFileback to summary
public boolean supportsAtomicCreateNewFile()

Overrides org.eclipse.jgit.util.FS.supportsAtomicCreateNewFile.

Doc from org.eclipse.jgit.util.FS.supportsAtomicCreateNewFile.

Does this file system support atomic file creation via java.io.File#createNewFile()? In certain environments (e.g. on NFS) it is not guaranteed that when two file system clients run createNewFile() in parallel only one will succeed. In such cases both clients may think they created a new file.

Returns:boolean

true if this implementation support atomic creation of new Files by java.io.File#createNewFile()

Annotations
@Override
supportsExecuteback to summary
public boolean supportsExecute()

Implements abstract org.eclipse.jgit.util.FS.supportsExecute.

Doc from org.eclipse.jgit.util.FS.supportsExecute.

Does this operating system and JRE support the execute flag on files?

Returns:boolean

true if this implementation can provide reasonably accurate executable bit information; false otherwise.

Annotations
@Override
tokenback to summary
private static FS.LockToken token(boolean created, Path p)
umaskback to summary
private int umask()
uniqueLinkPathback to summary
private static String uniqueLinkPath(File file)
org.eclipse.jgit.util back to summary

private final Enum FS_POSIX.AtomicFileCreation

extends Enum<FS_POSIX.AtomicFileCreation>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FS_POSIX.AtomicFileCreation
public static final FS_POSIX.AtomicFileCreation
public static final FS_POSIX.AtomicFileCreation

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FS_POSIX.AtomicFileCreation
public static FS_POSIX.AtomicFileCreation[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NOT_SUPPORTEDback to summary
public static final FS_POSIX.AtomicFileCreation NOT_SUPPORTED
SUPPORTEDback to summary
public static final FS_POSIX.AtomicFileCreation SUPPORTED
UNDEFINEDback to summary
public static final FS_POSIX.AtomicFileCreation UNDEFINED

Constructor Detail

AtomicFileCreationback to summary
private AtomicFileCreation()

Method Detail

valueOfback to summary
public static FS_POSIX.AtomicFileCreation valueOf(String name)
valuesback to summary
public static FS_POSIX.AtomicFileCreation[] values()