You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/04/12 13:37:13 UTC

(commons-codec) branch master updated (1faf4e62 -> feeec759)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git


    from 1faf4e62 Javadoc
     new 1ff5140c Internal refactoring
     new feeec759 Add GitIdentifiers.FileMode.GIT_LINK

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../commons/codec/digest/GitIdentifiers.java       | 41 +++++++++++++---------
 1 file changed, 25 insertions(+), 16 deletions(-)


(commons-codec) 01/02: Internal refactoring

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit 1ff5140ce427f6cfa53059d292ad91f08cfe8d2c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 12 09:30:36 2026 -0400

    Internal refactoring
---
 .../commons/codec/digest/GitIdentifiers.java       | 32 +++++++++++-----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
index a2418440..1fbd80e6 100644
--- a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
+++ b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
@@ -32,7 +32,7 @@ import java.util.Set;
 import java.util.TreeSet;
 
 /**
- * Computes Git object identifiers and their generalizations described by the
+ * Computes <a href="https://git-scm.com/">Git</a> object identifiers and their generalizations described by the
  * <a href="https://www.swhid.org/swhid-specification/">SWHID specification</a>.
  *
  * <p>When the hash algorithm is SHA-1, the identifiers produced by this class are identical to those used by Git.
@@ -157,6 +157,20 @@ public class GitIdentifiers {
          */
         SYMBOLIC_LINK("120000");
 
+        private static FileMode get(final Path path) {
+            // Symbolic links first
+            if (Files.isSymbolicLink(path)) {
+                return SYMBOLIC_LINK;
+            }
+            if (Files.isDirectory(path)) {
+                return DIRECTORY;
+            }
+            if (Files.isExecutable(path)) {
+                return EXECUTABLE;
+            }
+            return REGULAR;
+        }
+
         /**
          * The octal mode as used by Git.
          */
@@ -378,20 +392,6 @@ public class GitIdentifiers {
         return getGitPrefix("blob", dataSize);
     }
 
-    private static FileMode getGitDirectoryEntryType(final Path path) {
-        // Symbolic links first
-        if (Files.isSymbolicLink(path)) {
-            return FileMode.SYMBOLIC_LINK;
-        }
-        if (Files.isDirectory(path)) {
-            return FileMode.DIRECTORY;
-        }
-        if (Files.isExecutable(path)) {
-            return FileMode.EXECUTABLE;
-        }
-        return FileMode.REGULAR;
-    }
-
     private static byte[] getGitPrefix(final String type, final long dataSize) {
         return (type + " " + dataSize + "\0").getBytes(StandardCharsets.UTF_8);
     }
@@ -404,7 +404,7 @@ public class GitIdentifiers {
         try (DirectoryStream<Path> files = Files.newDirectoryStream(directory)) {
             for (final Path path : files) {
                 final String name = Objects.toString(path.getFileName());
-                final FileMode mode = getGitDirectoryEntryType(path);
+                final FileMode mode = FileMode.get(path);
                 if (mode == FileMode.DIRECTORY) {
                     populateFromPath(builder.addDirectory(name), path);
                 } else {


(commons-codec) 02/02: Add GitIdentifiers.FileMode.GIT_LINK

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit feeec7591704b24709e8028c434c7b57a6e2d9d7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 12 09:36:17 2026 -0400

    Add GitIdentifiers.FileMode.GIT_LINK
---
 .../java/org/apache/commons/codec/digest/GitIdentifiers.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
index 1fbd80e6..84058d51 100644
--- a/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
+++ b/src/main/java/org/apache/commons/codec/digest/GitIdentifiers.java
@@ -147,6 +147,15 @@ public class GitIdentifiers {
          */
         EXECUTABLE("100755"),
 
+        /**
+         * A gitlink, SHA-1 of the object refers to a commit in another repository. Git links can only be specified either by SHA or through a commit mark. They
+         * are used to implement submodules.
+         *
+         * @see <a href="https://git-scm.com/docs/gitdatamodel">gitdatamodel - Git’s core data model</a>
+         * @see <a href="https://git-scm.com/docs/git-fast-import">git-fast-import - Backend for fast Git data importers</a>
+         */
+        GIT_LINK("160000"),
+
         /**
          * A regular (non-executable) file.
          */