From: Junio C Hamano Date: Mon, 27 Aug 2012 18:54:28 +0000 (-0700) Subject: Merge branch 'jk/maint-null-in-trees' X-Git-Tag: v1.8.0-rc0~134 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3b753148b636be9dc821feebf85cd7f1739b07a1;p=git.git Merge branch 'jk/maint-null-in-trees' 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 --- 3b753148b636be9dc821feebf85cd7f1739b07a1 diff --cc builtin.h index ba6626b03,47f540f37..8e377522f --- a/builtin.h +++ 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 diff-no-index.c index b34b5aa7d,6568eea6f..74da65936 --- a/diff-no-index.c +++ b/diff-no-index.c @@@ -58,38 -51,8 +58,38 @@@ static int get_mode(const char *path, i return 0; } +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, mode); ++ 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 read-cache.c index 76513cdc8,5ae7f2b68..79e3bbe02 --- a/read-cache.c +++ b/read-cache.c @@@ -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 (is_null_sha1(ce->sha1)) + return error("cache entry has null sha1: %s", ce->name); - if (ce_write_entry(&c, newfd, ce) < 0) + 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) {