Merge branch 'jk/maint-null-in-trees'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 18:54:28 +0000 (11:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 18:54:28 +0000 (11:54 -0700)
We do not want a link to 0{40} object stored anywhere in our objects.

* jk/maint-null-in-trees:
  fsck: detect null sha1 in tree entries
  do not write null sha1s to on-disk index
  diff: do not use null sha1 as a sentinel value

15 files changed:
1  2 
builtin.h
builtin/blame.c
builtin/cat-file.c
builtin/diff.c
combine-diff.c
diff-no-index.c
diff.c
diff.h
diffcore-rename.c
diffcore.h
fsck.c
read-cache.c
revision.c
t/t1450-fsck.sh
tree-diff.c

diff --cc builtin.h
index ba6626b03505dd0622faea4e2bea51ed4b6720f5,47f540f37f908c7539bcdbde5dd7550af8c92e72..8e377522fee4be94f9cdca40d44ecdcc18b42d8b
+++ b/builtin.h
@@@ -40,10 -41,8 +40,10 @@@ int copy_note_for_rewrite(struct notes_
  void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c);
  
  extern int check_pager_config(const char *cmd);
 +struct diff_options;
 +extern void setup_diff_pager(struct diff_options *);
  
- extern int textconv_object(const char *path, unsigned mode, const unsigned char *sha1, char **buf, unsigned long *buf_size);
+ extern int textconv_object(const char *path, unsigned mode, const unsigned char *sha1, int sha1_valid, char **buf, unsigned long *buf_size);
  
  extern int cmd_add(int argc, const char **argv, const char *prefix);
  extern int cmd_annotate(int argc, const char **argv, const char *prefix);
diff --cc builtin/blame.c
Simple merge
Simple merge
diff --cc builtin/diff.c
Simple merge
diff --cc combine-diff.c
Simple merge
diff --cc diff-no-index.c
index b34b5aa7dfc4d1e34f64a6ade5e22be249b9517c,6568eea6f4a465a40f522584a6fcaf92841f16e7..74da659368e4db67715a9c81dc7a5e0edcd3bcce
@@@ -58,38 -51,8 +58,38 @@@ static int get_mode(const char *path, i
        return 0;
  }
  
-       fill_filespec(s, null_sha1, mode);
 +static int populate_from_stdin(struct diff_filespec *s)
 +{
 +      struct strbuf buf = STRBUF_INIT;
 +      size_t size = 0;
 +
 +      if (strbuf_read(&buf, 0, 0) < 0)
 +              return error("error while reading from stdin %s",
 +                                   strerror(errno));
 +
 +      s->should_munmap = 0;
 +      s->data = strbuf_detach(&buf, &size);
 +      s->size = size;
 +      s->should_free = 1;
 +      s->is_stdin = 1;
 +      return 0;
 +}
 +
 +static struct diff_filespec *noindex_filespec(const char *name, int mode)
 +{
 +      struct diff_filespec *s;
 +
 +      if (!name)
 +              name = "/dev/null";
 +      s = alloc_filespec(name);
++      fill_filespec(s, null_sha1, 0, mode);
 +      if (name == file_from_standard_input)
 +              populate_from_stdin(s);
 +      return s;
 +}
 +
  static int queue_diff(struct diff_options *o,
 -              const char *name1, const char *name2)
 +                    const char *name1, const char *name2)
  {
        int mode1 = 0, mode2 = 0;
  
diff --cc diff.c
Simple merge
diff --cc diff.h
Simple merge
Simple merge
diff --cc diffcore.h
Simple merge
diff --cc fsck.c
Simple merge
diff --cc read-cache.c
index 76513cdc8fbe417e189164a7e9aa1cd4646a3ac2,5ae7f2b680d8788f4c806d9c6ec111b6ba339aaa..79e3bbe0240e16629e8ba4b755d60f986132802a
@@@ -1796,10 -1615,11 +1796,12 @@@ int write_index(struct index_state *ist
                        continue;
                if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
                        ce_smudge_racily_clean_entry(ce);
 -              if (ce_write_entry(&c, newfd, ce) < 0)
+               if (is_null_sha1(ce->sha1))
+                       return error("cache entry has null sha1: %s", ce->name);
 +              if (ce_write_entry(&c, newfd, ce, previous_name) < 0)
                        return -1;
        }
 +      strbuf_release(&previous_name_buf);
  
        /* Write extension data here */
        if (istate->cache_tree) {
diff --cc revision.c
Simple merge
diff --cc t/t1450-fsck.sh
Simple merge
diff --cc tree-diff.c
Simple merge