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
}
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'])) {
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;
--- /dev/null
+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