blob: e76b0bc142d1ed7bcadfb0f8676e44590b7ff11d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
* Copyright (C) 2011, Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.storage.dfs;
import java.io.IOException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.RefRename;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.RefUpdate.Result;
final class DfsRefRename extends RefRename {
DfsRefRename(RefUpdate src, RefUpdate dst) {
super(src, dst);
}
@Override
protected Result doRename() throws IOException {
// TODO Correctly handle renaming foo/bar to foo.
// TODO Batch these together into one log update.
destination.setExpectedOldObjectId(ObjectId.zeroId());
destination.setNewObjectId(source.getRef().getObjectId());
switch (destination.update()) {
case NEW:
source.delete();
return Result.RENAMED;
default:
return destination.getResult();
}
}
}
|