]> git.ipfire.org Git - thirdparty/git.git/commit
git-p4: support explicit sync of arbitrary existing git-p4 refs
authorTao Klerks <tao@klerks.biz>
Mon, 4 Apr 2022 05:10:54 +0000 (05:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2022 19:59:40 +0000 (12:59 -0700)
commit17f273ffbad8724278e0fa4da592a7ec7c6abc83
treeb39f9ab97061355d831922507c2001ccb1342c97
parentfaa21c10d44184f616d391c158dcbb13b9c72ef3
git-p4: support explicit sync of arbitrary existing git-p4 refs

With the --branch argument of the "sync" subcommand, git-p4 enables
you to import a perforce branch/path to an arbitrary git ref, using
a full ref path, or to refs/remotes/p4/* or refs/heads/p4/*,
depending on --import-local, using a short ref name.

However, when you later want to explicitly sync such a given ref to
pick up subsequent p4 changes, it only works if the ref was placed
in the p4 path *and* has only one path component (no "/").

This limitation results from a bad assumption in the
existing-branch sync logic, and also means you cannot individually
sync branches detected by --detect-branches, as these also get a
"/" in their names.

Fix "git p4 sync --branch", when called with an existing ref, so
that it works correctly regardless of whether the ref is in the p4
path or not, and (in the case of refs in the p4 path) regardless of
whether it has a "/" in its short name or not.

Also add tests to validate that these branch-specific syncs work
as expected.

Signed-off-by: Tao Klerks <tao@klerks.biz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
t/t9800-git-p4-basic.sh
t/t9801-git-p4-branch.sh