1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Improve representation of replaced symlinks in Git

Summary:
See T584. Git renders these types of changes somewhat unusually. Ensure they are
rendered as changes.

The fact that a symlink was replaced is not explicitly rendered (e.g., "This
path was changed from a symlink to a regular file."), but can be inferred from
the 'unix:filemode' property change that will accompany the changeset. We could
also make it explicit but this type of change is rare enough that it's probably
good enough as-is.

Test Plan:
  - Ran unit test, which previously failed and now passes.
  - Created a diff which replaces a file with a symlink, verified it rendered a
little more sensibly.

Reviewers: aravindn, dschleimer, jungejason, nh, tuomaspelkonen

Reviewed By: nh

CC: aran, goldshlager, nh

Differential Revision: 1030
This commit is contained in:
epriestley 2011-10-21 12:37:40 -07:00
parent df8c0e5e25
commit a85e344425
3 changed files with 30 additions and 1 deletions

View file

@ -503,7 +503,14 @@ class ArcanistDiffParser {
}
if (!empty($match['new'])) {
$change->setType(ArcanistDiffChangeType::TYPE_ADD);
// If you replace a symlink with a normal file, git renders the change
// as a "delete" of the symlink plus an "add" of the new file. We
// prefer to represent this as a change.
if ($change->getType() == ArcanistDiffChangeType::TYPE_DELETE) {
$change->setType(ArcanistDiffChangeType::TYPE_CHANGE);
} else {
$change->setType(ArcanistDiffChangeType::TYPE_ADD);
}
}
if (!empty($match['old'])) {

View file

@ -487,6 +487,13 @@ EOTEXT
ArcanistDiffChangeType::FILE_BINARY,
$change->getFileType());
break;
case 'git-replace-symlink.gitdiff':
$this->assertEqual(1, count($changes));
$change = array_shift($changes);
$this->assertEqual(
ArcanistDiffChangeType::TYPE_CHANGE,
$change->getType());
break;
default:
throw new Exception("No test block for diff file {$diff_file}.");
break;

View file

@ -0,0 +1,15 @@
diff --git a/derp b/derp
deleted file mode 120000
index d6d9d34..0000000
--- a/derp
+++ /dev/null
@@ -1 +0,0 @@
-blah
\ No newline at end of file
diff --git a/derp b/derp
new file mode 100644
index 0000000..54a5dbc
--- /dev/null
+++ b/derp
@@ -0,0 +1 @@
+derp derp