]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sha1_name.c
(squash) test for previous
[thirdparty/git.git] / sha1_name.c
index 4f2af8da934b125f2c09ceb4d8185dabc58f7831..36c9cbf1acd94b4614f1a66e73664910309c279a 100644 (file)
@@ -659,6 +659,16 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1)
        return get_short_sha1(name, len, sha1, 0);
 }
 
+/*
+ * This interprets names like ':/Initial revision of "git"' by searching
+ * through history and returning the first commit whose message starts
+ * the given regular expression.
+ *
+ * For future extension, ':/!' is reserved. If you want to match a message
+ * beginning with a '!', you have to repeat the exclamation mark.
+ */
+#define ONELINE_SEEN (1u<<20)
+
 static int handle_one_ref(const char *path,
                const unsigned char *sha1, int flag, void *cb_data)
 {
@@ -674,19 +684,10 @@ static int handle_one_ref(const char *path,
        if (object->type != OBJ_COMMIT)
                return 0;
        insert_by_date((struct commit *)object, list);
+       object->flags |= ONELINE_SEEN;
        return 0;
 }
 
-/*
- * This interprets names like ':/Initial revision of "git"' by searching
- * through history and returning the first commit whose message matches
- * the given regular expression.
- *
- * For future extension, ':/!' is reserved. If you want to match a message
- * beginning with a '!', you have to repeat the exclamation mark.
- */
-
-#define ONELINE_SEEN (1u<<20)
 static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
 {
        struct commit_list *list = NULL, *backup = NULL, *l;
@@ -1067,6 +1068,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
                struct cache_entry *ce;
                int pos;
                if (namelen > 2 && name[1] == '/')
+                       /* don't need mode for commit */
                        return get_sha1_oneline(name + 2, sha1);
                if (namelen < 3 ||
                    name[2] != ':' ||
@@ -1094,6 +1096,7 @@ int get_sha1_with_context_1(const char *name, unsigned char *sha1,
                                break;
                        if (ce_stage(ce) == stage) {
                                hashcpy(sha1, ce->sha1);
+                               oc->mode = ce->ce_mode;
                                return 0;
                        }
                        pos++;