Fix sparse warnings
Fix warnings from 'make check'.
- These files don't include 'builtin.h' causing sparse to complain that
cmd_* isn't declared:
builtin/clone.c:364, builtin/fetch-pack.c:797,
builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
builtin/merge-index.c:69, builtin/merge-recursive.c:22
builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
builtin/notes.c:822, builtin/pack-redundant.c:596,
builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
builtin/remote.c:1512, builtin/remote-ext.c:240,
builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
builtin/unpack-file.c:25, builtin/var.c:75
- These files have symbols which should be marked static since they're
only file scope:
submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
- These files redeclare symbols to be different types:
builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
usage.c:49, usage.c:58, usage.c:63, usage.c:72
- These files use a literal integer 0 when they really should use a NULL
pointer:
daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
While we're in the area, clean up some unused #includes in builtin files
(mostly exec_cmd.h).
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-22 08:51:05 +01:00
|
|
|
#include "builtin.h"
|
2017-06-14 20:07:36 +02:00
|
|
|
#include "config.h"
|
2005-04-18 23:11:01 +02:00
|
|
|
|
2017-07-14 01:49:25 +02:00
|
|
|
static char *create_temp_file(struct object_id *oid)
|
2005-04-18 23:11:01 +02:00
|
|
|
{
|
|
|
|
static char path[50];
|
|
|
|
void *buf;
|
2007-02-26 20:55:59 +01:00
|
|
|
enum object_type type;
|
2005-04-18 23:11:01 +02:00
|
|
|
unsigned long size;
|
|
|
|
int fd;
|
|
|
|
|
2017-07-14 01:49:25 +02:00
|
|
|
buf = read_sha1_file(oid->hash, &type, &size);
|
2007-02-26 20:55:59 +01:00
|
|
|
if (!buf || type != OBJ_BLOB)
|
2017-07-14 01:49:25 +02:00
|
|
|
die("unable to read blob object %s", oid_to_hex(oid));
|
2005-04-18 23:11:01 +02:00
|
|
|
|
2015-09-24 23:06:08 +02:00
|
|
|
xsnprintf(path, sizeof(path), ".merge_file_XXXXXX");
|
2007-08-14 21:45:58 +02:00
|
|
|
fd = xmkstemp(path);
|
2007-01-08 16:58:23 +01:00
|
|
|
if (write_in_full(fd, buf, size) != size)
|
2009-06-27 17:58:47 +02:00
|
|
|
die_errno("unable to write temp-file");
|
2005-04-18 23:11:01 +02:00
|
|
|
close(fd);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2010-01-22 16:38:03 +01:00
|
|
|
int cmd_unpack_file(int argc, const char **argv, const char *prefix)
|
2005-04-18 23:11:01 +02:00
|
|
|
{
|
2017-07-14 01:49:25 +02:00
|
|
|
struct object_id oid;
|
2005-04-18 23:11:01 +02:00
|
|
|
|
2009-11-09 16:04:56 +01:00
|
|
|
if (argc != 2 || !strcmp(argv[1], "-h"))
|
2009-01-04 19:39:27 +01:00
|
|
|
usage("git unpack-file <sha1>");
|
2017-07-14 01:49:25 +02:00
|
|
|
if (get_oid(argv[1], &oid))
|
2006-05-08 23:43:38 +02:00
|
|
|
die("Not a valid object name %s", argv[1]);
|
2005-04-18 23:11:01 +02:00
|
|
|
|
2008-05-14 19:46:53 +02:00
|
|
|
git_config(git_default_config, NULL);
|
2005-11-26 09:50:02 +01:00
|
|
|
|
2017-07-14 01:49:25 +02:00
|
|
|
puts(create_temp_file(&oid));
|
2005-04-18 23:11:01 +02:00
|
|
|
return 0;
|
|
|
|
}
|