git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC v1] git-p4: test case for RCS keyword problem

From
Luke Diamand <luke@diamand.org>
Date
May 9, 2011, 07:49 UTC
Message-ID
<1304927397-24614-1-git-send-email-luke@diamand.org>

This is following on from some earlier threads about RCS keywords and git-p4:

http://marc.info/?l=git&m=122145837226632&w=2 http://marc.info/?l=git&m=130470278328964&w=2

The problem is that git-p4 imports into git with RCS keywords unexpanded (e.g. as $Id$), which is certainly the right thing to do given how nasty RCS keywords are.

However, when it comes to try to apply your changes, it applies them against a checked-out p4 tree, where the RCS keywords *are* expanded. This then fails if in git you modify any lines that contain RCS keywords (i.e. deleting them, or deleting the entire file).

You would think you could just tell p4 to not expand RCS keywords in your client view, but sadly that option doesn't exist :-(

This isn't a fix, it's just a test case that shows the problem, and doesn't even try to test the whole-file deletion case.

I'm hoping someone will suggest a good way to handle this.

Otherwise, I've got a possible scheme that involves spotting the failure to apply the patch, patching up RCS keywords in the p4 client shadow and then trying again. It's not pretty but it seems like it ought to work. My current version doesn't handle deletion, and zaps *all* RCS keywords rather than just the ones zapped in git; more work is needed before I can submit it.

Regards! Luke

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 t/t9800-git-p4.sh |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
index 0dcaa9c..8e79331 100755
--- a/t/t9800-git-p4.sh
+++ b/t/t9800-git-p4.sh
@@ -258,6 +258,50 @@ test_expect_success 'not preserving user with mixed authorship' '
 	rm -rf "$git" && mkdir "$git"
 '
 
+create_kw_file() {
+	cat <<'EOF' > $1
+/* A file
+   Id: $Id:$
+   Revision: $Revision:$
+   File: $File:$
+ */
+int main(int argc, const char **argv) {
+	return 0;
+}
+EOF
+	git add $1
+}
+
+p4_append_to_file() {
+	f=$1
+	p4 edit -t ktext $f &&
+	echo "/* $(date) */" >> $f &&
+	p4 submit -d "appending a line in p4" &&
+	cat $f
+}
+
+# Create some files with RCS keywords. If they get modified
+# elsewhere then the version number gets bumped which then
+# results in a merge conflict if we touch the RCS kw lines,
+# even though the change itself would otherwise apply cleanly.
+test_expect_failure 'cope with rcs keyword expansion damage' '
+	"$GITP4" clone --dest="$git" //depot &&
+	cd "$git" &&
+	git config git-p4.skipSubmitEditCheck true &&
+	create_kw_file kwfile1.c &&
+	git commit -m "Files with RCS keywords" &&
+	P4EDITOR=touch "$GITP4" commit && "$GITP4" rebase &&
+	(cd ../cli && p4_append_to_file kwfile1.c) &&
+	perl -n -i -e "print unless m/Revision:/" kwfile1.c &&
+	git add kwfile1.c &&
+	git commit -m "Zap an RCS kw line" &&
+	(echo 'w' | P4EDITOR=touch "$GITP4" submit) && "$GITP4" rebase &&
+	git diff p4/master &&
+	"$GITP4" commit &&
+	cd "$TRASH_DIRECTORY" &&
+	rm -rf "$git" && mkdir "$git"
+'
+
 
 test_expect_success 'shutdown' '
 	pid=`pgrep -f p4d` &&
-- 
1.7.1
Next: Pete Wyckoff
Message 1 of 4 in “[RFC v1] git-p4: test case for RCS keyword problem”
  1. Luke DiamandMay 9, 2011
  2. Pete WyckoffMay 9, 2011
  3. Luke DiamandMay 10, 2011
  4. Pete WyckoffMay 10, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.