GitmoduleEntry.java

  1. /*
  2.  * Copyright (C) 2018, Google LLC. 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.lib;

  11. /**
  12.  * A .gitmodules file found in the pack. Store the blob of the file itself (e.g.
  13.  * to access its contents) and the tree where it was found (e.g. to check if it
  14.  * is in the root)
  15.  *
  16.  * @since 4.7.5
  17.  */
  18. public final class GitmoduleEntry {
  19.     private final AnyObjectId treeId;

  20.     private final AnyObjectId blobId;

  21.     /**
  22.      * A record of (tree, blob) for a .gitmodule file in a pack
  23.      *
  24.      * @param treeId
  25.      *            tree id containing a .gitmodules entry
  26.      * @param blobId
  27.      *            id of the blob of the .gitmodules file
  28.      */
  29.     public GitmoduleEntry(AnyObjectId treeId, AnyObjectId blobId) {
  30.         // AnyObjectId's are reused, must keep a copy.
  31.         this.treeId = treeId.copy();
  32.         this.blobId = blobId.copy();
  33.     }

  34.     /**
  35.      * @return Id of a .gitmodules file found in the pack
  36.      */
  37.     public AnyObjectId getBlobId() {
  38.         return blobId;
  39.     }

  40.     /**
  41.      * @return Id of a tree object where the .gitmodules file was found
  42.      */
  43.     public AnyObjectId getTreeId() {
  44.         return treeId;
  45.     }
  46. }