summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: afb4ff2)
raw | patch | inline | side by side (parent: afb4ff2)
author | Dmitry V. Levin <ldv@altlinux.org> | |
Mon, 8 May 2006 21:43:38 +0000 (01:43 +0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 8 May 2006 23:25:33 +0000 (16:25 -0700) |
Separate object name errors from usage errors.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
13 files changed:
cat-file.c | patch | blob | history | |
commit-tree.c | patch | blob | history | |
convert-objects.c | patch | blob | history | |
describe.c | patch | blob | history | |
ls-tree.c | patch | blob | history | |
merge-base.c | patch | blob | history | |
merge-tree.c | patch | blob | history | |
read-tree.c | patch | blob | history | |
revision.c | patch | blob | history | |
ssh-upload.c | patch | blob | history | |
tar-tree.c | patch | blob | history | |
unpack-file.c | patch | blob | history | |
update-ref.c | patch | blob | history |
diff --git a/cat-file.c b/cat-file.c
index 628f6cada89431acd23d612f7e0b10649348e088..7413feed78f20feb635ad55f098c59a2afc2a54c 100644 (file)
--- a/cat-file.c
+++ b/cat-file.c
setup_git_directory();
git_config(git_default_config);
- if (argc != 3 || get_sha1(argv[2], sha1))
+ if (argc != 3)
usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
+ if (get_sha1(argv[2], sha1))
+ die("Not a valid object name %s", argv[2]);
opt = 0;
if ( argv[1][0] == '-' ) {
return !has_sha1_file(sha1);
case 'p':
- if (get_sha1(argv[2], sha1) ||
- sha1_object_info(sha1, type, NULL))
+ if (sha1_object_info(sha1, type, NULL))
die("Not a valid object name %s", argv[2]);
/* custom pretty-print here */
diff --git a/commit-tree.c b/commit-tree.c
index 25958509703f7e46dc0b1a4bffd7be8ba2897cf9..0320036e802f820760dd197f745698acb5531bbb 100644 (file)
--- a/commit-tree.c
+++ b/commit-tree.c
git_config(git_default_config);
- if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0)
+ if (argc < 2)
usage(commit_tree_usage);
+ if (get_sha1(argv[1], tree_sha1))
+ die("Not a valid object name %s", argv[1]);
check_valid(tree_sha1, tree_type);
for (i = 2; i < argc; i += 2) {
char *a, *b;
a = argv[i]; b = argv[i+1];
- if (!b || strcmp(a, "-p") || get_sha1(b, parent_sha1[parents]))
+ if (!b || strcmp(a, "-p"))
usage(commit_tree_usage);
+ if (get_sha1(b, parent_sha1[parents]))
+ die("Not a valid object name %s", b);
check_valid(parent_sha1[parents], commit_type);
if (new_parent(parents))
parents++;
diff --git a/convert-objects.c b/convert-objects.c
index 12aacef5a9c06adec2e7abb7c11051acc954225a..a67d6b479ec57816de1b259f9efed2258e999703 100644 (file)
--- a/convert-objects.c
+++ b/convert-objects.c
setup_git_directory();
- if (argc != 2 || get_sha1(argv[1], sha1))
+ if (argc != 2)
usage("git-convert-objects <sha1>");
+ if (get_sha1(argv[1], sha1))
+ die("Not a valid object name %s", argv[1]);
entry = convert_entry(sha1);
printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
diff --git a/describe.c b/describe.c
index ff65742615cb6862d3699e4f301d671a7eadc2e2..8a9cd5d52c555330c512b977179ab030ccd28861 100644 (file)
--- a/describe.c
+++ b/describe.c
static int initialized = 0;
struct commit_name *n;
- if (get_sha1(arg, sha1) < 0)
- usage(describe_usage);
+ if (get_sha1(arg, sha1))
+ die("Not a valid object name %s", arg);
cmit = lookup_commit_reference(sha1);
if (!cmit)
- usage(describe_usage);
+ die("%s is not a valid '%s' object", arg, commit_type);
if (!initialized) {
initialized = 1;
diff --git a/ls-tree.c b/ls-tree.c
index e4ef200985030e8dee6f23dbe723bfa476160db0..f2b3bc1231b7fdfd7277974fc5a5708ceef9cbaf 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
if (argc < 2)
usage(ls_tree_usage);
- if (get_sha1(argv[1], sha1) < 0)
- usage(ls_tree_usage);
+ if (get_sha1(argv[1], sha1))
+ die("Not a valid object name %s", argv[1]);
pathspec = get_pathspec(prefix, argv + 2);
tree = parse_tree_indirect(sha1);
diff --git a/merge-base.c b/merge-base.c
index 07f5ab4d1c72afeac5e3f193cefe91801ee9a9c9..f0dc06ef5546b148fe20d3b1061c7eae0d262cce 100644 (file)
--- a/merge-base.c
+++ b/merge-base.c
usage(merge_base_usage);
argc--; argv++;
}
- if (argc != 3 ||
- get_sha1(argv[1], rev1key) ||
- get_sha1(argv[2], rev2key))
+ if (argc != 3)
usage(merge_base_usage);
+ if (get_sha1(argv[1], rev1key))
+ die("Not a valid object name %s", argv[1]);
+ if (get_sha1(argv[2], rev2key))
+ die("Not a valid object name %s", argv[2]);
rev1 = lookup_commit_reference(rev1key);
rev2 = lookup_commit_reference(rev2key);
if (!rev1 || !rev2)
diff --git a/merge-tree.c b/merge-tree.c
index 50528d5e438c62be409a9f7d252cedadfd52b15e..47181d422cd8b5ef0a01a52aede67b34034784d3 100644 (file)
--- a/merge-tree.c
+++ b/merge-tree.c
unsigned char sha1[20];
void *buf;
- if (get_sha1(rev, sha1) < 0)
+ if (get_sha1(rev, sha1))
die("unknown rev %s", rev);
buf = fill_tree_descriptor(desc, sha1);
if (!buf)
diff --git a/read-tree.c b/read-tree.c
index 26f4f7e32308d6e60d6a6e2c294bda322b34fc05..e926e4c880363469c5abf766127acc466fb5e438 100644 (file)
--- a/read-tree.c
+++ b/read-tree.c
if (1 < index_only + update)
usage(read_tree_usage);
- if (get_sha1(arg, sha1) < 0)
- usage(read_tree_usage);
+ if (get_sha1(arg, sha1))
+ die("Not a valid object name %s", arg);
if (list_tree(sha1) < 0)
die("failed to unpack tree object %s", arg);
stage++;
diff --git a/revision.c b/revision.c
index 5f2f0be3825e521152448a9bb47a17c79951d56b..d41e59b9ccbe30d0589d52d73e0c7bef26394a23 100644 (file)
--- a/revision.c
+++ b/revision.c
@@ -674,7 +674,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
local_flags = UNINTERESTING;
arg++;
}
- if (get_sha1(arg, sha1) < 0) {
+ if (get_sha1(arg, sha1)) {
int j;
if (seen_dashdash || local_flags)
@@ -693,7 +693,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
if (def && !revs->commits) {
unsigned char sha1[20];
struct commit *commit;
- if (get_sha1(def, sha1) < 0)
+ if (get_sha1(def, sha1))
die("bad default revision '%s'", def);
commit = get_commit_reference(revs, def, sha1, 0);
add_one_commit(commit, revs);
diff --git a/ssh-upload.c b/ssh-upload.c
index b675a0b1f1df7d313f8201d59ad25b1c3d53a2f4..2da66618fcdd6a0f5af35c9f30554a65eb427427 100644 (file)
--- a/ssh-upload.c
+++ b/ssh-upload.c
commit_id = argv[arg];
url = argv[arg + 1];
if (get_sha1(commit_id, sha1))
- usage(ssh_push_usage);
+ die("Not a valid object name %s", commit_id);
memcpy(hex, sha1_to_hex(sha1), sizeof(hex));
argv[arg] = hex;
diff --git a/tar-tree.c b/tar-tree.c
index fc60a90873d1928ce3ada6d26f0a0ae571d43773..33087366c350655fe92837ba0fe0b3ac80865f33 100644 (file)
--- a/tar-tree.c
+++ b/tar-tree.c
strbuf_append_string(¤t_path, "/");
/* FALLTHROUGH */
case 2:
- if (get_sha1(argv[1], sha1) < 0)
- usage(tar_tree_usage);
+ if (get_sha1(argv[1], sha1))
+ die("Not a valid object name %s", argv[1]);
break;
default:
usage(tar_tree_usage);
diff --git a/unpack-file.c b/unpack-file.c
index 23a85623019c3b7a465fba86132df3f4b75d94a5..ccddf1d4b0cf7fd3a699d8b33cf5bc4c5c4435b7 100644 (file)
--- a/unpack-file.c
+++ b/unpack-file.c
{
unsigned char sha1[20];
- if (argc != 2 || get_sha1(argv[1], sha1))
+ if (argc != 2)
usage("git-unpack-file <sha1>");
+ if (get_sha1(argv[1], sha1))
+ die("Not a valid object name %s", argv[1]);
setup_git_directory();
git_config(git_default_config);
diff --git a/update-ref.c b/update-ref.c
index ba4bf5153efb38914f66658c59784b58d8b69a0a..fd487421cd36763dd94f5439b3c40d0ed97c2c96 100644 (file)
--- a/update-ref.c
+++ b/update-ref.c
refname = argv[1];
value = argv[2];
oldval = argv[3];
- if (get_sha1(value, sha1) < 0)
+ if (get_sha1(value, sha1))
die("%s: not a valid SHA1", value);
memset(oldsha1, 0, 20);
- if (oldval && get_sha1(oldval, oldsha1) < 0)
+ if (oldval && get_sha1(oldval, oldsha1))
die("%s: not a valid old SHA1", oldval);
path = resolve_ref(git_path("%s", refname), currsha1, !!oldval);