git-p4.html   [plain text]


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 8.5.2" />
<title>git-p4(1)</title>
<style type="text/css">
/* Debug borders */
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
/*
  border: 1px solid red;
*/
}

body {
  margin: 1em 5% 1em 5%;
}

a {
  color: blue;
  text-decoration: underline;
}
a:visited {
  color: fuchsia;
}

em {
  font-style: italic;
  color: navy;
}

strong {
  font-weight: bold;
  color: #083194;
}

tt {
  color: navy;
}

h1, h2, h3, h4, h5, h6 {
  color: #527bbd;
  font-family: sans-serif;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

h1, h2, h3 {
  border-bottom: 2px solid silver;
}
h2 {
  padding-top: 0.5em;
}
h3 {
  float: left;
}
h3 + * {
  clear: left;
}

div.sectionbody {
  font-family: serif;
  margin-left: 0;
}

hr {
  border: 1px solid silver;
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

ul, ol, li > p {
  margin-top: 0;
}

pre {
  padding: 0;
  margin: 0;
}

span#author {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  font-size: 1.1em;
}
span#email {
}
span#revnumber, span#revdate, span#revremark {
  font-family: sans-serif;
}

div#footer {
  font-family: sans-serif;
  font-size: small;
  border-top: 2px solid silver;
  padding-top: 0.5em;
  margin-top: 4.0em;
}
div#footer-text {
  float: left;
  padding-bottom: 0.5em;
}
div#footer-badges {
  float: right;
  padding-bottom: 0.5em;
}

div#preamble {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
  margin-top: 1.0em;
  margin-bottom: 1.5em;
}
div.admonitionblock {
  margin-top: 2.0em;
  margin-bottom: 2.0em;
  margin-right: 10%;
  color: #606060;
}

div.content { /* Block element content. */
  padding: 0;
}

/* Block element titles. */
div.title, caption.title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  text-align: left;
  margin-top: 1.0em;
  margin-bottom: 0.5em;
}
div.title + * {
  margin-top: 0;
}

td div.title:first-child {
  margin-top: 0.0em;
}
div.content div.title:first-child {
  margin-top: 0.0em;
}
div.content + div.title {
  margin-top: 0.0em;
}

div.sidebarblock > div.content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}

div.listingblock > div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock, div.verseblock {
  padding-left: 1.0em;
  margin-left: 1.0em;
  margin-right: 10%;
  border-left: 5px solid #dddddd;
  color: #777777;
}

div.quoteblock > div.attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock > div.content {
  white-space: pre;
}
div.verseblock > div.attribution {
  padding-top: 0.75em;
  text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
  text-align: left;
}

div.admonitionblock .icon {
  vertical-align: top;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: underline;
  color: #527bbd;
  padding-right: 0.5em;
}
div.admonitionblock td.content {
  padding-left: 0.5em;
  border-left: 3px solid #dddddd;
}

div.exampleblock > div.content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; }
a.image:visited { color: white; }

dl {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
dt {
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: normal;
  color: navy;
}
dd > *:first-child {
  margin-top: 0.1em;
}

ul, ol {
    list-style-position: outside;
}
ol.arabic {
  list-style-type: decimal;
}
ol.loweralpha {
  list-style-type: lower-alpha;
}
ol.upperalpha {
  list-style-type: upper-alpha;
}
ol.lowerroman {
  list-style-type: lower-roman;
}
ol.upperroman {
  list-style-type: upper-roman;
}

div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
}

div.tableblock > table {
  border: 3px solid #527bbd;
}
thead, p.table.header {
  font-family: sans-serif;
  font-weight: bold;
}
tfoot {
  font-weight: bold;
}
td > div.verse {
  white-space: pre;
}
p.table {
  margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
  border-style: none;
}
div.tableblock > table[frame="hsides"] {
  border-left-style: none;
  border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
  border-top-style: none;
  border-bottom-style: none;
}


div.hdlist {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
div.hdlist tr {
  padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
  font-weight: bold;
}
td.hdlist1 {
  vertical-align: top;
  font-style: normal;
  padding-right: 0.8em;
  color: navy;
}
td.hdlist2 {
  vertical-align: top;
}
div.hdlist.compact tr {
  margin: 0;
  padding-bottom: 0;
}

.comment {
  background: yellow;
}

.footnote, .footnoteref {
  font-size: 0.8em;
}

span.footnote, span.footnoteref {
  vertical-align: super;
}

#footnotes {
  margin: 20px 0 20px 0;
  padding: 7px 0 0 0;
}

#footnotes div.footnote {
  margin: 0 0 5px 0;
}

#footnotes hr {
  border: none;
  border-top: 1px solid silver;
  height: 1px;
  text-align: left;
  margin-left: 0;
  width: 20%;
  min-width: 100px;
}


@media print {
  div#footer-badges { display: none; }
}

div#toc {
  margin-bottom: 2.5em;
}

div#toctitle {
  color: #527bbd;
  font-family: sans-serif;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.0em;
  margin-bottom: 0.1em;
}

div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  margin-top: 0;
  margin-bottom: 0;
}
div.toclevel2 {
  margin-left: 2em;
  font-size: 0.9em;
}
div.toclevel3 {
  margin-left: 4em;
  font-size: 0.9em;
}
div.toclevel4 {
  margin-left: 6em;
  font-size: 0.9em;
}
/* Overrides for manpage documents */
h1 {
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  border-top: 2px solid silver;
  border-bottom: 2px solid silver;
}
h2 {
  border-style: none;
}
div.sectionbody {
  margin-left: 5%;
}

@media print {
  div#toc { display: none; }
}

/* Workarounds for IE6's broken and incomplete CSS2. */

div.sidebar-content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}
div.sidebar-title, div.image-title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  margin-top: 0.0em;
  margin-bottom: 0.5em;
}

div.listingblock div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock-attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock-content {
  white-space: pre;
}
div.verseblock-attribution {
  padding-top: 0.75em;
  text-align: left;
}

div.exampleblock-content {
  border-left: 3px solid #dddddd;
  padding-left: 0.5em;
}

/* IE6 sets dynamically generated links as visited. */
div#toc a:visited { color: blue; }
</style>
<script type="text/javascript">
/*<![CDATA[*/
window.onload = function(){asciidoc.footnotes();}
var asciidoc = {  // Namespace.

/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////

/* Author: Mihai Bazon, September 2002
 * http://students.infoiasi.ro/~mishoo
 *
 * Table Of Content generator
 * Version: 0.4
 *
 * Feel free to use this script under the terms of the GNU General Public
 * License, as long as you do not remove or alter this notice.
 */

 /* modified by Troy D. Hanson, September 2006. License: GPL */
 /* modified by Stuart Rackham, 2006, 2009. License: GPL */

// toclevels = 1..4.
toc: function (toclevels) {

  function getText(el) {
    var text = "";
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
      if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
        text += i.data;
      else if (i.firstChild != null)
        text += getText(i);
    }
    return text;
  }

  function TocEntry(el, text, toclevel) {
    this.element = el;
    this.text = text;
    this.toclevel = toclevel;
  }

  function tocEntries(el, toclevels) {
    var result = new Array;
    var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
    // Function that scans the DOM tree for header elements (the DOM2
    // nodeIterator API would be a better technique but not supported by all
    // browsers).
    var iterate = function (el) {
      for (var i = el.firstChild; i != null; i = i.nextSibling) {
        if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
          var mo = re.exec(i.tagName);
          if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
            result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
          }
          iterate(i);
        }
      }
    }
    iterate(el);
    return result;
  }

  var toc = document.getElementById("toc");
  var entries = tocEntries(document.getElementById("content"), toclevels);
  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    if (entry.element.id == "")
      entry.element.id = "_toc_" + i;
    var a = document.createElement("a");
    a.href = "#" + entry.element.id;
    a.appendChild(document.createTextNode(entry.text));
    var div = document.createElement("div");
    div.appendChild(a);
    div.className = "toclevel" + entry.toclevel;
    toc.appendChild(div);
  }
  if (entries.length == 0)
    toc.parentNode.removeChild(toc);
},


/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////

/* Based on footnote generation code from:
 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
 */

footnotes: function () {
  var cont = document.getElementById("content");
  var noteholder = document.getElementById("footnotes");
  var spans = cont.getElementsByTagName("span");
  var refs = {};
  var n = 0;
  for (i=0; i<spans.length; i++) {
    if (spans[i].className == "footnote") {
      n++;
      // Use [\s\S] in place of . so multi-line matches work.
      // Because JavaScript has no s (dotall) regex flag.
      note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
      noteholder.innerHTML +=
        "<div class='footnote' id='_footnote_" + n + "'>" +
        "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
        n + "</a>. " + note + "</div>";
      spans[i].innerHTML =
        "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
        "' title='View footnote' class='footnote'>" + n + "</a>]";
      var id =spans[i].getAttribute("id");
      if (id != null) refs["#"+id] = n;
    }
  }
  if (n == 0)
    noteholder.parentNode.removeChild(noteholder);
  else {
    // Process footnoterefs.
    for (i=0; i<spans.length; i++) {
      if (spans[i].className == "footnoteref") {
        var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
        href = href.match(/#.*/)[0];  // Because IE return full URL.
        n = refs[href];
        spans[i].innerHTML =
          "[<a href='#_footnote_" + n +
          "' title='View footnote' class='footnote'>" + n + "</a>]";
      }
    }
  }
}

}
/*]]>*/
</script>
</head>
<body>
<div id="header">
<h1>
git-p4(1) Manual Page
</h1>
<h2>NAME</h2>
<div class="sectionbody">
<p>git-p4 -
   Import from and submit to Perforce repositories
</p>
</div>
</div>
<div id="content">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="verseblock">
<div class="verseblock-content"><em>git p4 clone</em> [&lt;sync options&gt;] [&lt;clone options&gt;] &lt;p4 depot path&gt;&#8230;
<em>git p4 sync</em> [&lt;sync options&gt;] [&lt;p4 depot path&gt;&#8230;]
<em>git p4 rebase</em>
<em>git p4 submit</em> [&lt;submit options&gt;] [&lt;master branch name&gt;]</div>
<div class="verseblock-attribution">
</div></div>
</div>
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph"><p>This command provides a way to interact with p4 repositories
using git.</p></div>
<div class="paragraph"><p>Create a new git repository from an existing p4 repository using
<em>git p4 clone</em>, giving it one or more p4 depot paths.  Incorporate
new commits from p4 changes with <em>git p4 sync</em>.  The <em>sync</em> command
is also used to include new branches from other p4 depot paths.
Submit git changes back to p4 using <em>git p4 submit</em>.  The command
<em>git p4 rebase</em> does a sync plus rebases the current branch onto
the updated p4 remote branch.</p></div>
</div>
<h2 id="_example">EXAMPLE</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
Clone a repository:
</p>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 clone //depot/path/project</tt></pre>
</div></div>
</li>
<li>
<p>
Do some work in the newly created git repository:
</p>
<div class="listingblock">
<div class="content">
<pre><tt>$ cd project
$ vi foo.h
$ git commit -a -m "edited foo.h"</tt></pre>
</div></div>
</li>
<li>
<p>
Update the git repository with recent changes from p4, rebasing your
  work on top:
</p>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 rebase</tt></pre>
</div></div>
</li>
<li>
<p>
Submit your commits back to p4:
</p>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 submit</tt></pre>
</div></div>
</li>
</ul></div>
</div>
<h2 id="_commands">COMMANDS</h2>
<div class="sectionbody">
<h3 id="_clone">Clone</h3><div style="clear:left"></div>
<div class="paragraph"><p>Generally, <em>git p4 clone</em> is used to create a new git directory
from an existing p4 repository:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 clone //depot/path/project</tt></pre>
</div></div>
<div class="paragraph"><p>This:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
Creates an empty git repository in a subdirectory called <em>project</em>.
</p>
</li>
<li>
<p>
Imports the full contents of the head revision from the given p4
depot path into a single commit in the git branch <em>refs/remotes/p4/master</em>.
</p>
</li>
<li>
<p>
Creates a local branch, <em>master</em> from this remote and checks it out.
</p>
</li>
</ol></div>
<div class="paragraph"><p>To reproduce the entire p4 history in git, use the <em>@all</em> modifier on
the depot path:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 clone //depot/path/project@all</tt></pre>
</div></div>
<h3 id="_sync">Sync</h3><div style="clear:left"></div>
<div class="paragraph"><p>As development continues in the p4 repository, those changes can
be included in the git repository using:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 sync</tt></pre>
</div></div>
<div class="paragraph"><p>This command finds new changes in p4 and imports them as git commits.</p></div>
<div class="paragraph"><p>P4 repositories can be added to an existing git repository using
<em>git p4 sync</em> too:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ mkdir repo-git
$ cd repo-git
$ git init
$ git p4 sync //path/in/your/perforce/depot</tt></pre>
</div></div>
<div class="paragraph"><p>This imports the specified depot into
<em>refs/remotes/p4/master</em> in an existing git repository.  The
<em>--branch</em> option can be used to specify a different branch to
be used for the p4 content.</p></div>
<div class="paragraph"><p>If a git repository includes branches <em>refs/remotes/origin/p4</em>, these
will be fetched and consulted first during a <em>git p4 sync</em>.  Since
importing directly from p4 is considerably slower than pulling changes
from a git remote, this can be useful in a multi-developer environment.</p></div>
<h3 id="_rebase">Rebase</h3><div style="clear:left"></div>
<div class="paragraph"><p>A common working pattern is to fetch the latest changes from the p4 depot
and merge them with local uncommitted changes.  Often, the p4 repository
is the ultimate location for all code, thus a rebase workflow makes
sense.  This command does <em>git p4 sync</em> followed by <em>git rebase</em> to move
local commits on top of updated p4 changes.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 rebase</tt></pre>
</div></div>
<h3 id="_submit">Submit</h3><div style="clear:left"></div>
<div class="paragraph"><p>Submitting changes from a git repository back to the p4 repository
requires a separate p4 client workspace.  This should be specified
using the <em>P4CLIENT</em> environment variable or the git configuration
variable <em>git-p4.client</em>.  The p4 client must exist, but the client root
will be created and populated if it does not already exist.</p></div>
<div class="paragraph"><p>To submit all changes that are in the current git branch but not in
the <em>p4/master</em> branch, use:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 submit</tt></pre>
</div></div>
<div class="paragraph"><p>To specify a branch other than the current one, use:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git p4 submit topicbranch</tt></pre>
</div></div>
<div class="paragraph"><p>The upstream reference is generally <em>refs/remotes/p4/master</em>, but can
be overridden using the <em>--origin=</em> command-line option.</p></div>
<div class="paragraph"><p>The p4 changes will be created as the user invoking <em>git p4 submit</em>. The
<em>--preserve-user</em> option will cause ownership to be modified
according to the author of the git commit.  This option requires admin
privileges in p4, which can be granted using <em>p4 protect</em>.</p></div>
</div>
<h2 id="_options">OPTIONS</h2>
<div class="sectionbody">
<h3 id="_general_options">General options</h3><div style="clear:left"></div>
<div class="paragraph"><p>All commands except clone accept these options.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--git-dir &lt;dir&gt;
</dt>
<dd>
<p>
        Set the <em>GIT_DIR</em> environment variable.  See <a href="git.html">git(1)</a>.
</p>
</dd>
<dt class="hdlist1">
--verbose
</dt>
<dd>
<p>
        Provide more progress information.
</p>
</dd>
</dl></div>
<h3 id="_sync_options">Sync options</h3><div style="clear:left"></div>
<div class="paragraph"><p>These options can be used in the initial <em>clone</em> as well as in
subsequent <em>sync</em> operations.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--branch &lt;branch&gt;
</dt>
<dd>
<p>
        Import changes into given branch.  If the branch starts with
        <em>refs/</em>, it will be used as is, otherwise the path <em>refs/heads/</em>
        will be prepended.  The default branch is <em>master</em>.  If used
        with an initial clone, no HEAD will be checked out.
</p>
<div class="paragraph"><p>This example imports a new remote "p4/proj2" into an existing
git repository:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>    $ git init
    $ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2</tt></pre>
</div></div>
</dd>
<dt class="hdlist1">
--detect-branches
</dt>
<dd>
<p>
        Use the branch detection algorithm to find new paths in p4.  It is
        documented below in "BRANCH DETECTION".
</p>
</dd>
<dt class="hdlist1">
--changesfile &lt;file&gt;
</dt>
<dd>
<p>
        Import exactly the p4 change numbers listed in <em>file</em>, one per
        line.  Normally, <em>git p4</em> inspects the current p4 repository
        state and detects the changes it should import.
</p>
</dd>
<dt class="hdlist1">
--silent
</dt>
<dd>
<p>
        Do not print any progress information.
</p>
</dd>
<dt class="hdlist1">
--detect-labels
</dt>
<dd>
<p>
        Query p4 for labels associated with the depot paths, and add
        them as tags in git. Limited usefulness as only imports labels
        associated with new changelists. Deprecated.
</p>
</dd>
<dt class="hdlist1">
--import-labels
</dt>
<dd>
<p>
        Import labels from p4 into git.
</p>
</dd>
<dt class="hdlist1">
--import-local
</dt>
<dd>
<p>
        By default, p4 branches are stored in <em>refs/remotes/p4/</em>,
        where they will be treated as remote-tracking branches by
        <a href="git-branch.html">git-branch(1)</a> and other commands.  This option instead
        puts p4 branches in <em>refs/heads/p4/</em>.  Note that future
        sync operations must specify <em>--import-local</em> as well so that
        they can find the p4 branches in refs/heads.
</p>
</dd>
<dt class="hdlist1">
--max-changes &lt;n&gt;
</dt>
<dd>
<p>
        Limit the number of imported changes to <em>n</em>.  Useful to
        limit the amount of history when using the <em>@all</em> p4 revision
        specifier.
</p>
</dd>
<dt class="hdlist1">
--keep-path
</dt>
<dd>
<p>
        The mapping of file names from the p4 depot path to git, by
        default, involves removing the entire depot path.  With this
        option, the full p4 depot path is retained in git.  For example,
        path <em>//depot/main/foo/bar.c</em>, when imported from
        <em>//depot/main/</em>, becomes <em>foo/bar.c</em>.  With <em>--keep-path</em>, the
        git path is instead <em>depot/main/foo/bar.c</em>.
</p>
</dd>
<dt class="hdlist1">
--use-client-spec
</dt>
<dd>
<p>
        Use a client spec to find the list of interesting files in p4.
        See the "CLIENT SPEC" section below.
</p>
</dd>
</dl></div>
<h3 id="_clone_options">Clone options</h3><div style="clear:left"></div>
<div class="paragraph"><p>These options can be used in an initial <em>clone</em>, along with the <em>sync</em>
options described above.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--destination &lt;directory&gt;
</dt>
<dd>
<p>
        Where to create the git repository.  If not provided, the last
        component in the p4 depot path is used to create a new
        directory.
</p>
</dd>
<dt class="hdlist1">
--bare
</dt>
<dd>
<p>
        Perform a bare clone.  See <a href="git-clone.html">git-clone(1)</a>.
</p>
</dd>
<dt class="hdlist1">
-/ &lt;path&gt;
</dt>
<dd>
<p>
        Exclude selected depot paths when cloning.
</p>
</dd>
</dl></div>
<h3 id="_submit_options">Submit options</h3><div style="clear:left"></div>
<div class="paragraph"><p>These options can be used to modify <em>git p4 submit</em> behavior.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--origin &lt;commit&gt;
</dt>
<dd>
<p>
        Upstream location from which commits are identified to submit to
        p4.  By default, this is the most recent p4 commit reachable
        from <em>HEAD</em>.
</p>
</dd>
<dt class="hdlist1">
-M
</dt>
<dd>
<p>
        Detect renames.  See <a href="git-diff.html">git-diff(1)</a>.  Renames will be
        represented in p4 using explicit <em>move</em> operations.  There
        is no corresponding option to detect copies, but there are
        variables for both moves and copies.
</p>
</dd>
<dt class="hdlist1">
--preserve-user
</dt>
<dd>
<p>
        Re-author p4 changes before submitting to p4.  This option
        requires p4 admin privileges.
</p>
</dd>
<dt class="hdlist1">
--export-labels
</dt>
<dd>
<p>
        Export tags from git as p4 labels. Tags found in git are applied
        to the perforce working directory.
</p>
</dd>
</dl></div>
<h3 id="_rebase_options">Rebase options</h3><div style="clear:left"></div>
<div class="paragraph"><p>These options can be used to modify <em>git p4 rebase</em> behavior.</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
--import-labels
</dt>
<dd>
<p>
        Import p4 labels.
</p>
</dd>
</dl></div>
</div>
<h2 id="_depot_path_syntax">DEPOT PATH SYNTAX</h2>
<div class="sectionbody">
<div class="paragraph"><p>The p4 depot path argument to <em>git p4 sync</em> and <em>git p4 clone</em> can
be one or more space-separated p4 depot paths, with an optional
p4 revision specifier on the end:</p></div>
<div class="dlist"><dl>
<dt class="hdlist1">
"//depot/my/project"
</dt>
<dd>
<p>
    Import one commit with all files in the <em>#head</em> change under that tree.
</p>
</dd>
<dt class="hdlist1">
"//depot/my/project@all"
</dt>
<dd>
<p>
    Import one commit for each change in the history of that depot path.
</p>
</dd>
<dt class="hdlist1">
"//depot/my/project@1,6"
</dt>
<dd>
<p>
    Import only changes 1 through 6.
</p>
</dd>
<dt class="hdlist1">
"//depot/proj1@all //depot/proj2@all"
</dt>
<dd>
<p>
    Import all changes from both named depot paths into a single
    repository.  Only files below these directories are included.
    There is not a subdirectory in git for each "proj1" and "proj2".
    You must use the <em>--destination</em> option when specifying more
    than one depot path.  The revision specifier must be specified
    identically on each depot path.  If there are files in the
    depot paths with the same name, the path with the most recently
    updated version of the file is the one that appears in git.
</p>
</dd>
</dl></div>
<div class="paragraph"><p>See <em>p4 help revisions</em> for the full syntax of p4 revision specifiers.</p></div>
</div>
<h2 id="_client_spec">CLIENT SPEC</h2>
<div class="sectionbody">
<div class="paragraph"><p>The p4 client specification is maintained with the <em>p4 client</em> command
and contains among other fields, a View that specifies how the depot
is mapped into the client repository.  The <em>clone</em> and <em>sync</em> commands
can consult the client spec when given the <em>--use-client-spec</em> option or
when the useClientSpec variable is true.  After <em>git p4 clone</em>, the
useClientSpec variable is automatically set in the repository
configuration file.  This allows future <em>git p4 submit</em> commands to
work properly; the submit command looks only at the variable and does
not have a command-line option.</p></div>
<div class="paragraph"><p>The full syntax for a p4 view is documented in <em>p4 help views</em>.  <em>Git p4</em>
knows only a subset of the view syntax.  It understands multi-line
mappings, overlays with <em>+</em>, exclusions with <em>-</em> and double-quotes
around whitespace.  Of the possible wildcards, <em>git p4</em> only handles
<em>&#8230;</em>, and only when it is at the end of the path.  <em>Git p4</em> will complain
if it encounters an unhandled wildcard.</p></div>
<div class="paragraph"><p>Bugs in the implementation of overlap mappings exist.  If multiple depot
paths map through overlays to the same location in the repository,
<em>git p4</em> can choose the wrong one.  This is hard to solve without
dedicating a client spec just for <em>git p4</em>.</p></div>
<div class="paragraph"><p>The name of the client can be given to <em>git p4</em> in multiple ways.  The
variable <em>git-p4.client</em> takes precedence if it exists.  Otherwise,
normal p4 mechanisms of determining the client are used:  environment
variable P4CLIENT, a file referenced by P4CONFIG, or the local host name.</p></div>
</div>
<h2 id="_branch_detection">BRANCH DETECTION</h2>
<div class="sectionbody">
<div class="paragraph"><p>P4 does not have the same concept of a branch as git.  Instead,
p4 organizes its content as a directory tree, where by convention
different logical branches are in different locations in the tree.
The <em>p4 branch</em> command is used to maintain mappings between
different areas in the tree, and indicate related content.  <em>git p4</em>
can use these mappings to determine branch relationships.</p></div>
<div class="paragraph"><p>If you have a repository where all the branches of interest exist as
subdirectories of a single depot path, you can use <em>--detect-branches</em>
when cloning or syncing to have <em>git p4</em> automatically find
subdirectories in p4, and to generate these as branches in git.</p></div>
<div class="paragraph"><p>For example, if the P4 repository structure is:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>//depot/main/...
//depot/branch1/...</tt></pre>
</div></div>
<div class="paragraph"><p>And "p4 branch -o branch1" shows a View line that looks like:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>//depot/main/... //depot/branch1/...</tt></pre>
</div></div>
<div class="paragraph"><p>Then this <em>git p4 clone</em> command:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>git p4 clone --detect-branches //depot@all</tt></pre>
</div></div>
<div class="paragraph"><p>produces a separate branch in <em>refs/remotes/p4/</em> for //depot/main,
called <em>master</em>, and one for //depot/branch1 called <em>depot/branch1</em>.</p></div>
<div class="paragraph"><p>However, it is not necessary to create branches in p4 to be able to use
them like branches.  Because it is difficult to infer branch
relationships automatically, a git configuration setting
<em>git-p4.branchList</em> can be used to explicitly identify branch
relationships.  It is a list of "source:destination" pairs, like a
simple p4 branch specification, where the "source" and "destination" are
the path elements in the p4 repository.  The example above relied on the
presence of the p4 branch.  Without p4 branches, the same result will
occur with:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>git config git-p4.branchList main:branch1
git p4 clone --detect-branches //depot@all</tt></pre>
</div></div>
</div>
<h2 id="_performance">PERFORMANCE</h2>
<div class="sectionbody">
<div class="paragraph"><p>The fast-import mechanism used by <em>git p4</em> creates one pack file for
each invocation of <em>git p4 sync</em>.  Normally, git garbage compression
(<a href="git-gc.html">git-gc(1)</a>) automatically compresses these to fewer pack files,
but explicit invocation of <em>git repack -adf</em> may improve performance.</p></div>
</div>
<h2 id="_configuration_variables">CONFIGURATION VARIABLES</h2>
<div class="sectionbody">
<div class="paragraph"><p>The following config settings can be used to modify <em>git p4</em> behavior.
They all are in the <em>git-p4</em> section.</p></div>
<h3 id="_general_variables">General variables</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.user
</dt>
<dd>
<p>
        User specified as an option to all p4 commands, with <em>-u &lt;user&gt;</em>.
        The environment variable <em>P4USER</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.password
</dt>
<dd>
<p>
        Password specified as an option to all p4 commands, with
        <em>-P &lt;password&gt;</em>.
        The environment variable <em>P4PASS</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.port
</dt>
<dd>
<p>
        Port specified as an option to all p4 commands, with
        <em>-p &lt;port&gt;</em>.
        The environment variable <em>P4PORT</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.host
</dt>
<dd>
<p>
        Host specified as an option to all p4 commands, with
        <em>-h &lt;host&gt;</em>.
        The environment variable <em>P4HOST</em> can be used instead.
</p>
</dd>
<dt class="hdlist1">
git-p4.client
</dt>
<dd>
<p>
        Client specified as an option to all p4 commands, with
        <em>-c &lt;client&gt;</em>, including the client spec.
</p>
</dd>
</dl></div>
<h3 id="_clone_and_sync_variables">Clone and sync variables</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.syncFromOrigin
</dt>
<dd>
<p>
        Because importing commits from other git repositories is much faster
        than importing them from p4, a mechanism exists to find p4 changes
        first in git remotes.  If branches exist under <em>refs/remote/origin/p4</em>,
        those will be fetched and used when syncing from p4.  This
        variable can be set to <em>false</em> to disable this behavior.
</p>
</dd>
<dt class="hdlist1">
git-p4.branchUser
</dt>
<dd>
<p>
        One phase in branch detection involves looking at p4 branches
        to find new ones to import.  By default, all branches are
        inspected.  This option limits the search to just those owned
        by the single user named in the variable.
</p>
</dd>
<dt class="hdlist1">
git-p4.branchList
</dt>
<dd>
<p>
        List of branches to be imported when branch detection is
        enabled.  Each entry should be a pair of branch names separated
        by a colon (:).  This example declares that both branchA and
        branchB were created from main:
</p>
<div class="listingblock">
<div class="content">
<pre><tt>git config       git-p4.branchList main:branchA
git config --add git-p4.branchList main:branchB</tt></pre>
</div></div>
</dd>
<dt class="hdlist1">
git-p4.ignoredP4Labels
</dt>
<dd>
<p>
        List of p4 labels to ignore. This is built automatically as
        unimportable labels are discovered.
</p>
</dd>
<dt class="hdlist1">
git-p4.importLabels
</dt>
<dd>
<p>
        Import p4 labels into git, as per --import-labels.
</p>
</dd>
<dt class="hdlist1">
git-p4.labelImportRegexp
</dt>
<dd>
<p>
        Only p4 labels matching this regular expression will be imported. The
        default value is <em>[a-zA-Z0-9_\-.]+$</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.useClientSpec
</dt>
<dd>
<p>
        Specify that the p4 client spec should be used to identify p4
        depot paths of interest.  This is equivalent to specifying the
        option <em>--use-client-spec</em>.  See the "CLIENT SPEC" section above.
        This variable is a boolean, not the name of a p4 client.
</p>
</dd>
</dl></div>
<h3 id="_submit_variables">Submit variables</h3><div style="clear:left"></div>
<div class="dlist"><dl>
<dt class="hdlist1">
git-p4.detectRenames
</dt>
<dd>
<p>
        Detect renames.  See <a href="git-diff.html">git-diff(1)</a>.  This can be true,
        false, or a score as expected by <em>git diff -M</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.detectCopies
</dt>
<dd>
<p>
        Detect copies.  See <a href="git-diff.html">git-diff(1)</a>.  This can be true,
        false, or a score as expected by <em>git diff -C</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.detectCopiesHarder
</dt>
<dd>
<p>
        Detect copies harder.  See <a href="git-diff.html">git-diff(1)</a>.  A boolean.
</p>
</dd>
<dt class="hdlist1">
git-p4.preserveUser
</dt>
<dd>
<p>
        On submit, re-author changes to reflect the git author,
        regardless of who invokes <em>git p4 submit</em>.
</p>
</dd>
<dt class="hdlist1">
git-p4.allowMissingP4Users
</dt>
<dd>
<p>
        When <em>preserveUser</em> is true, <em>git p4</em> normally dies if it
        cannot find an author in the p4 user map.  This setting
        submits the change regardless.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipSubmitEdit
</dt>
<dd>
<p>
        The submit process invokes the editor before each p4 change
        is submitted.  If this setting is true, though, the editing
        step is skipped.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipSubmitEditCheck
</dt>
<dd>
<p>
        After editing the p4 change message, <em>git p4</em> makes sure that
        the description really was changed by looking at the file
        modification time.  This option disables that test.
</p>
</dd>
<dt class="hdlist1">
git-p4.allowSubmit
</dt>
<dd>
<p>
        By default, any branch can be used as the source for a <em>git p4
        submit</em> operation.  This configuration variable, if set, permits only
        the named branches to be used as submit sources.  Branch names
        must be the short names (no "refs/heads/"), and should be
        separated by commas (","), with no spaces.
</p>
</dd>
<dt class="hdlist1">
git-p4.skipUserNameCheck
</dt>
<dd>
<p>
        If the user running <em>git p4 submit</em> does not exist in the p4
        user map, <em>git p4</em> exits.  This option can be used to force
        submission regardless.
</p>
</dd>
<dt class="hdlist1">
git-p4.attemptRCSCleanup
</dt>
<dd>
<p>
        If enabled, <em>git p4 submit</em> will attempt to cleanup RCS keywords
        ($Header$, etc). These would otherwise cause merge conflicts and prevent
        the submit going ahead. This option should be considered experimental at
        present.
</p>
</dd>
<dt class="hdlist1">
git-p4.exportLabels
</dt>
<dd>
<p>
        Export git tags to p4 labels, as per --export-labels.
</p>
</dd>
<dt class="hdlist1">
git-p4.labelExportRegexp
</dt>
<dd>
<p>
        Only p4 labels matching this regular expression will be exported. The
        default value is <em>[a-zA-Z0-9_\-.]+$</em>.
</p>
</dd>
</dl></div>
</div>
<h2 id="_implementation_details">IMPLEMENTATION DETAILS</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
Changesets from p4 are imported using git fast-import.
</p>
</li>
<li>
<p>
Cloning or syncing does not require a p4 client; file contents are
  collected using <em>p4 print</em>.
</p>
</li>
<li>
<p>
Submitting requires a p4 client, which is not in the same location
  as the git repository.  Patches are applied, one at a time, to
  this p4 client and submitted from there.
</p>
</li>
<li>
<p>
Each commit imported by <em>git p4</em> has a line at the end of the log
  message indicating the p4 depot location and change number.  This
  line is used by later <em>git p4 sync</em> operations to know which p4
  changes are new.
</p>
</li>
</ul></div>
</div>
</div>
<div id="footnotes"><hr /></div>
<div id="footer">
<div id="footer-text">
Last updated 2012-07-15 22:27:35 PDT
</div>
</div>
</body>
</html>