Initial EGit contribution to eclipse.org
[egit.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / internal / storage / KidCommit.java
blobb94faeac125a60911d000b80decb8b77cadd50c7
1 /*******************************************************************************
2 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.core.internal.storage;
11 import org.eclipse.jgit.lib.AnyObjectId;
12 import org.eclipse.jgit.revwalk.RevCommit;
14 class KidCommit extends RevCommit {
15 static final KidCommit[] NO_CHILDREN = {};
17 KidCommit[] children = NO_CHILDREN;
19 KidCommit(final AnyObjectId id) {
20 super(id);
23 void addChild(final KidCommit c) {
24 final int cnt = children.length;
25 if (cnt == 0)
26 children = new KidCommit[] { c };
27 else if (cnt == 1)
28 children = new KidCommit[] { children[0], c };
29 else {
30 final KidCommit[] n = new KidCommit[cnt + 1];
31 System.arraycopy(children, 0, n, 0, cnt);
32 n[cnt] = c;
33 children = n;
37 @Override
38 public void reset() {
39 children = NO_CHILDREN;
40 super.reset();