Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Reference | 2025.1

# p4 attribute

Set per-revision attributes on revisions: name-value pairs that associate metadata with the file revision.

## Syntax

    p4 [g-opts] attribute [-e -f -p] -n name [-v value [-T0 | -T1]] files ...
    p4 [g-opts] attribute [-e -f -p [-T0 | -T1]] -i -n name file
    p4 attribute [-f -p [-T0 | -T1]] -I filename -n name file

Syntax conventions

## Description

The `p4 attribute` command sets per-revision attributes on file revisions. An attribute is special metadata that a user or an application associates with a file revision that is separate from the metadata Information that P4 Server maintains, such as who created file revisions in the depot, whether the file is a 'lazy copy,, the current state of client workspaces, protections, groups, users, labels, streams, and branches. Metadata is stored in the server database and is separate from the 'archive files' that users submit from their client workspace into the depot. that P4 generates. For example:

- `status` of a file, such as `work-in-progress`, `completed`, or `approved`

- `thumbnail` preview image that is associated with an image file, `description` of an image, `size` of the thumbnail metadata

- `type` of a gif file, such as `static` or `animated`, `color` or `black-and-white`, `drawing` or `photo`

You can set any number of attributes on a file, and any number of files can have zero, one, or more of the attributes.

### Attribute values and the trait depot

Attribute values are stored in the `db.traits` table by default. If the attributes are huge, the growth of the `db.traits` table can affect the performance of checkpoints. An alternative is to store new attribute values in the depot of type `trait` instead. To do so, set the `trait.storagedepot.min` configurable to a number greater than `0`. When the size in bytes of the file's attribute value matches or exceeds the minimum set by this configurable, the file's attribute value is stored in the `trait` depot instead of the `db.traits` table.

For optimal performance, new traits with small values should be stored in the `db.traits` table, and new traits with large values should be stored in the `trait` depot. The value of `trait.storagedepot.min` should be chosen carefully because retrieval from the `trait` depot involves costly fetching from depot storage. It is recommended that the minimum size of huge data, such as thumbnails, should be chosen for this value.

## Options

`-e` | Indicates that the value is specified in hex.
`-f` | Set the attribute on submitted files. If a propagating trait is set on a submitted file, a revision specifier cannot be used, and the file must not be currently open in any workspace.
`-i` | Read an attribute value from the standard input. Only one file argument is allowed when using this option. This option supports both textual and binary content.
`-I` | Read the attribute value from a file. The file can have textual or binary content. Use this when the attribute data exceeds 250 megabytes, which might cause the command to fail with the `Rpc buffer too big` error. The following are not allow with this option: Using the `-e` option to specify the value as hex. More one file argument. Setting more than one trait value. To display attributes set with this option, use the `p4 print -T` command instead of the `p4 fstat -Oa` command because `p4 print -T` can handle larger non-encoded binary data.
`-n name` | The name of the attribute to set.
`-p` | Create a propagating attribute: an attribute whose value is passed on to subsequent revisions whenever the file is opened. Relevant commands include `p4 copy`, `p4 delete`, `p4 edit`, `p4 integrate`, `p4 reconcile`, `p4 resolve`, `p4 shelve`, `p4 submit`, and `p4 unshelve`.
`-v value` | The value of the attribute to set. To clear an attribute, omit the `-v` option. The supplied value must be text.
`-T0 | - T1` | `-T0` causes the value to be stored in the `db.traits` table, which is the implicit default. `-T1` causes the value to be stored in the `trait` depot instead of the `db.traits` table, even if the size of the attribute value is less than the size specified by the `trait.storagedepot.min` configurable. However, if `trait.storagedepot.min` is unset or set to `0`, the attribute value is stored in the `db.traits` table.
`g-opts` | See Global options.

## Usage notes

Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required
--- | --- | ---
Yes | Yes | write, or `admin` to use the `-f` option

- Multiple attributes can be set or cleared by specifying multiple `-n name` options and an equal number of corresponding `-v value` options (to set) or no `-v` options ( to clear).

## Examples

#### To assign an attribute of a file

Use the `-n` option to set the name the attribute, and use `-v` option to set the value of the attribute. Here, for revision 4 of the file named `kitten.gif`, the attribute `black-and-white` is set to the value of `true`.

This attribute value is small and indicates that the image is black-and-white instead of color.

    p4 attribute -f -n black-and-white -v true //depot/main/rel1/perl_proj/kitten.gif
    //depot/main/release1/perl_proj/kitten.gif#4 - black-and-white set

### Searching for attributes

See the Examples for attributes in the p4 fstat topic.

#### To remove an attribute from a file

The omission of the `-v` option removes the attribute value from the file.

    p4 attribute -f black-and-white //depot/main/rel1/perl_proj/kitten.gif
    //depot/main/release1/perl_proj/kitten.gif#4 - black-and-white cleared

Your search for returned results