'git foo' program identifies itself without dash in die() messages

This is a mechanical conversion of all '*.c' files with:

	s/((?:die|error|warning)\("git)-(\S+:)/$1 $2/;

The result was manually inspected and no false positive was found.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Junio C Hamano 2008-08-31 09:39:19 -07:00
parent 34baebcee1
commit 7e44c93558
15 changed files with 52 additions and 52 deletions

View File

@ -506,17 +506,17 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
name = orig_name; name = orig_name;
len = strlen(name); len = strlen(name);
if (isnull) if (isnull)
die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr); die("git apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
another = find_name(line, NULL, p_value, TERM_TAB); another = find_name(line, NULL, p_value, TERM_TAB);
if (!another || memcmp(another, name, len)) if (!another || memcmp(another, name, len))
die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr); die("git apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
free(another); free(another);
return orig_name; return orig_name;
} }
else { else {
/* expect "/dev/null" */ /* expect "/dev/null" */
if (memcmp("/dev/null", line, 9) || line[9] != '\n') if (memcmp("/dev/null", line, 9) || line[9] != '\n')
die("git-apply: bad git-diff - expected /dev/null on line %d", linenr); die("git apply: bad git-diff - expected /dev/null on line %d", linenr);
return NULL; return NULL;
} }
} }

View File

@ -258,9 +258,9 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
const char *p; const char *p;


if (all) if (all)
die("git-checkout-index: don't mix '--all' and explicit filenames"); die("git checkout-index: don't mix '--all' and explicit filenames");
if (read_from_stdin) if (read_from_stdin)
die("git-checkout-index: don't mix '--stdin' and explicit filenames"); die("git checkout-index: don't mix '--stdin' and explicit filenames");
p = prefix_path(prefix, prefix_length, arg); p = prefix_path(prefix, prefix_length, arg);
checkout_file(p, prefix_length); checkout_file(p, prefix_length);
if (p < arg || p > arg + strlen(arg)) if (p < arg || p > arg + strlen(arg))
@ -271,7 +271,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
struct strbuf buf, nbuf; struct strbuf buf, nbuf;


if (all) if (all)
die("git-checkout-index: don't mix '--all' and '--stdin'"); die("git checkout-index: don't mix '--all' and '--stdin'");


strbuf_init(&buf, 0); strbuf_init(&buf, 0);
strbuf_init(&nbuf, 0); strbuf_init(&nbuf, 0);

View File

@ -118,7 +118,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
} }


if (strbuf_read(&buffer, 0, 0) < 0) if (strbuf_read(&buffer, 0, 0) < 0)
die("git-commit-tree: read returned %s", strerror(errno)); die("git commit-tree: read returned %s", strerror(errno));


if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1)) { if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1)) {
printf("%s\n", sha1_to_hex(commit_sha1)); printf("%s\n", sha1_to_hex(commit_sha1));

View File

@ -609,7 +609,7 @@ static struct ref *do_fetch_pack(int fd[2],
fprintf(stderr, "warning: no common commits\n"); fprintf(stderr, "warning: no common commits\n");


if (get_pack(fd, pack_lockfile)) if (get_pack(fd, pack_lockfile))
die("git-fetch-pack: fetch failed."); die("git fetch-pack: fetch failed.");


all_done: all_done:
return ref; return ref;

View File

@ -774,7 +774,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
/* Make sure we do not get outside of paths */ /* Make sure we do not get outside of paths */
for (i = 0; paths[i]; i++) for (i = 0; paths[i]; i++)
if (strncmp(prefix, paths[i], opt.prefix_length)) if (strncmp(prefix, paths[i], opt.prefix_length))
die("git-grep: cannot generate relative filenames containing '..'"); die("git grep: cannot generate relative filenames containing '..'");
} }
} }
else if (prefix) { else if (prefix) {

View File

@ -78,7 +78,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
int offset = prefix_offset; int offset = prefix_offset;


if (len >= ent->len) if (len >= ent->len)
die("git-ls-files: internal error - directory entry not superset of prefix"); die("git ls-files: internal error - directory entry not superset of prefix");


if (pathspec && !pathspec_match(pathspec, ps_matched, ent->name, len)) if (pathspec && !pathspec_match(pathspec, ps_matched, ent->name, len))
return; return;
@ -183,7 +183,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
int offset = prefix_offset; int offset = prefix_offset;


if (len >= ce_namelen(ce)) if (len >= ce_namelen(ce))
die("git-ls-files: internal error - cache entry not superset of prefix"); die("git ls-files: internal error - cache entry not superset of prefix");


if (pathspec && !pathspec_match(pathspec, ps_matched, ce->name, len)) if (pathspec && !pathspec_match(pathspec, ps_matched, ce->name, len))
return; return;
@ -319,7 +319,7 @@ static const char *verify_pathspec(const char *prefix)
} }


if (prefix_offset > max || memcmp(prev, prefix, prefix_offset)) if (prefix_offset > max || memcmp(prev, prefix, prefix_offset))
die("git-ls-files: cannot generate relative filenames containing '..'"); die("git ls-files: cannot generate relative filenames containing '..'");


prefix_len = max; prefix_len = max;
return max ? xmemdupz(prev, max) : NULL; return max ? xmemdupz(prev, max) : NULL;

View File

@ -221,7 +221,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
printf("rm '%s'\n", path); printf("rm '%s'\n", path);


if (remove_file_from_cache(path)) if (remove_file_from_cache(path))
die("git-rm: unable to remove %s", path); die("git rm: unable to remove %s", path);
} }


if (show_only) if (show_only)
@ -244,7 +244,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
continue; continue;
} }
if (!removed) if (!removed)
die("git-rm: %s: %s", path, strerror(errno)); die("git rm: %s: %s", path, strerror(errno));
} }
} }



View File

@ -62,7 +62,7 @@ match:
* ref points at a nonexistent object. * ref points at a nonexistent object.
*/ */
if (!has_sha1_file(sha1)) if (!has_sha1_file(sha1))
die("git-show-ref: bad ref %s (%s)", refname, die("git show-ref: bad ref %s (%s)", refname,
sha1_to_hex(sha1)); sha1_to_hex(sha1));


if (quiet) if (quiet)
@ -82,12 +82,12 @@ match:
else { else {
obj = parse_object(sha1); obj = parse_object(sha1);
if (!obj) if (!obj)
die("git-show-ref: bad ref %s (%s)", refname, die("git show-ref: bad ref %s (%s)", refname,
sha1_to_hex(sha1)); sha1_to_hex(sha1));
if (obj->type == OBJ_TAG) { if (obj->type == OBJ_TAG) {
obj = deref_tag(obj, refname, 0); obj = deref_tag(obj, refname, 0);
if (!obj) if (!obj)
die("git-show-ref: bad tag at ref %s (%s)", refname, die("git show-ref: bad tag at ref %s (%s)", refname,
sha1_to_hex(sha1)); sha1_to_hex(sha1));
hex = find_unique_abbrev(obj->sha1, abbrev); hex = find_unique_abbrev(obj->sha1, abbrev);
printf("%s %s^{}\n", hex, refname); printf("%s %s^{}\n", hex, refname);

View File

@ -76,7 +76,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)


n = read_in_full(0, buffer, HEADERSIZE); n = read_in_full(0, buffer, HEADERSIZE);
if (n < HEADERSIZE) if (n < HEADERSIZE)
die("git-get-tar-commit-id: read error"); die("git get-tar-commit-id: read error");
if (header->typeflag[0] != 'g') if (header->typeflag[0] != 'g')
return 1; return 1;
if (memcmp(content, "52 comment=", 11)) if (memcmp(content, "52 comment=", 11))
@ -84,7 +84,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)


n = write_in_full(1, content + 11, 41); n = write_in_full(1, content + 11, 41);
if (n < 41) if (n < 41)
die("git-get-tar-commit-id: write error"); die("git get-tar-commit-id: write error");


return 0; return 0;
} }

View File

@ -262,7 +262,7 @@ static void chmod_path(int flip, const char *path)
report("chmod %cx '%s'", flip, path); report("chmod %cx '%s'", flip, path);
return; return;
fail: fail:
die("git-update-index: cannot chmod %cx '%s'", flip, path); die("git update-index: cannot chmod %cx '%s'", flip, path);
} }


static void update_one(const char *path, const char *prefix, int prefix_length) static void update_one(const char *path, const char *prefix, int prefix_length)
@ -280,7 +280,7 @@ static void update_one(const char *path, const char *prefix, int prefix_length)


if (force_remove) { if (force_remove) {
if (remove_file_from_cache(p)) if (remove_file_from_cache(p))
die("git-update-index: unable to remove %s", path); die("git update-index: unable to remove %s", path);
report("remove '%s'", path); report("remove '%s'", path);
goto free_return; goto free_return;
} }
@ -351,7 +351,7 @@ static void read_index_info(int line_termination)
if (line_termination && path_name[0] == '"') { if (line_termination && path_name[0] == '"') {
strbuf_reset(&uq); strbuf_reset(&uq);
if (unquote_c_style(&uq, path_name, NULL)) { if (unquote_c_style(&uq, path_name, NULL)) {
die("git-update-index: bad quoting of path name"); die("git update-index: bad quoting of path name");
} }
path_name = uq.buf; path_name = uq.buf;
} }
@ -364,7 +364,7 @@ static void read_index_info(int line_termination)
if (!mode) { if (!mode) {
/* mode == 0 means there is no such path -- remove */ /* mode == 0 means there is no such path -- remove */
if (remove_file_from_cache(path_name)) if (remove_file_from_cache(path_name))
die("git-update-index: unable to remove %s", die("git update-index: unable to remove %s",
ptr); ptr);
} }
else { else {
@ -374,7 +374,7 @@ static void read_index_info(int line_termination)
*/ */
ptr[-42] = ptr[-1] = 0; ptr[-42] = ptr[-1] = 0;
if (add_cacheinfo(mode, sha1, path_name, stage)) if (add_cacheinfo(mode, sha1, path_name, stage))
die("git-update-index: unable to update %s", die("git update-index: unable to update %s",
path_name); path_name);
} }
continue; continue;
@ -626,12 +626,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
unsigned int mode; unsigned int mode;


if (i+3 >= argc) if (i+3 >= argc)
die("git-update-index: --cacheinfo <mode> <sha1> <path>"); die("git update-index: --cacheinfo <mode> <sha1> <path>");


if (strtoul_ui(argv[i+1], 8, &mode) || if (strtoul_ui(argv[i+1], 8, &mode) ||
get_sha1_hex(argv[i+2], sha1) || get_sha1_hex(argv[i+2], sha1) ||
add_cacheinfo(mode, sha1, argv[i+3], 0)) add_cacheinfo(mode, sha1, argv[i+3], 0))
die("git-update-index: --cacheinfo" die("git update-index: --cacheinfo"
" cannot add %s", argv[i+3]); " cannot add %s", argv[i+3]);
i += 3; i += 3;
continue; continue;
@ -639,7 +639,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
if (!strcmp(path, "--chmod=-x") || if (!strcmp(path, "--chmod=-x") ||
!strcmp(path, "--chmod=+x")) { !strcmp(path, "--chmod=+x")) {
if (argc <= i+1) if (argc <= i+1)
die("git-update-index: %s <path>", path); die("git update-index: %s <path>", path);
set_executable_bit = path[8]; set_executable_bit = path[8];
continue; continue;
} }

View File

@ -97,7 +97,7 @@ int get_ack(int fd, unsigned char *result_sha1)
int len = packet_read_line(fd, line, sizeof(line)); int len = packet_read_line(fd, line, sizeof(line));


if (!len) if (!len)
die("git-fetch-pack: expected ACK/NAK, got EOF"); die("git fetch-pack: expected ACK/NAK, got EOF");
if (line[len-1] == '\n') if (line[len-1] == '\n')
line[--len] = 0; line[--len] = 0;
if (!strcmp(line, "NAK")) if (!strcmp(line, "NAK"))
@ -109,7 +109,7 @@ int get_ack(int fd, unsigned char *result_sha1)
return 1; return 1;
} }
} }
die("git-fetch_pack: expected ACK/NAK, got '%s'", line); die("git fetch_pack: expected ACK/NAK, got '%s'", line);
} }


int path_match(const char *path, int nr, char **match) int path_match(const char *path, int nr, char **match)

20
entry.c
View File

@ -111,7 +111,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
case S_IFREG: case S_IFREG:
new = read_blob_entry(ce, path, &size); new = read_blob_entry(ce, path, &size);
if (!new) if (!new)
return error("git-checkout-index: unable to read sha1 file of %s (%s)", return error("git checkout-index: unable to read sha1 file of %s (%s)",
path, sha1_to_hex(ce->sha1)); path, sha1_to_hex(ce->sha1));


/* /*
@ -132,7 +132,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
fd = create_file(path, ce->ce_mode); fd = create_file(path, ce->ce_mode);
if (fd < 0) { if (fd < 0) {
free(new); free(new);
return error("git-checkout-index: unable to create file %s (%s)", return error("git checkout-index: unable to create file %s (%s)",
path, strerror(errno)); path, strerror(errno));
} }


@ -140,12 +140,12 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
close(fd); close(fd);
free(new); free(new);
if (wrote != size) if (wrote != size)
return error("git-checkout-index: unable to write file %s", path); return error("git checkout-index: unable to write file %s", path);
break; break;
case S_IFLNK: case S_IFLNK:
new = read_blob_entry(ce, path, &size); new = read_blob_entry(ce, path, &size);
if (!new) if (!new)
return error("git-checkout-index: unable to read sha1 file of %s (%s)", return error("git checkout-index: unable to read sha1 file of %s (%s)",
path, sha1_to_hex(ce->sha1)); path, sha1_to_hex(ce->sha1));
if (to_tempfile || !has_symlinks) { if (to_tempfile || !has_symlinks) {
if (to_tempfile) { if (to_tempfile) {
@ -155,31 +155,31 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
fd = create_file(path, 0666); fd = create_file(path, 0666);
if (fd < 0) { if (fd < 0) {
free(new); free(new);
return error("git-checkout-index: unable to create " return error("git checkout-index: unable to create "
"file %s (%s)", path, strerror(errno)); "file %s (%s)", path, strerror(errno));
} }
wrote = write_in_full(fd, new, size); wrote = write_in_full(fd, new, size);
close(fd); close(fd);
free(new); free(new);
if (wrote != size) if (wrote != size)
return error("git-checkout-index: unable to write file %s", return error("git checkout-index: unable to write file %s",
path); path);
} else { } else {
wrote = symlink(new, path); wrote = symlink(new, path);
free(new); free(new);
if (wrote) if (wrote)
return error("git-checkout-index: unable to create " return error("git checkout-index: unable to create "
"symlink %s (%s)", path, strerror(errno)); "symlink %s (%s)", path, strerror(errno));
} }
break; break;
case S_IFGITLINK: case S_IFGITLINK:
if (to_tempfile) if (to_tempfile)
return error("git-checkout-index: cannot create temporary subproject %s", path); return error("git checkout-index: cannot create temporary subproject %s", path);
if (mkdir(path, 0777) < 0) if (mkdir(path, 0777) < 0)
return error("git-checkout-index: cannot create subproject directory %s", path); return error("git checkout-index: cannot create subproject directory %s", path);
break; break;
default: default:
return error("git-checkout-index: unknown file mode for %s", path); return error("git checkout-index: unknown file mode for %s", path);
} }


if (state->refresh_cache) { if (state->refresh_cache) {

View File

@ -27,7 +27,7 @@ static int merge_entry(int pos, const char *path)
int found; int found;


if (pos >= active_nr) if (pos >= active_nr)
die("git-merge-index: %s not in the cache", path); die("git merge-index: %s not in the cache", path);
arguments[0] = pgm; arguments[0] = pgm;
arguments[1] = ""; arguments[1] = "";
arguments[2] = ""; arguments[2] = "";
@ -53,7 +53,7 @@ static int merge_entry(int pos, const char *path)
arguments[stage + 4] = ownbuf[stage]; arguments[stage + 4] = ownbuf[stage];
} while (++pos < active_nr); } while (++pos < active_nr);
if (!found) if (!found)
die("git-merge-index: %s not in the cache", path); die("git merge-index: %s not in the cache", path);
run_program(); run_program();
return found; return found;
} }
@ -117,7 +117,7 @@ int main(int argc, char **argv)
merge_all(); merge_all();
continue; continue;
} }
die("git-merge-index: unknown option %s", arg); die("git merge-index: unknown option %s", arg);
} }
merge_file(arg); merge_file(arg);
} }

View File

@ -303,7 +303,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru
update_tree_entry(t2); update_tree_entry(t2);
continue; continue;
} }
die("git-diff-tree: internal error"); die("git diff-tree: internal error");
} }
return 0; return 0;
} }

View File

@ -157,7 +157,7 @@ static void create_pack_file(void)
/* .data is just a boolean: any non-NULL value will do */ /* .data is just a boolean: any non-NULL value will do */
rev_list.data = create_full_pack ? &rev_list : NULL; rev_list.data = create_full_pack ? &rev_list : NULL;
if (start_async(&rev_list)) if (start_async(&rev_list))
die("git-upload-pack: unable to fork git-rev-list"); die("git upload-pack: unable to fork git-rev-list");


argv[arg++] = "pack-objects"; argv[arg++] = "pack-objects";
argv[arg++] = "--stdout"; argv[arg++] = "--stdout";
@ -177,7 +177,7 @@ static void create_pack_file(void)
pack_objects.argv = argv; pack_objects.argv = argv;


if (start_command(&pack_objects)) if (start_command(&pack_objects))
die("git-upload-pack: unable to fork git-pack-objects"); die("git upload-pack: unable to fork git-pack-objects");


/* We read from pack_objects.err to capture stderr output for /* We read from pack_objects.err to capture stderr output for
* progress bar, and pack_objects.out to capture the pack data. * progress bar, and pack_objects.out to capture the pack data.
@ -271,7 +271,7 @@ static void create_pack_file(void)
} }


if (finish_command(&pack_objects)) { if (finish_command(&pack_objects)) {
error("git-upload-pack: git-pack-objects died with error."); error("git upload-pack: git-pack-objects died with error.");
goto fail; goto fail;
} }
if (finish_async(&rev_list)) if (finish_async(&rev_list))
@ -291,7 +291,7 @@ static void create_pack_file(void)


fail: fail:
send_client_data(3, abort_msg, sizeof(abort_msg)); send_client_data(3, abort_msg, sizeof(abort_msg));
die("git-upload-pack: %s", abort_msg); die("git upload-pack: %s", abort_msg);
} }


static int got_sha1(char *hex, unsigned char *sha1) static int got_sha1(char *hex, unsigned char *sha1)
@ -300,7 +300,7 @@ static int got_sha1(char *hex, unsigned char *sha1)
int we_knew_they_have = 0; int we_knew_they_have = 0;


if (get_sha1_hex(hex, sha1)) if (get_sha1_hex(hex, sha1))
die("git-upload-pack: expected SHA1 object, got '%s'", hex); die("git upload-pack: expected SHA1 object, got '%s'", hex);
if (!has_sha1_file(sha1)) if (!has_sha1_file(sha1))
return -1; return -1;


@ -440,7 +440,7 @@ static int get_common_commits(void)
packet_write(1, "NAK\n"); packet_write(1, "NAK\n");
return -1; return -1;
} }
die("git-upload-pack: expected SHA1 list, got '%s'", line); die("git upload-pack: expected SHA1 list, got '%s'", line);
} }
} }


@ -485,7 +485,7 @@ static void receive_needs(void)
} }
if (prefixcmp(line, "want ") || if (prefixcmp(line, "want ") ||
get_sha1_hex(line+5, sha1_buf)) get_sha1_hex(line+5, sha1_buf))
die("git-upload-pack: protocol error, " die("git upload-pack: protocol error, "
"expected to get sha, not '%s'", line); "expected to get sha, not '%s'", line);
if (strstr(line+45, "multi_ack")) if (strstr(line+45, "multi_ack"))
multi_ack = 1; multi_ack = 1;
@ -512,7 +512,7 @@ static void receive_needs(void)
*/ */
o = lookup_object(sha1_buf); o = lookup_object(sha1_buf);
if (!o || !(o->flags & OUR_REF)) if (!o || !(o->flags & OUR_REF))
die("git-upload-pack: not our ref %s", line+5); die("git upload-pack: not our ref %s", line+5);
if (!(o->flags & WANTED)) { if (!(o->flags & WANTED)) {
o->flags |= WANTED; o->flags |= WANTED;
add_object_array(o, NULL, &want_obj); add_object_array(o, NULL, &want_obj);
@ -577,7 +577,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
struct object *o = parse_object(sha1); struct object *o = parse_object(sha1);


if (!o) if (!o)
die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1)); die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));


if (capabilities) if (capabilities)
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname, packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,