Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2009 23:50:31 +0000 (16:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Apr 2009 23:50:31 +0000 (16:50 -0700)
* maint:
diff -c -p: do not die on submodules

Conflicts:
combine-diff.c

1  2 
combine-diff.c
diff --combined combine-diff.c
index 066ce841ed76e03dd87e789f6688cc3f5411ba64,0b071b6e256fa655b51f9e484f0633a7f055dd25..d210656861dcd6568e1228f39dff042ab374a584
@@@ -6,6 -6,7 +6,7 @@@
  #include "quote.h"
  #include "xdiff-interface.h"
  #include "log-tree.h"
+ #include "refs.h"
  
  static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, int n, int num_parent)
  {
@@@ -90,18 -91,24 +91,24 @@@ struct sline 
        unsigned long *p_lno;
  };
  
- static char *grab_blob(const unsigned char *sha1, unsigned long *size)
+ static char *grab_blob(const unsigned char *sha1, unsigned int mode, unsigned long *size)
  {
        char *blob;
        enum object_type type;
-       if (is_null_sha1(sha1)) {
+       if (S_ISGITLINK(mode)) {
+               blob = xmalloc(100);
+               *size = snprintf(blob, 100,
+                                "Subproject commit %s\n", sha1_to_hex(sha1));
+       } else if (is_null_sha1(sha1)) {
                /* deleted blob */
                *size = 0;
                return xcalloc(1, 1);
+       } else {
+               blob = read_sha1_file(sha1, &type, size);
+               if (type != OBJ_BLOB)
+                       die("object '%s' is not a blob!", sha1_to_hex(sha1));
        }
-       blob = read_sha1_file(sha1, &type, size);
-       if (type != OBJ_BLOB)
-               die("object '%s' is not a blob!", sha1_to_hex(sha1));
        return blob;
  }
  
@@@ -195,7 -202,8 +202,8 @@@ static void consume_line(void *state_, 
        }
  }
  
- static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
+ static void combine_diff(const unsigned char *parent, unsigned int mode,
+                        mmfile_t *result_file,
                         struct sline *sline, unsigned int cnt, int n,
                         int num_parent)
  {
        if (!cnt)
                return; /* result deleted */
  
-       parent_file.ptr = grab_blob(parent, &sz);
+       parent_file.ptr = grab_blob(parent, mode, &sz);
        parent_file.size = sz;
        memset(&xpp, 0, sizeof(xpp));
        xpp.flags = XDF_NEED_MINIMAL;
@@@ -526,6 -534,7 +534,6 @@@ static void dump_sline(struct sline *sl
                return; /* result deleted */
  
        while (1) {
 -              struct sline *sl = &sline[lno];
                unsigned long hunk_end;
                unsigned long rlines;
                const char *hunk_comment = NULL;
                        struct lline *ll;
                        int j;
                        unsigned long p_mask;
 -                      sl = &sline[lno++];
 +                      struct sline *sl = &sline[lno++];
                        ll = (sl->flag & no_pre_delete) ? NULL : sl->lost_head;
                        while (ll) {
                                fputs(c_old, stdout);
@@@ -692,7 -701,7 +700,7 @@@ static void show_patch_diff(struct comb
  
        /* Read the result of merge first */
        if (!working_tree_file)
-               result = grab_blob(elem->sha1, &result_size);
+               result = grab_blob(elem->sha1, elem->mode, &result_size);
        else {
                /* Used by diff-tree to read from the working tree */
                struct stat st;
                        result_size = buf.len;
                        result = strbuf_detach(&buf, NULL);
                        elem->mode = canon_mode(st.st_mode);
+               } else if (S_ISDIR(st.st_mode)) {
+                       unsigned char sha1[20];
+                       if (resolve_gitlink_ref(elem->path, "HEAD", sha1) < 0)
+                               result = grab_blob(elem->sha1, elem->mode, &result_size);
+                       else
+                               result = grab_blob(sha1, elem->mode, &result_size);
                } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
                        size_t len = xsize_t(st.st_size);
                        ssize_t done;
                        }
                }
                if (i <= j)
-                       combine_diff(elem->parent[i].sha1, &result_file, sline,
+                       combine_diff(elem->parent[i].sha1,
+                                    elem->parent[i].mode,
+                                    &result_file, sline,
                                     cnt, i, num_parent);
                if (elem->parent[i].mode != elem->mode)
                        mode_differs = 1;