You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NonNoteEntry.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. package org.eclipse.jgit.notes;
  11. import org.eclipse.jgit.lib.AnyObjectId;
  12. import org.eclipse.jgit.lib.FileMode;
  13. import org.eclipse.jgit.lib.ObjectId;
  14. import org.eclipse.jgit.lib.TreeFormatter;
  15. import org.eclipse.jgit.util.Paths;
  16. /** A tree entry found in a note branch that isn't a valid note. */
  17. class NonNoteEntry extends ObjectId {
  18. /** Name of the entry in the tree, in raw format. */
  19. private final byte[] name;
  20. /** Mode of the entry as parsed from the tree. */
  21. private final FileMode mode;
  22. /** The next non-note entry in the same tree, as defined by tree order. */
  23. NonNoteEntry next;
  24. NonNoteEntry(byte[] name, FileMode mode, AnyObjectId id) {
  25. super(id);
  26. this.name = name;
  27. this.mode = mode;
  28. }
  29. void format(TreeFormatter fmt) {
  30. fmt.append(name, mode, this);
  31. }
  32. int treeEntrySize() {
  33. return TreeFormatter.entrySize(mode, name.length);
  34. }
  35. int pathCompare(byte[] bBuf, int bPos, int bLen, FileMode bMode) {
  36. return Paths.compare(
  37. name, 0, name.length, mode.getBits(),
  38. bBuf, bPos, bLen, bMode.getBits());
  39. }
  40. }