Skip to content

Commit

Permalink
git p4: bring back files in deleted client directory
Browse files Browse the repository at this point in the history
The code to auto-create the client directory, added in 0591cfa
(git-p4: ensure submit clientPath exists before chdir,
2011-12-09), works when the client directory never existed.

But if the directory is summarily removed without telling p4,
the sync operation will not bring back all the files.  Always
do "sync -f" if the client directory is newly created.

Reported-by: Gary Gibbons <ggibbons@perforce.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pete Wyckoff authored and Junio C Hamano committed Apr 30, 2012
1 parent 9768caf commit 8d7ec36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 9 additions & 3 deletions git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def p4_system(cmd):
def p4_integrate(src, dest):
p4_system(["integrate", "-Dt", src, dest])

def p4_sync(path):
p4_system(["sync", path])
def p4_sync(f, *options):
p4_system(["sync"] + list(options) + [f])

def p4_add(f):
p4_system(["add", f])
Expand Down Expand Up @@ -1361,12 +1361,18 @@ def run(self, args):
self.oldWorkingDirectory = os.getcwd()

# ensure the clientPath exists
new_client_dir = False
if not os.path.exists(self.clientPath):
new_client_dir = True
os.makedirs(self.clientPath)

chdir(self.clientPath)
print "Synchronizing p4 checkout..."
p4_sync("...")
if new_client_dir:
# old one was destroyed, and maybe nobody told p4
p4_sync("...", "-f")
else:
p4_sync("...")
self.check()

commits = []
Expand Down
7 changes: 5 additions & 2 deletions t/t9807-git-p4-submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ test_expect_success 'submit with no client dir' '
rm -rf "$cli" &&
git config git-p4.skipSubmitEdit true &&
git p4 submit
) &&
(
cd "$cli" &&
test_path_is_file file1 &&
test_path_is_file file2
)
'

Expand All @@ -44,7 +49,6 @@ test_expect_success 'submit --origin' '
) &&
(
cd "$cli" &&
p4 sync &&
test_path_is_missing "file3.t" &&
test_path_is_file "file4.t"
)
Expand Down Expand Up @@ -79,7 +83,6 @@ test_expect_success 'submit with master branch name from argv' '
) &&
(
cd "$cli" &&
p4 sync &&
test_path_is_file "file6.t" &&
test_path_is_missing "file7.t"
)
Expand Down

0 comments on commit 8d7ec36

Please sign in to comment.