From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Gary Gibbons <ggibbons@perforce.com>, Luke Diamand <luke@diamand.org>
Subject: [PATCH 3/4] git p4: fix writable file after rename or copy
Date: Sun, 29 Apr 2012 20:57:16 -0400 [thread overview]
Message-ID: <1335747437-24034-4-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1335747437-24034-1-git-send-email-pw@padd.com>
The way rename works is with a "p4 integrate", optionally
followed by a "p4 edit" if the change is not a 100% rename.
Contents are generated by applying a patch, not doing a file
system rename. Copy is similar.
In this case, p4 does not fix the permissions back to read-only.
Make sure this happens by calling "p4 sync -f".
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
git-p4.py | 12 ++++++++++++
t/t9807-git-p4-submit.sh | 6 ++++--
t/t9809-git-p4-client-view.sh | 7 ++++---
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/git-p4.py b/git-p4.py
index a2eba5d..888e3e7 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1021,6 +1021,7 @@ class P4Submit(Command, P4UserMap):
filesToAdd = set()
filesToDelete = set()
editedFiles = set()
+ pureRenameCopy = set()
filesToChangeExecBit = {}
for line in diff:
@@ -1044,10 +1045,13 @@ class P4Submit(Command, P4UserMap):
elif modifier == "C":
src, dest = diff['src'], diff['dst']
p4_integrate(src, dest)
+ pureRenameCopy.add(dest)
if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest)
+ pureRenameCopy.discard(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest)
+ pureRenameCopy.discard(dest)
filesToChangeExecBit[dest] = diff['dst_mode']
os.unlink(dest)
editedFiles.add(dest)
@@ -1056,6 +1060,8 @@ class P4Submit(Command, P4UserMap):
p4_integrate(src, dest)
if diff['src_sha1'] != diff['dst_sha1']:
p4_edit(dest)
+ else:
+ pureRenameCopy.add(dest)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
p4_edit(dest)
filesToChangeExecBit[dest] = diff['dst_mode']
@@ -1209,6 +1215,12 @@ class P4Submit(Command, P4UserMap):
# unmarshalled.
changelist = self.lastP4Changelist()
self.modifyChangelistUser(changelist, p4User)
+
+ # The rename/copy happened by applying a patch that created a
+ # new file. This leaves it writable, which confuses p4.
+ for f in pureRenameCopy:
+ p4_sync(f, "-f")
+
else:
# skip this patch
print "Submission cancelled, undoing p4 changes."
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index a2499ee..f23b4c3 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -158,7 +158,8 @@ test_expect_success 'submit copy' '
) &&
(
cd "$cli" &&
- test_path_is_file file5.ta
+ test_path_is_file file5.ta &&
+ test ! -w file5.ta
)
'
@@ -176,7 +177,8 @@ test_expect_success 'submit rename' '
(
cd "$cli" &&
test_path_is_missing file6.t &&
- test_path_is_file file6.ta
+ test_path_is_file file6.ta &&
+ test ! -w file6.ta
)
'
diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh
index 796b02c..43ed1fe 100755
--- a/t/t9809-git-p4-client-view.sh
+++ b/t/t9809-git-p4-client-view.sh
@@ -349,7 +349,8 @@ test_expect_success 'subdir clone, submit copy' '
) &&
(
cd "$cli" &&
- test_path_is_file dir1/file11a
+ test_path_is_file dir1/file11a &&
+ test ! -w dir1/file11a
)
'
@@ -368,14 +369,14 @@ test_expect_success 'subdir clone, submit rename' '
(
cd "$cli" &&
test_path_is_missing dir1/file13 &&
- test_path_is_file dir1/file13a
+ test_path_is_file dir1/file13a &&
+ test ! -w dir1/file13a
)
'
test_expect_success 'reinit depot' '
(
cd "$cli" &&
- p4 sync -f &&
rm files &&
p4 delete */* &&
p4 submit -d "delete all files" &&
--
1.7.10.366.g90ade
next prev parent reply other threads:[~2012-04-30 0:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-30 0:57 [PATCH 0/4] git p4 submit fixes Pete Wyckoff
2012-04-30 0:57 ` [PATCH 1/4] git p4: bring back files in deleted client directory Pete Wyckoff
2012-04-30 6:55 ` Luke Diamand
2012-04-30 12:36 ` Pete Wyckoff
2012-04-30 18:34 ` Luke Diamand
2012-04-30 21:56 ` Pete Wyckoff
2012-04-30 0:57 ` [PATCH 2/4] git p4: test submit Pete Wyckoff
2012-04-30 0:57 ` Pete Wyckoff [this message]
2012-04-30 0:57 ` [PATCH 4/4] git p4: submit files with wildcards Pete Wyckoff
2012-04-30 18:34 ` Luke Diamand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335747437-24034-4-git-send-email-pw@padd.com \
--to=pw@padd.com \
--cc=ggibbons@perforce.com \
--cc=git@vger.kernel.org \
--cc=luke@diamand.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).