git/builtin
Jeff King fe24d396e1 move setting of object->type to alloc_* functions
The "struct object" type implements basic object
polymorphism.  Individual instances are allocated as
concrete types (or as a union type that can store any
object), and a "struct object *" can be cast into its real
type after examining its "type" enum.  This means it is
dangerous to have a type field that does not match the
allocation (e.g., setting the type field of a "struct blob"
to "OBJ_COMMIT" would mean that a reader might read past the
allocated memory).

In most of the current code this is not a problem; the first
thing we do after allocating an object is usually to set its
type field by passing it to create_object. However, the
virtual commits we create in merge-recursive.c do not ever
get their type set. This does not seem to have caused
problems in practice, though (presumably because we always
pass around a "struct commit" pointer and never even look at
the type).

We can fix this oversight and also make it harder for future
code to get it wrong by setting the type directly in the
object allocation functions.

This will also make it easier to fix problems with commit
index allocation, as we know that any object allocated by
alloc_commit_node will meet the invariant that an object
with an OBJ_COMMIT type field will have a unique index
number.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-28 10:14:33 -07:00
..
add.c Merge branch 'fr/add-interactive-argv-array' 2014-03-28 13:51:05 -07:00
annotate.c annotate: use argv_array 2014-07-16 11:10:11 -07:00
apply.c use xmemdupz() to allocate copies of strings given by start and length 2014-07-21 10:37:02 -07:00
archive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
bisect--helper.c Replace deprecated OPT_BOOLEAN by OPT_BOOL 2013-08-05 11:32:19 -07:00
blame.c move setting of object->type to alloc_* functions 2014-07-28 10:14:33 -07:00
branch.c use wildmatch() directly without fnmatch() wrapper 2014-02-20 14:15:46 -08:00
bundle.c
cat-file.c Merge branch 'jk/warn-on-object-refname-ambiguity' 2014-03-25 11:07:36 -07:00
check-attr.c Merge branch 'jc/check-attr-honor-working-tree' into maint 2014-03-18 14:03:03 -07:00
check-ignore.c Merge branch 'dw/check-ignore-sans-index' 2013-09-20 12:37:32 -07:00
check-mailmap.c builtin: add git-check-mailmap command 2013-07-13 10:19:37 -07:00
check-ref-format.c
checkout-index.c Merge branch 'nd/lift-path-max' 2013-10-30 12:10:56 -07:00
checkout.c Merge branch 'jl/nor-or-nand-and' into maint 2014-04-09 12:03:26 -07:00
clean.c use xcalloc() to allocate zero-initialized memory 2014-07-21 10:30:21 -07:00
clone.c builtin/clone.c: detect a clone starting at a tag correctly 2014-06-23 14:31:35 -07:00
column.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
commit-tree.c commit_tree: take a pointer/len pair rather than a const strbuf 2014-06-12 10:29:41 -07:00
commit.c Merge branch 'jk/commit-buffer-length' into maint 2014-07-16 11:16:38 -07:00
config.c config: teach "git config --file -" to read from the standard input 2014-02-18 16:12:14 -08:00
count-objects.c count-objects: add -H option to humanize sizes 2013-04-10 13:27:26 -07:00
credential.c git credential fill: output the whole 'struct credential' 2012-06-25 11:56:24 -07:00
describe.c Merge branch 'nd/no-more-fnmatch' 2014-03-14 14:25:31 -07:00
diff-files.c convert read_cache_preload() to take struct pathspec 2013-07-15 10:56:08 -07:00
diff-index.c convert read_cache_preload() to take struct pathspec 2013-07-15 10:56:08 -07:00
diff-tree.c
diff.c Merge branch 'tg/diff-no-index-refactor' 2013-12-27 14:58:17 -08:00
fast-export.c commit: record buffer length in cache 2014-06-13 12:09:38 -07:00
fetch-pack.c Merge branch 'nd/shallow-clone' 2014-01-17 12:21:20 -08:00
fetch.c Merge branch 'ep/varscope' 2014-02-27 14:01:30 -08:00
fmt-merge-msg.c commit: record buffer length in cache 2014-06-13 12:09:38 -07:00
for-each-ref.c use wildmatch() directly without fnmatch() wrapper 2014-02-20 14:15:46 -08:00
fsck.c provide a helper to free commit buffer 2014-06-13 12:07:47 -07:00
gc.c Merge branch 'nd/daemonize-gc' into maint 2014-06-25 11:47:36 -07:00
get-tar-commit-id.c stop installing git-tar-tree link 2013-12-03 12:35:22 -08:00
grep.c Merge branch 'sk/spawn-less-case-insensitively-from-grep-O-i' into maint 2014-06-25 11:47:49 -07:00
hash-object.c hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP 2013-08-07 08:30:55 -07:00
help.c builtin/help.c: speed up is_git_command() by checking for builtin commands first 2014-01-06 11:26:31 -08:00
index-pack.c use xcalloc() to allocate zero-initialized memory 2014-07-21 10:30:21 -07:00
init-db.c i18n: only extract comments marked with "TRANSLATORS:" 2014-04-17 11:09:56 -07:00
log.c Merge branch 'jk/commit-buffer-length' into maint 2014-07-16 11:16:38 -07:00
ls-files.c pathspec: pass directory indicator to match_pathspec_item() 2014-02-24 14:37:19 -08:00
ls-remote.c builtin/ls-remote.c: rearrange xcalloc arguments 2014-05-27 14:00:43 -07:00
ls-tree.c pathspec: rename match_pathspec_depth() to match_pathspec() 2014-02-24 14:37:14 -08:00
mailinfo.c Merge branch 'rs/mailinfo-header-cmp' into maint 2014-06-25 11:48:23 -07:00
mailsplit.c mailsplit: sort maildir filenames more cleverly 2013-03-02 22:52:44 -08:00
merge-base.c Merge branch 'bm/merge-base-octopus-dedup' into maint 2014-02-13 13:38:59 -08:00
merge-file.c Replace deprecated OPT_BOOLEAN by OPT_BOOL 2013-08-05 11:32:19 -07:00
merge-index.c Convert "struct cache_entry *" to "const ..." wherever possible 2013-07-09 09:12:48 -07:00
merge-ours.c
merge-recursive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
merge-tree.c merge-tree: handle directory/empty conflict correctly 2013-05-06 22:17:00 -07:00
merge.c commit_tree: take a pointer/len pair rather than a const strbuf 2014-06-12 10:29:41 -07:00
mktag.c
mktree.c builtin/mktree.c: use ALLOC_GROW() in append_to_tree() 2014-03-03 14:54:45 -08:00
mv.c Merge branch 'dt/merge-recursive-case-insensitive' into maint 2014-06-25 11:48:34 -07:00
name-rev.c use wildmatch() directly without fnmatch() wrapper 2014-02-20 14:15:46 -08:00
notes.c parse-options: multi-word argh should use dash to separate words 2014-03-24 10:43:34 -07:00
pack-objects.c Merge branch 'jk/pack-bitmap' 2014-04-08 12:00:33 -07:00
pack-redundant.c Fix sizeof usage in get_permutations 2012-12-13 11:13:44 -08:00
pack-refs.c pack-refs: merge code from pack-refs.{c,h} into refs.{c,h} 2013-05-01 15:33:11 -07:00
patch-id.c
prune-packed.c i18n: mark all progress lines for translation 2014-02-24 09:08:37 -08:00
prune.c Merge branch 'mh/replace-refs-variable-rename' 2014-03-14 14:27:06 -07:00
push.c Merge branch 'cc/starts-n-ends-with-endgame' 2014-03-07 15:18:28 -08:00
read-tree.c C: have space around && and || operators 2013-10-16 10:26:39 -07:00
receive-pack.c shallow: automatically clean up shallow tempfiles 2014-02-27 12:07:13 -08:00
reflog.c use wildmatch() directly without fnmatch() wrapper 2014-02-20 14:15:46 -08:00
remote-ext.c
remote-fd.c
remote.c Merge branch 'bg/xcalloc-nmemb-then-size' into maint 2014-07-22 10:25:17 -07:00
repack.c Merge branch 'jk/repack-pack-keep-objects' into maint 2014-07-10 11:10:05 -07:00
replace.c Merge branch 'mh/replace-refs-variable-rename' 2014-03-14 14:27:06 -07:00
rerere.c rerere: fix for merge.conflictstyle 2014-04-30 10:30:02 -07:00
reset.c convert logmsg_reencode to get_commit_buffer 2014-06-13 12:08:17 -07:00
rev-list.c commit: record buffer length in cache 2014-06-13 12:09:38 -07:00
rev-parse.c rev-parse --parseopt: option argument name hints 2014-03-23 17:28:03 -07:00
revert.c parse-options: multi-word argh should use dash to separate words 2014-03-24 10:43:34 -07:00
rm.c Merge branch 'nd/submodule-pathspec-ending-with-slash' 2014-02-27 14:01:15 -08:00
send-pack.c Merge branch 'nd/shallow-clone' 2014-01-17 12:21:20 -08:00
shortlog.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
show-branch.c use wildmatch() directly without fnmatch() wrapper 2014-02-20 14:15:46 -08:00
show-ref.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
stripspace.c builtin/stripspace.c: fix broken indentation 2013-09-06 13:33:17 -07:00
symbolic-ref.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
tag.c parse-options: multi-word argh should use dash to separate words 2014-03-24 10:43:34 -07:00
unpack-file.c
unpack-objects.c Merge branch 'mh/replace-refs-variable-rename' 2014-03-14 14:27:06 -07:00
update-index.c update-index: fix segfault with missing --cacheinfo argument 2014-06-04 11:02:55 -07:00
update-ref.c update-ref: fail create operation over stdin if ref already exists 2014-04-02 10:40:43 -07:00
update-server-info.c i18n: update-server-info: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00
upload-archive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
var.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
verify-pack.c i18n: verify-pack: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00
verify-tag.c gpg_interface: allow to request status return 2013-02-14 09:30:04 -08:00
write-tree.c i18n: write-tree: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00