Skip to content

Commit 06804c7

Browse files
luked99gitster
authored andcommitted
git p4: import/export of labels to/from p4
The existing label import code looks at each commit being imported, and then checks for labels at that commit. This doesn't work in the real world though because it will drop labels applied on changelists that have already been imported, a common pattern. This change adds a new --import-labels option. With this option, at the end of the sync, git p4 gets sets of labels in p4 and git, and then creates a git tag for each missing p4 label. This means that tags created on older changelists are still imported. Tags that could not be imported are added to an ignore list. The same sets of git and p4 tags and labels can also be used to derive a list of git tags to export to p4. This is enabled with --export-labels in 'git p4 submit'. Signed-off-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbaf11 commit 06804c7

File tree

3 files changed

+468
-39
lines changed

3 files changed

+468
-39
lines changed

Documentation/git-p4.txt

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ git repository:
198198

199199
--detect-labels::
200200
Query p4 for labels associated with the depot paths, and add
201-
them as tags in git.
201+
them as tags in git. Limited usefulness as only imports labels
202+
associated with new changelists. Deprecated.
203+
204+
--import-labels::
205+
Import labels from p4 into git.
202206

203207
--import-local::
204208
By default, p4 branches are stored in 'refs/remotes/p4/',
@@ -263,6 +267,16 @@ These options can be used to modify 'git p4 submit' behavior.
263267
Re-author p4 changes before submitting to p4. This option
264268
requires p4 admin privileges.
265269

270+
--export-labels:
271+
Export tags from git as p4 labels. Tags found in git are applied
272+
to the perforce working directory.
273+
274+
Rebase options
275+
~~~~~~~~~~~~~~
276+
These options can be used to modify 'git p4 rebase' behavior.
277+
278+
--import-labels::
279+
Import p4 labels.
266280

267281
DEPOT PATH SYNTAX
268282
-----------------
@@ -427,6 +441,18 @@ git-p4.branchList::
427441
enabled. Each entry should be a pair of branch names separated
428442
by a colon (:). This example declares that both branchA and
429443
branchB were created from main:
444+
445+
git-p4.ignoredP4Labels::
446+
List of p4 labels to ignore. This is built automatically as
447+
unimportable labels are discovered.
448+
449+
git-p4.importLabels::
450+
Import p4 labels into git, as per --import-labels.
451+
452+
git-p4.validLabelRegexp::
453+
Only p4 labels matching this regular expression will be imported. The
454+
default value is '[A-Z0-9_\-.]+$'.
455+
430456
-------------
431457
git config git-p4.branchList main:branchA
432458
git config --add git-p4.branchList main:branchB
@@ -481,10 +507,17 @@ git-p4.skipUserNameCheck::
481507
submission regardless.
482508

483509
git-p4.attemptRCSCleanup:
484-
If enabled, 'git p4 submit' will attempt to cleanup RCS keywords
485-
($Header$, etc). These would otherwise cause merge conflicts and prevent
486-
the submit going ahead. This option should be considered experimental at
487-
present.
510+
If enabled, 'git p4 submit' will attempt to cleanup RCS keywords
511+
($Header$, etc). These would otherwise cause merge conflicts and prevent
512+
the submit going ahead. This option should be considered experimental at
513+
present.
514+
515+
git-p4.exportLabels::
516+
Export git tags to p4 labels, as per --export-labels.
517+
518+
git-p4.validLabelRegexp::
519+
Only p4 labels matching this regular expression will be exported. The
520+
default value is '[A-Z0-9_\-.]+$'.
488521

489522
IMPLEMENTATION DETAILS
490523
----------------------

0 commit comments

Comments
 (0)