blob: 88782ec2f24d176d1f574c44d9ed3adbfde0319d [file] [log] [blame]
Junio C Hamanodb472bc2012-01-04 00:22:371<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6<meta name="generator" content="AsciiDoc 8.5.2" />
7<title>git-p4(1)</title>
8<style type="text/css">
9/* Debug borders */
10p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11/*
12 border: 1px solid red;
13*/
14}
15
16body {
17 margin: 1em 5% 1em 5%;
18}
19
20a {
21 color: blue;
22 text-decoration: underline;
23}
24a:visited {
25 color: fuchsia;
26}
27
28em {
29 font-style: italic;
30 color: navy;
31}
32
33strong {
34 font-weight: bold;
35 color: #083194;
36}
37
38tt {
39 color: navy;
40}
41
42h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
48}
49
50h1, h2, h3 {
51 border-bottom: 2px solid silver;
52}
53h2 {
54 padding-top: 0.5em;
55}
56h3 {
57 float: left;
58}
59h3 + * {
60 clear: left;
61}
62
63div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
66}
67
68hr {
69 border: 1px solid silver;
70}
71
72p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
75}
76
77ul, ol, li > p {
78 margin-top: 0;
79}
80
81pre {
82 padding: 0;
83 margin: 0;
84}
85
86span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
91}
92span#email {
93}
94span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
96}
97
98div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
104}
105div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
108}
109div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
112}
113
114div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
117}
118div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120div.admonitionblock {
121 margin-top: 1.0em;
122 margin-bottom: 1.5em;
123}
124div.admonitionblock {
125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
129}
130
131div.content { /* Block element content. */
132 padding: 0;
133}
134
135/* Block element titles. */
136div.title, caption.title {
137 color: #527bbd;
138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
143}
144div.title + * {
145 margin-top: 0;
146}
147
148td div.title:first-child {
149 margin-top: 0.0em;
150}
151div.content div.title:first-child {
152 margin-top: 0.0em;
153}
154div.content + div.title {
155 margin-top: 0.0em;
156}
157
158div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
162}
163
164div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
168}
169
170div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
173 margin-right: 10%;
174 border-left: 5px solid #dddddd;
175 color: #777777;
176}
177
178div.quoteblock > div.attribution {
179 padding-top: 0.5em;
180 text-align: right;
181}
182
183div.verseblock > div.content {
184 white-space: pre;
185}
186div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
189}
190/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191div.verseblock + div.attribution {
192 text-align: left;
193}
194
195div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
202}
203div.admonitionblock td.content {
204 padding-left: 0.5em;
205 border-left: 3px solid #dddddd;
206}
207
208div.exampleblock > div.content {
209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
211}
212
213div.imageblock div.content { padding-left: 0; }
214span.image img { border-style: none; }
215a.image:visited { color: white; }
216
217dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
220}
221dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
224 font-style: normal;
225 color: navy;
226}
227dd > *:first-child {
228 margin-top: 0.1em;
229}
230
231ul, ol {
232 list-style-position: outside;
233}
234ol.arabic {
235 list-style-type: decimal;
236}
237ol.loweralpha {
238 list-style-type: lower-alpha;
239}
240ol.upperalpha {
241 list-style-type: upper-alpha;
242}
243ol.lowerroman {
244 list-style-type: lower-roman;
245}
246ol.upperroman {
247 list-style-type: upper-roman;
248}
249
250div.compact ul, div.compact ol,
251div.compact p, div.compact p,
252div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
255}
256
257div.tableblock > table {
258 border: 3px solid #527bbd;
259}
260thead, p.table.header {
261 font-family: sans-serif;
262 font-weight: bold;
263}
264tfoot {
265 font-weight: bold;
266}
267td > div.verse {
268 white-space: pre;
269}
270p.table {
271 margin-top: 0;
272}
273/* Because the table frame attribute is overriden by CSS in most browsers. */
274div.tableblock > table[frame="void"] {
275 border-style: none;
276}
277div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
280}
281div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
284}
285
286
287div.hdlist {
288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
290}
291div.hdlist tr {
292 padding-bottom: 15px;
293}
294dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
296}
297td.hdlist1 {
298 vertical-align: top;
299 font-style: normal;
300 padding-right: 0.8em;
301 color: navy;
302}
303td.hdlist2 {
304 vertical-align: top;
305}
306div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
309}
310
311.comment {
312 background: yellow;
313}
314
315.footnote, .footnoteref {
316 font-size: 0.8em;
317}
318
319span.footnote, span.footnoteref {
320 vertical-align: super;
321}
322
323#footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
326}
327
328#footnotes div.footnote {
329 margin: 0 0 5px 0;
330}
331
332#footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
340}
341
342
343@media print {
344 div#footer-badges { display: none; }
345}
346
347div#toc {
348 margin-bottom: 2.5em;
349}
350
351div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
358}
359
360div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
363}
364div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
367}
368div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
371}
372div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
375}
376/* Overrides for manpage documents */
377h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
382}
383h2 {
384 border-style: none;
385}
386div.sectionbody {
387 margin-left: 5%;
388}
389
390@media print {
391 div#toc { display: none; }
392}
393
394/* Workarounds for IE6's broken and incomplete CSS2. */
395
396div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
400}
401div.sidebar-title, div.image-title {
402 color: #527bbd;
403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
407}
408
409div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
413}
414
415div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
418}
419
420div.verseblock-content {
421 white-space: pre;
422}
423div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
426}
427
428div.exampleblock-content {
429 border-left: 3px solid #dddddd;
430 padding-left: 0.5em;
431}
432
433/* IE6 sets dynamically generated links as visited. */
434div#toc a:visited { color: blue; }
435</style>
436<script type="text/javascript">
437/*<![CDATA[*/
438window.onload = function(){asciidoc.footnotes();}
439var asciidoc = { // Namespace.
440
441/////////////////////////////////////////////////////////////////////
442// Table Of Contents generator
443/////////////////////////////////////////////////////////////////////
444
445/* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
447 *
448 * Table Of Content generator
449 * Version: 0.4
450 *
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
453 */
454
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
457
458// toclevels = 1..4.
459toc: function (toclevels) {
460
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
468 }
469 return text;
470 }
471
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
476 }
477
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
490 }
491 iterate(i);
492 }
493 }
494 }
495 iterate(el);
496 return result;
497 }
498
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
512 }
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
515},
516
517
518/////////////////////////////////////////////////////////////////////
519// Footnotes generator
520/////////////////////////////////////////////////////////////////////
521
522/* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
524 */
525
526footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
547 }
548 }
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
561 }
562 }
563 }
564}
565
566}
567/*]]>*/
568</script>
569</head>
570<body>
571<div id="header">
572<h1>
573git-p4(1) Manual Page
574</h1>
575<h2>NAME</h2>
576<div class="sectionbody">
577<p>git-p4 -
578 Import from and submit to Perforce repositories
579</p>
580</div>
581</div>
582<div id="content">
583<h2 id="_synopsis">SYNOPSIS</h2>
584<div class="sectionbody">
585<div class="verseblock">
586<div class="verseblock-content"><em>git p4 clone</em> [&lt;sync options&gt;] [&lt;clone options&gt;] &lt;p4 depot path&gt;&#8230;
587<em>git p4 sync</em> [&lt;sync options&gt;] [&lt;p4 depot path&gt;&#8230;]
588<em>git p4 rebase</em>
589<em>git p4 submit</em> [&lt;submit options&gt;] [&lt;master branch name&gt;]</div>
590<div class="verseblock-attribution">
591</div></div>
592</div>
593<h2 id="_description">DESCRIPTION</h2>
594<div class="sectionbody">
595<div class="paragraph"><p>This command provides a way to interact with p4 repositories
596using git.</p></div>
597<div class="paragraph"><p>Create a new git repository from an existing p4 repository using
598<em>git p4 clone</em>, giving it one or more p4 depot paths. Incorporate
599new commits from p4 changes with <em>git p4 sync</em>. The <em>sync</em> command
600is also used to include new branches from other p4 depot paths.
601Submit git changes back to p4 using <em>git p4 submit</em>. The command
602<em>git p4 rebase</em> does a sync plus rebases the current branch onto
603the updated p4 remote branch.</p></div>
604</div>
605<h2 id="_example">EXAMPLE</h2>
606<div class="sectionbody">
607<div class="ulist"><ul>
608<li>
609<p>
Junio C Hamanodb472bc2012-01-04 00:22:37610Clone a repository:
611</p>
612<div class="listingblock">
613<div class="content">
614<pre><tt>$ git p4 clone //depot/path/project</tt></pre>
615</div></div>
616</li>
617<li>
618<p>
619Do some work in the newly created git repository:
620</p>
621<div class="listingblock">
622<div class="content">
623<pre><tt>$ cd project
624$ vi foo.h
625$ git commit -a -m "edited foo.h"</tt></pre>
626</div></div>
627</li>
628<li>
629<p>
630Update the git repository with recent changes from p4, rebasing your
631 work on top:
632</p>
633<div class="listingblock">
634<div class="content">
635<pre><tt>$ git p4 rebase</tt></pre>
636</div></div>
637</li>
638<li>
639<p>
640Submit your commits back to p4:
641</p>
642<div class="listingblock">
643<div class="content">
644<pre><tt>$ git p4 submit</tt></pre>
645</div></div>
646</li>
647</ul></div>
648</div>
649<h2 id="_commands">COMMANDS</h2>
650<div class="sectionbody">
651<h3 id="_clone">Clone</h3><div style="clear:left"></div>
652<div class="paragraph"><p>Generally, <em>git p4 clone</em> is used to create a new git directory
653from an existing p4 repository:</p></div>
654<div class="listingblock">
655<div class="content">
656<pre><tt>$ git p4 clone //depot/path/project</tt></pre>
657</div></div>
658<div class="paragraph"><p>This:</p></div>
659<div class="olist arabic"><ol class="arabic">
660<li>
661<p>
662Creates an empty git repository in a subdirectory called <em>project</em>.
663</p>
664</li>
665<li>
666<p>
667Imports the full contents of the head revision from the given p4
668depot path into a single commit in the git branch <em>refs/remotes/p4/master</em>.
669</p>
670</li>
671<li>
672<p>
673Creates a local branch, <em>master</em> from this remote and checks it out.
674</p>
675</li>
676</ol></div>
677<div class="paragraph"><p>To reproduce the entire p4 history in git, use the <em>@all</em> modifier on
678the depot path:</p></div>
679<div class="listingblock">
680<div class="content">
681<pre><tt>$ git p4 clone //depot/path/project@all</tt></pre>
682</div></div>
683<h3 id="_sync">Sync</h3><div style="clear:left"></div>
684<div class="paragraph"><p>As development continues in the p4 repository, those changes can
685be included in the git repository using:</p></div>
686<div class="listingblock">
687<div class="content">
688<pre><tt>$ git p4 sync</tt></pre>
689</div></div>
690<div class="paragraph"><p>This command finds new changes in p4 and imports them as git commits.</p></div>
691<div class="paragraph"><p>P4 repositories can be added to an existing git repository using
692<em>git p4 sync</em> too:</p></div>
693<div class="listingblock">
694<div class="content">
695<pre><tt>$ mkdir repo-git
696$ cd repo-git
697$ git init
698$ git p4 sync //path/in/your/perforce/depot</tt></pre>
699</div></div>
700<div class="paragraph"><p>This imports the specified depot into
701<em>refs/remotes/p4/master</em> in an existing git repository. The
702<em>--branch</em> option can be used to specify a different branch to
703be used for the p4 content.</p></div>
704<div class="paragraph"><p>If a git repository includes branches <em>refs/remotes/origin/p4</em>, these
705will be fetched and consulted first during a <em>git p4 sync</em>. Since
706importing directly from p4 is considerably slower than pulling changes
707from a git remote, this can be useful in a multi-developer environment.</p></div>
708<h3 id="_rebase">Rebase</h3><div style="clear:left"></div>
709<div class="paragraph"><p>A common working pattern is to fetch the latest changes from the p4 depot
710and merge them with local uncommitted changes. Often, the p4 repository
711is the ultimate location for all code, thus a rebase workflow makes
712sense. This command does <em>git p4 sync</em> followed by <em>git rebase</em> to move
713local commits on top of updated p4 changes.</p></div>
714<div class="listingblock">
715<div class="content">
716<pre><tt>$ git p4 rebase</tt></pre>
717</div></div>
718<h3 id="_submit">Submit</h3><div style="clear:left"></div>
719<div class="paragraph"><p>Submitting changes from a git repository back to the p4 repository
720requires a separate p4 client workspace. This should be specified
721using the <em>P4CLIENT</em> environment variable or the git configuration
722variable <em>git-p4.client</em>. The p4 client must exist, but the client root
723will be created and populated if it does not already exist.</p></div>
724<div class="paragraph"><p>To submit all changes that are in the current git branch but not in
725the <em>p4/master</em> branch, use:</p></div>
726<div class="listingblock">
727<div class="content">
728<pre><tt>$ git p4 submit</tt></pre>
729</div></div>
730<div class="paragraph"><p>To specify a branch other than the current one, use:</p></div>
731<div class="listingblock">
732<div class="content">
733<pre><tt>$ git p4 submit topicbranch</tt></pre>
734</div></div>
735<div class="paragraph"><p>The upstream reference is generally <em>refs/remotes/p4/master</em>, but can
736be overridden using the <em>--origin=</em> command-line option.</p></div>
737<div class="paragraph"><p>The p4 changes will be created as the user invoking <em>git p4 submit</em>. The
738<em>--preserve-user</em> option will cause ownership to be modified
739according to the author of the git commit. This option requires admin
740privileges in p4, which can be granted using <em>p4 protect</em>.</p></div>
741</div>
742<h2 id="_options">OPTIONS</h2>
743<div class="sectionbody">
744<h3 id="_general_options">General options</h3><div style="clear:left"></div>
Junio C Hamano37e389e2012-04-30 22:36:09745<div class="paragraph"><p>All commands except clone accept these options.</p></div>
Junio C Hamanodb472bc2012-01-04 00:22:37746<div class="dlist"><dl>
747<dt class="hdlist1">
748--git-dir &lt;dir&gt;
749</dt>
750<dd>
751<p>
752 Set the <em>GIT_DIR</em> environment variable. See <a href="git.html">git(1)</a>.
753</p>
754</dd>
Junio C Hamano37e389e2012-04-30 22:36:09755<dt class="hdlist1">
756--verbose
757</dt>
758<dd>
759<p>
760 Provide more progress information.
761</p>
762</dd>
Junio C Hamanodb472bc2012-01-04 00:22:37763</dl></div>
764<h3 id="_sync_options">Sync options</h3><div style="clear:left"></div>
765<div class="paragraph"><p>These options can be used in the initial <em>clone</em> as well as in
766subsequent <em>sync</em> operations.</p></div>
767<div class="dlist"><dl>
768<dt class="hdlist1">
769--branch &lt;branch&gt;
770</dt>
771<dd>
772<p>
773 Import changes into given branch. If the branch starts with
774 <em>refs/</em>, it will be used as is, otherwise the path <em>refs/heads/</em>
775 will be prepended. The default branch is <em>master</em>. If used
776 with an initial clone, no HEAD will be checked out.
777</p>
778<div class="paragraph"><p>This example imports a new remote "p4/proj2" into an existing
779git repository:</p></div>
Junio C Hamanodb472bc2012-01-04 00:22:37780<div class="listingblock">
781<div class="content">
782<pre><tt> $ git init
783 $ git p4 sync --branch=refs/remotes/p4/proj2 //depot/proj2</tt></pre>
784</div></div>
Junio C Hamanobcdb12e2012-05-10 18:45:15785</dd>
Junio C Hamanodb472bc2012-01-04 00:22:37786<dt class="hdlist1">
787--detect-branches
788</dt>
789<dd>
790<p>
791 Use the branch detection algorithm to find new paths in p4. It is
792 documented below in "BRANCH DETECTION".
793</p>
794</dd>
795<dt class="hdlist1">
796--changesfile &lt;file&gt;
797</dt>
798<dd>
799<p>
800 Import exactly the p4 change numbers listed in <em>file</em>, one per
801 line. Normally, <em>git p4</em> inspects the current p4 repository
802 state and detects the changes it should import.
803</p>
804</dd>
805<dt class="hdlist1">
806--silent
807</dt>
808<dd>
809<p>
810 Do not print any progress information.
811</p>
812</dd>
813<dt class="hdlist1">
Junio C Hamanodb472bc2012-01-04 00:22:37814--detect-labels
815</dt>
816<dd>
817<p>
818 Query p4 for labels associated with the depot paths, and add
Junio C Hamano37e389e2012-04-30 22:36:09819 them as tags in git. Limited usefulness as only imports labels
820 associated with new changelists. Deprecated.
821</p>
822</dd>
823<dt class="hdlist1">
824--import-labels
825</dt>
826<dd>
827<p>
828 Import labels from p4 into git.
Junio C Hamanodb472bc2012-01-04 00:22:37829</p>
830</dd>
831<dt class="hdlist1">
832--import-local
833</dt>
834<dd>
835<p>
836 By default, p4 branches are stored in <em>refs/remotes/p4/</em>,
837 where they will be treated as remote-tracking branches by
838 <a href="git-branch.html">git-branch(1)</a> and other commands. This option instead
839 puts p4 branches in <em>refs/heads/p4/</em>. Note that future
840 sync operations must specify <em>--import-local</em> as well so that
841 they can find the p4 branches in refs/heads.
842</p>
843</dd>
844<dt class="hdlist1">
845--max-changes &lt;n&gt;
846</dt>
847<dd>
848<p>
849 Limit the number of imported changes to <em>n</em>. Useful to
850 limit the amount of history when using the <em>@all</em> p4 revision
851 specifier.
852</p>
853</dd>
854<dt class="hdlist1">
855--keep-path
856</dt>
857<dd>
858<p>
859 The mapping of file names from the p4 depot path to git, by
860 default, involves removing the entire depot path. With this
861 option, the full p4 depot path is retained in git. For example,
862 path <em>//depot/main/foo/bar.c</em>, when imported from
863 <em>//depot/main/</em>, becomes <em>foo/bar.c</em>. With <em>--keep-path</em>, the
864 git path is instead <em>depot/main/foo/bar.c</em>.
865</p>
866</dd>
867<dt class="hdlist1">
868--use-client-spec
869</dt>
870<dd>
871<p>
872 Use a client spec to find the list of interesting files in p4.
Junio C Hamano4fd24422012-01-06 21:52:43873 See the "CLIENT SPEC" section below.
Junio C Hamanodb472bc2012-01-04 00:22:37874</p>
875</dd>
876</dl></div>
877<h3 id="_clone_options">Clone options</h3><div style="clear:left"></div>
878<div class="paragraph"><p>These options can be used in an initial <em>clone</em>, along with the <em>sync</em>
879options described above.</p></div>
880<div class="dlist"><dl>
881<dt class="hdlist1">
882--destination &lt;directory&gt;
883</dt>
884<dd>
885<p>
886 Where to create the git repository. If not provided, the last
887 component in the p4 depot path is used to create a new
888 directory.
889</p>
890</dd>
891<dt class="hdlist1">
892--bare
893</dt>
894<dd>
895<p>
896 Perform a bare clone. See <a href="git-clone.html">git-clone(1)</a>.
897</p>
898</dd>
899<dt class="hdlist1">
900-/ &lt;path&gt;
901</dt>
902<dd>
903<p>
904 Exclude selected depot paths when cloning.
905</p>
906</dd>
907</dl></div>
908<h3 id="_submit_options">Submit options</h3><div style="clear:left"></div>
909<div class="paragraph"><p>These options can be used to modify <em>git p4 submit</em> behavior.</p></div>
910<div class="dlist"><dl>
911<dt class="hdlist1">
Junio C Hamanodb472bc2012-01-04 00:22:37912--origin &lt;commit&gt;
913</dt>
914<dd>
915<p>
916 Upstream location from which commits are identified to submit to
917 p4. By default, this is the most recent p4 commit reachable
918 from <em>HEAD</em>.
919</p>
920</dd>
921<dt class="hdlist1">
922-M[&lt;n&gt;]
923</dt>
924<dd>
925<p>
926 Detect renames. See <a href="git-diff.html">git-diff(1)</a>. Renames will be
927 represented in p4 using explicit <em>move</em> operations. There
928 is no corresponding option to detect copies, but there are
929 variables for both moves and copies.
930</p>
931</dd>
932<dt class="hdlist1">
933--preserve-user
934</dt>
935<dd>
936<p>
937 Re-author p4 changes before submitting to p4. This option
938 requires p4 admin privileges.
939</p>
940</dd>
Junio C Hamano37e389e2012-04-30 22:36:09941<dt class="hdlist1">
942--export-labels
943</dt>
944<dd>
945<p>
946 Export tags from git as p4 labels. Tags found in git are applied
947 to the perforce working directory.
948</p>
949</dd>
950</dl></div>
951<h3 id="_rebase_options">Rebase options</h3><div style="clear:left"></div>
952<div class="paragraph"><p>These options can be used to modify <em>git p4 rebase</em> behavior.</p></div>
953<div class="dlist"><dl>
954<dt class="hdlist1">
955--import-labels
956</dt>
957<dd>
958<p>
959 Import p4 labels.
960</p>
961</dd>
Junio C Hamanodb472bc2012-01-04 00:22:37962</dl></div>
963</div>
964<h2 id="_depot_path_syntax">DEPOT PATH SYNTAX</h2>
965<div class="sectionbody">
966<div class="paragraph"><p>The p4 depot path argument to <em>git p4 sync</em> and <em>git p4 clone</em> can
967be one or more space-separated p4 depot paths, with an optional
968p4 revision specifier on the end:</p></div>
969<div class="dlist"><dl>
970<dt class="hdlist1">
971"//depot/my/project"
972</dt>
973<dd>
974<p>
975 Import one commit with all files in the <em>#head</em> change under that tree.
976</p>
977</dd>
978<dt class="hdlist1">
979"//depot/my/project@all"
980</dt>
981<dd>
982<p>
983 Import one commit for each change in the history of that depot path.
984</p>
985</dd>
986<dt class="hdlist1">
987"//depot/my/project@1,6"
988</dt>
989<dd>
990<p>
991 Import only changes 1 through 6.
992</p>
993</dd>
994<dt class="hdlist1">
995"//depot/proj1@all //depot/proj2@all"
996</dt>
997<dd>
998<p>
999 Import all changes from both named depot paths into a single
1000 repository. Only files below these directories are included.
1001 There is not a subdirectory in git for each "proj1" and "proj2".
1002 You must use the <em>--destination</em> option when specifying more
1003 than one depot path. The revision specifier must be specified
1004 identically on each depot path. If there are files in the
1005 depot paths with the same name, the path with the most recently
1006 updated version of the file is the one that appears in git.
1007</p>
1008</dd>
1009</dl></div>
1010<div class="paragraph"><p>See <em>p4 help revisions</em> for the full syntax of p4 revision specifiers.</p></div>
1011</div>
Junio C Hamano4fd24422012-01-06 21:52:431012<h2 id="_client_spec">CLIENT SPEC</h2>
1013<div class="sectionbody">
1014<div class="paragraph"><p>The p4 client specification is maintained with the <em>p4 client</em> command
1015and contains among other fields, a View that specifies how the depot
Junio C Hamano8c6a7b02012-02-27 02:21:581016is mapped into the client repository. The <em>clone</em> and <em>sync</em> commands
1017can consult the client spec when given the <em>--use-client-spec</em> option or
1018when the useClientSpec variable is true. After <em>git p4 clone</em>, the
1019useClientSpec variable is automatically set in the repository
1020configuration file. This allows future <em>git p4 submit</em> commands to
1021work properly; the submit command looks only at the variable and does
1022not have a command-line option.</p></div>
Junio C Hamano4eda1362012-04-23 20:55:491023<div class="paragraph"><p>The full syntax for a p4 view is documented in <em>p4 help views</em>. <em>Git p4</em>
Junio C Hamano4fd24422012-01-06 21:52:431024knows only a subset of the view syntax. It understands multi-line
1025mappings, overlays with <em>+</em>, exclusions with <em>-</em> and double-quotes
Junio C Hamano4eda1362012-04-23 20:55:491026around whitespace. Of the possible wildcards, <em>git p4</em> only handles
1027<em>&#8230;</em>, and only when it is at the end of the path. <em>Git p4</em> will complain
Junio C Hamano4fd24422012-01-06 21:52:431028if it encounters an unhandled wildcard.</p></div>
Junio C Hamanob5be0522012-01-29 22:20:191029<div class="paragraph"><p>Bugs in the implementation of overlap mappings exist. If multiple depot
1030paths map through overlays to the same location in the repository,
Junio C Hamano4eda1362012-04-23 20:55:491031<em>git p4</em> can choose the wrong one. This is hard to solve without
1032dedicating a client spec just for <em>git p4</em>.</p></div>
1033<div class="paragraph"><p>The name of the client can be given to <em>git p4</em> in multiple ways. The
Junio C Hamano4fd24422012-01-06 21:52:431034variable <em>git-p4.client</em> takes precedence if it exists. Otherwise,
1035normal p4 mechanisms of determining the client are used: environment
1036variable P4CLIENT, a file referenced by P4CONFIG, or the local host name.</p></div>
1037</div>
Junio C Hamanodb472bc2012-01-04 00:22:371038<h2 id="_branch_detection">BRANCH DETECTION</h2>
1039<div class="sectionbody">
1040<div class="paragraph"><p>P4 does not have the same concept of a branch as git. Instead,
1041p4 organizes its content as a directory tree, where by convention
1042different logical branches are in different locations in the tree.
1043The <em>p4 branch</em> command is used to maintain mappings between
1044different areas in the tree, and indicate related content. <em>git p4</em>
1045can use these mappings to determine branch relationships.</p></div>
1046<div class="paragraph"><p>If you have a repository where all the branches of interest exist as
1047subdirectories of a single depot path, you can use <em>--detect-branches</em>
1048when cloning or syncing to have <em>git p4</em> automatically find
1049subdirectories in p4, and to generate these as branches in git.</p></div>
1050<div class="paragraph"><p>For example, if the P4 repository structure is:</p></div>
1051<div class="listingblock">
1052<div class="content">
1053<pre><tt>//depot/main/...
1054//depot/branch1/...</tt></pre>
1055</div></div>
1056<div class="paragraph"><p>And "p4 branch -o branch1" shows a View line that looks like:</p></div>
1057<div class="listingblock">
1058<div class="content">
1059<pre><tt>//depot/main/... //depot/branch1/...</tt></pre>
1060</div></div>
1061<div class="paragraph"><p>Then this <em>git p4 clone</em> command:</p></div>
1062<div class="listingblock">
1063<div class="content">
1064<pre><tt>git p4 clone --detect-branches //depot@all</tt></pre>
1065</div></div>
1066<div class="paragraph"><p>produces a separate branch in <em>refs/remotes/p4/</em> for //depot/main,
1067called <em>master</em>, and one for //depot/branch1 called <em>depot/branch1</em>.</p></div>
1068<div class="paragraph"><p>However, it is not necessary to create branches in p4 to be able to use
1069them like branches. Because it is difficult to infer branch
1070relationships automatically, a git configuration setting
1071<em>git-p4.branchList</em> can be used to explicitly identify branch
1072relationships. It is a list of "source:destination" pairs, like a
1073simple p4 branch specification, where the "source" and "destination" are
1074the path elements in the p4 repository. The example above relied on the
1075presence of the p4 branch. Without p4 branches, the same result will
1076occur with:</p></div>
1077<div class="listingblock">
1078<div class="content">
1079<pre><tt>git config git-p4.branchList main:branch1
1080git p4 clone --detect-branches //depot@all</tt></pre>
1081</div></div>
1082</div>
1083<h2 id="_performance">PERFORMANCE</h2>
1084<div class="sectionbody">
1085<div class="paragraph"><p>The fast-import mechanism used by <em>git p4</em> creates one pack file for
1086each invocation of <em>git p4 sync</em>. Normally, git garbage compression
1087(<a href="git-gc.html">git-gc(1)</a>) automatically compresses these to fewer pack files,
1088but explicit invocation of <em>git repack -adf</em> may improve performance.</p></div>
1089</div>
1090<h2 id="_configuration_variables">CONFIGURATION VARIABLES</h2>
1091<div class="sectionbody">
1092<div class="paragraph"><p>The following config settings can be used to modify <em>git p4</em> behavior.
1093They all are in the <em>git-p4</em> section.</p></div>
1094<h3 id="_general_variables">General variables</h3><div style="clear:left"></div>
1095<div class="dlist"><dl>
1096<dt class="hdlist1">
1097git-p4.user
1098</dt>
1099<dd>
1100<p>
1101 User specified as an option to all p4 commands, with <em>-u &lt;user&gt;</em>.
1102 The environment variable <em>P4USER</em> can be used instead.
1103</p>
1104</dd>
1105<dt class="hdlist1">
1106git-p4.password
1107</dt>
1108<dd>
1109<p>
1110 Password specified as an option to all p4 commands, with
1111 <em>-P &lt;password&gt;</em>.
1112 The environment variable <em>P4PASS</em> can be used instead.
1113</p>
1114</dd>
1115<dt class="hdlist1">
1116git-p4.port
1117</dt>
1118<dd>
1119<p>
1120 Port specified as an option to all p4 commands, with
1121 <em>-p &lt;port&gt;</em>.
1122 The environment variable <em>P4PORT</em> can be used instead.
1123</p>
1124</dd>
1125<dt class="hdlist1">
1126git-p4.host
1127</dt>
1128<dd>
1129<p>
1130 Host specified as an option to all p4 commands, with
1131 <em>-h &lt;host&gt;</em>.
1132 The environment variable <em>P4HOST</em> can be used instead.
1133</p>
1134</dd>
1135<dt class="hdlist1">
1136git-p4.client
1137</dt>
1138<dd>
1139<p>
1140 Client specified as an option to all p4 commands, with
Junio C Hamano4fd24422012-01-06 21:52:431141 <em>-c &lt;client&gt;</em>, including the client spec.
Junio C Hamanodb472bc2012-01-04 00:22:371142</p>
1143</dd>
1144</dl></div>
1145<h3 id="_clone_and_sync_variables">Clone and sync variables</h3><div style="clear:left"></div>
1146<div class="dlist"><dl>
1147<dt class="hdlist1">
1148git-p4.syncFromOrigin
1149</dt>
1150<dd>
1151<p>
1152 Because importing commits from other git repositories is much faster
1153 than importing them from p4, a mechanism exists to find p4 changes
1154 first in git remotes. If branches exist under <em>refs/remote/origin/p4</em>,
1155 those will be fetched and used when syncing from p4. This
1156 variable can be set to <em>false</em> to disable this behavior.
1157</p>
1158</dd>
1159<dt class="hdlist1">
1160git-p4.branchUser
1161</dt>
1162<dd>
1163<p>
1164 One phase in branch detection involves looking at p4 branches
1165 to find new ones to import. By default, all branches are
1166 inspected. This option limits the search to just those owned
1167 by the single user named in the variable.
1168</p>
1169</dd>
1170<dt class="hdlist1">
1171git-p4.branchList
1172</dt>
1173<dd>
1174<p>
1175 List of branches to be imported when branch detection is
1176 enabled. Each entry should be a pair of branch names separated
1177 by a colon (:). This example declares that both branchA and
1178 branchB were created from main:
1179</p>
Junio C Hamanodb472bc2012-01-04 00:22:371180<div class="listingblock">
1181<div class="content">
1182<pre><tt>git config git-p4.branchList main:branchA
1183git config --add git-p4.branchList main:branchB</tt></pre>
1184</div></div>
Junio C Hamanobcdb12e2012-05-10 18:45:151185</dd>
Junio C Hamanodb472bc2012-01-04 00:22:371186<dt class="hdlist1">
Junio C Hamano37e389e2012-04-30 22:36:091187git-p4.ignoredP4Labels
1188</dt>
1189<dd>
1190<p>
1191 List of p4 labels to ignore. This is built automatically as
1192 unimportable labels are discovered.
1193</p>
1194</dd>
1195<dt class="hdlist1">
1196git-p4.importLabels
1197</dt>
1198<dd>
1199<p>
1200 Import p4 labels into git, as per --import-labels.
1201</p>
1202</dd>
1203<dt class="hdlist1">
1204git-p4.labelImportRegexp
1205</dt>
1206<dd>
1207<p>
1208 Only p4 labels matching this regular expression will be imported. The
1209 default value is <em>[a-zA-Z0-9_\-.]+$</em>.
1210</p>
1211</dd>
1212<dt class="hdlist1">
Junio C Hamanodb472bc2012-01-04 00:22:371213git-p4.useClientSpec
1214</dt>
1215<dd>
1216<p>
Junio C Hamano4fd24422012-01-06 21:52:431217 Specify that the p4 client spec should be used to identify p4
1218 depot paths of interest. This is equivalent to specifying the
1219 option <em>--use-client-spec</em>. See the "CLIENT SPEC" section above.
1220 This variable is a boolean, not the name of a p4 client.
Junio C Hamanodb472bc2012-01-04 00:22:371221</p>
1222</dd>
1223</dl></div>
1224<h3 id="_submit_variables">Submit variables</h3><div style="clear:left"></div>
1225<div class="dlist"><dl>
1226<dt class="hdlist1">
1227git-p4.detectRenames
1228</dt>
1229<dd>
1230<p>
1231 Detect renames. See <a href="git-diff.html">git-diff(1)</a>.
1232</p>
1233</dd>
1234<dt class="hdlist1">
1235git-p4.detectCopies
1236</dt>
1237<dd>
1238<p>
1239 Detect copies. See <a href="git-diff.html">git-diff(1)</a>.
1240</p>
1241</dd>
1242<dt class="hdlist1">
1243git-p4.detectCopiesHarder
1244</dt>
1245<dd>
1246<p>
1247 Detect copies harder. See <a href="git-diff.html">git-diff(1)</a>.
1248</p>
1249</dd>
1250<dt class="hdlist1">
1251git-p4.preserveUser
1252</dt>
1253<dd>
1254<p>
1255 On submit, re-author changes to reflect the git author,
1256 regardless of who invokes <em>git p4 submit</em>.
1257</p>
1258</dd>
1259<dt class="hdlist1">
1260git-p4.allowMissingP4Users
1261</dt>
1262<dd>
1263<p>
1264 When <em>preserveUser</em> is true, <em>git p4</em> normally dies if it
1265 cannot find an author in the p4 user map. This setting
1266 submits the change regardless.
1267</p>
1268</dd>
1269<dt class="hdlist1">
1270git-p4.skipSubmitEdit
1271</dt>
1272<dd>
1273<p>
1274 The submit process invokes the editor before each p4 change
1275 is submitted. If this setting is true, though, the editing
1276 step is skipped.
1277</p>
1278</dd>
1279<dt class="hdlist1">
1280git-p4.skipSubmitEditCheck
1281</dt>
1282<dd>
1283<p>
1284 After editing the p4 change message, <em>git p4</em> makes sure that
1285 the description really was changed by looking at the file
1286 modification time. This option disables that test.
1287</p>
1288</dd>
1289<dt class="hdlist1">
1290git-p4.allowSubmit
1291</dt>
1292<dd>
1293<p>
1294 By default, any branch can be used as the source for a <em>git p4
1295 submit</em> operation. This configuration variable, if set, permits only
1296 the named branches to be used as submit sources. Branch names
1297 must be the short names (no "refs/heads/"), and should be
1298 separated by commas (","), with no spaces.
1299</p>
1300</dd>
1301<dt class="hdlist1">
1302git-p4.skipUserNameCheck
1303</dt>
1304<dd>
1305<p>
1306 If the user running <em>git p4 submit</em> does not exist in the p4
1307 user map, <em>git p4</em> exits. This option can be used to force
1308 submission regardless.
1309</p>
1310</dd>
Junio C Hamanobcdb12e2012-05-10 18:45:151311<dt class="hdlist1">
1312git-p4.attemptRCSCleanup
1313</dt>
1314<dd>
1315<p>
Junio C Hamano37e389e2012-04-30 22:36:091316 If enabled, <em>git p4 submit</em> will attempt to cleanup RCS keywords
1317 ($Header$, etc). These would otherwise cause merge conflicts and prevent
1318 the submit going ahead. This option should be considered experimental at
Junio C Hamanobcdb12e2012-05-10 18:45:151319 present.
1320</p>
1321</dd>
Junio C Hamano37e389e2012-04-30 22:36:091322<dt class="hdlist1">
1323git-p4.exportLabels
1324</dt>
1325<dd>
1326<p>
1327 Export git tags to p4 labels, as per --export-labels.
1328</p>
1329</dd>
1330<dt class="hdlist1">
1331git-p4.labelExportRegexp
1332</dt>
1333<dd>
1334<p>
1335 Only p4 labels matching this regular expression will be exported. The
1336 default value is <em>[a-zA-Z0-9_\-.]+$</em>.
1337</p>
1338</dd>
1339</dl></div>
Junio C Hamanodb472bc2012-01-04 00:22:371340</div>
1341<h2 id="_implementation_details">IMPLEMENTATION DETAILS</h2>
1342<div class="sectionbody">
1343<div class="ulist"><ul>
1344<li>
1345<p>
1346Changesets from p4 are imported using git fast-import.
1347</p>
1348</li>
1349<li>
1350<p>
1351Cloning or syncing does not require a p4 client; file contents are
1352 collected using <em>p4 print</em>.
1353</p>
1354</li>
1355<li>
1356<p>
1357Submitting requires a p4 client, which is not in the same location
1358 as the git repository. Patches are applied, one at a time, to
1359 this p4 client and submitted from there.
1360</p>
1361</li>
1362<li>
1363<p>
1364Each commit imported by <em>git p4</em> has a line at the end of the log
1365 message indicating the p4 depot location and change number. This
1366 line is used by later <em>git p4 sync</em> operations to know which p4
1367 changes are new.
1368</p>
1369</li>
1370</ul></div>
1371</div>
1372</div>
1373<div id="footnotes"><hr /></div>
1374<div id="footer">
1375<div id="footer-text">
Junio C Hamanobcdb12e2012-05-10 18:45:151376Last updated 2012-05-10 11:44:38 PDT
Junio C Hamanodb472bc2012-01-04 00:22:371377</div>
1378</div>
1379</body>
1380</html>