Great.  Now, we just have to write refs/modules/<branch>/* at
commit-time.

Signed-off-by: Ramkumar Ramachandra <artag...@gmail.com>
---
 sha1_file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sha1_file.c b/sha1_file.c
index a8a6d72..2ea101a 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2874,6 +2874,7 @@ int index_path(unsigned char *sha1, const char *path, 
struct stat *st, unsigned
        char pathbuf[PATH_MAX];
        const char *submodule_gitdir;
        unsigned char checkout_rev[20];
+       char *ref_name;
 
        switch (st->st_mode & S_IFMT) {
        case S_IFREG:
@@ -2915,9 +2916,18 @@ int index_path(unsigned char *sha1, const char *path, 
struct stat *st, unsigned
                if (resolve_gitlink_ref(path, "HEAD", checkout_rev) < 0)
                        die("Unable to resolve submodule HEAD");
 
+               /* Construct a ref_name from path */
+               sprintf(pathbuf, "%s", path);
+               pathbuf[strlen(pathbuf) - 1] = '\0'; /* Remove trailing slash */
+               if (strchr(pathbuf, '/'))
+                       ref_name = xstrdup(strrchr(pathbuf, '/') + 1);
+               else
+                       ref_name = xstrdup(pathbuf);
+
                /* Add fields to the strbuf */
                strbuf_addf(&sb, "upstream_url = %s\n", (char *) upstream_url);
                strbuf_addf(&sb, "checkout_rev = %s\n", 
sha1_to_hex(checkout_rev));
+               strbuf_addf(&sb, "ref_name = %s\n", ref_name);
                if (!(flags & HASH_WRITE_OBJECT))
                        hash_sha1_file(sb.buf, sb.len, link_type, sha1);
                else if (write_sha1_file(sb.buf, sb.len, link_type, sha1))
-- 
1.8.2.380.g0d4e79b

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to