View Javadoc
1   /*
2    * Copyright (C) 2010, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.notes;
12  
13  import org.eclipse.jgit.lib.AnyObjectId;
14  import org.eclipse.jgit.lib.FileMode;
15  import org.eclipse.jgit.lib.ObjectId;
16  import org.eclipse.jgit.lib.TreeFormatter;
17  import org.eclipse.jgit.util.Paths;
18  
19  /** A tree entry found in a note branch that isn't a valid note. */
20  class NonNoteEntry extends ObjectId {
21  	/** Name of the entry in the tree, in raw format. */
22  	private final byte[] name;
23  
24  	/** Mode of the entry as parsed from the tree. */
25  	private final FileMode mode;
26  
27  	/** The next non-note entry in the same tree, as defined by tree order. */
28  	NonNoteEntry next;
29  
30  	NonNoteEntry(byte[] name, FileMode mode, AnyObjectId id) {
31  		super(id);
32  		this.name = name;
33  		this.mode = mode;
34  	}
35  
36  	void format(TreeFormatter fmt) {
37  		fmt.append(name, mode, this);
38  	}
39  
40  	int treeEntrySize() {
41  		return TreeFormatter.entrySize(mode, name.length);
42  	}
43  
44  	int pathCompare(byte[] bBuf, int bPos, int bLen, FileMode bMode) {
45  		return Paths.compare(
46  				name, 0, name.length, mode.getBits(),
47  				bBuf, bPos, bLen, bMode.getBits());
48  	}
49  }