Skip to content

Commit 909d549

Browse files
author
Edward Thomson
committed
giterr_set: consistent error messages
Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
1 parent 238b8cc commit 909d549

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+496
-496
lines changed

src/apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static int apply_hunk(
173173
git_diff_line *line = git_array_get(patch->lines, linenum);
174174

175175
if (!line) {
176-
error = apply_err("Preimage does not contain line %"PRIuZ, linenum);
176+
error = apply_err("preimage does not contain line %"PRIuZ, linenum);
177177
goto done;
178178
}
179179

@@ -193,7 +193,7 @@ static int apply_hunk(
193193
line_num = hunk->hunk.new_start ? hunk->hunk.new_start - 1 : 0;
194194

195195
if (!find_hunk_linenum(&line_num, image, &preimage, line_num)) {
196-
error = apply_err("Hunk at line %d did not apply",
196+
error = apply_err("hunk at line %d did not apply",
197197
hunk->hunk.new_start);
198198
goto done;
199199
}

src/attr_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int git_attr_file__new(
3030
GITERR_CHECK_ALLOC(attrs);
3131

3232
if (git_mutex_init(&attrs->lock) < 0) {
33-
giterr_set(GITERR_OS, "Failed to initialize lock");
33+
giterr_set(GITERR_OS, "failed to initialize lock");
3434
git__free(attrs);
3535
return -1;
3636
}
@@ -49,7 +49,7 @@ int git_attr_file__clear_rules(git_attr_file *file, bool need_lock)
4949
git_attr_rule *rule;
5050

5151
if (need_lock && git_mutex_lock(&file->lock) < 0) {
52-
giterr_set(GITERR_OS, "Failed to lock attribute file");
52+
giterr_set(GITERR_OS, "failed to lock attribute file");
5353
return -1;
5454
}
5555

@@ -140,7 +140,7 @@ int git_attr_file__load(
140140
break;
141141
}
142142
default:
143-
giterr_set(GITERR_INVALID, "Unknown file source %d", source);
143+
giterr_set(GITERR_INVALID, "unknown file source %d", source);
144144
return -1;
145145
}
146146

@@ -212,7 +212,7 @@ int git_attr_file__out_of_date(
212212
}
213213

214214
default:
215-
giterr_set(GITERR_INVALID, "Invalid file type %d", file->source);
215+
giterr_set(GITERR_INVALID, "invalid file type %d", file->source);
216216
return -1;
217217
}
218218
}
@@ -238,7 +238,7 @@ int git_attr_file__parse_buffer(
238238
context = attrs->entry->path;
239239

240240
if (git_mutex_lock(&attrs->lock) < 0) {
241-
giterr_set(GITERR_OS, "Failed to lock attribute file");
241+
giterr_set(GITERR_OS, "failed to lock attribute file");
242242
return -1;
243243
}
244244

src/attrcache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache)
1212
GIT_UNUSED(cache); /* avoid warning if threading is off */
1313

1414
if (git_mutex_lock(&cache->lock) < 0) {
15-
giterr_set(GITERR_OS, "Unable to get attr cache lock");
15+
giterr_set(GITERR_OS, "unable to get attr cache lock");
1616
return -1;
1717
}
1818
return 0;
@@ -365,7 +365,7 @@ int git_attr_cache__do_init(git_repository *repo)
365365

366366
/* set up lock */
367367
if (git_mutex_init(&cache->lock) < 0) {
368-
giterr_set(GITERR_OS, "Unable to initialize lock for attr cache");
368+
giterr_set(GITERR_OS, "unable to initialize lock for attr cache");
369369
git__free(cache);
370370
return -1;
371371
}
@@ -430,7 +430,7 @@ int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro)
430430
return 0;
431431

432432
if (git_mutex_lock(&cache->lock) < 0) {
433-
giterr_set(GITERR_OS, "Unable to get attr cache lock");
433+
giterr_set(GITERR_OS, "unable to get attr cache lock");
434434
error = -1;
435435
} else {
436436
git_strmap_insert(macros, macro->match.pattern, macro, error);

src/blob.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int write_file_stream(
9696
p_close(fd);
9797

9898
if (written != file_size || read_len < 0) {
99-
giterr_set(GITERR_OS, "Failed to read file into stream");
99+
giterr_set(GITERR_OS, "failed to read file into stream");
100100
error = -1;
101101
}
102102

@@ -142,7 +142,7 @@ static int write_symlink(
142142

143143
read_len = p_readlink(path, link_data, link_size);
144144
if (read_len != (ssize_t)link_size) {
145-
giterr_set(GITERR_OS, "Failed to create blob. Can't read symlink '%s'", path);
145+
giterr_set(GITERR_OS, "failed to create blob: cannot read symlink '%s'", path);
146146
git__free(link_data);
147147
return -1;
148148
}
@@ -186,7 +186,7 @@ int git_blob__create_from_paths(
186186
goto done;
187187

188188
if (S_ISDIR(st.st_mode)) {
189-
giterr_set(GITERR_ODB, "cannot create blob from '%s'; it is a directory", content_path);
189+
giterr_set(GITERR_ODB, "cannot create blob from '%s': it is a directory", content_path);
190190
error = GIT_EDIRECTORY;
191191
goto done;
192192
}

src/branch.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int retrieve_branch_reference(
3333
/* OOM */;
3434
else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0)
3535
giterr_set(
36-
GITERR_REFERENCE, "Cannot locate %s branch '%s'",
36+
GITERR_REFERENCE, "cannot locate %s branch '%s'",
3737
is_remote ? "remote-tracking" : "local", branch_name);
3838

3939
*branch_reference_out = branch; /* will be NULL on error */
@@ -46,7 +46,7 @@ static int not_a_local_branch(const char *reference_name)
4646
{
4747
giterr_set(
4848
GITERR_INVALID,
49-
"Reference '%s' is not a local branch.", reference_name);
49+
"reference '%s' is not a local branch.", reference_name);
5050
return -1;
5151
}
5252

@@ -80,7 +80,7 @@ static int create_branch(
8080
}
8181

8282
if (is_unmovable_head && force) {
83-
giterr_set(GITERR_REFERENCE, "Cannot force update branch '%s' as it is "
83+
giterr_set(GITERR_REFERENCE, "cannot force update branch '%s' as it is "
8484
"the current HEAD of the repository.", branch_name);
8585
error = -1;
8686
goto cleanup;
@@ -135,7 +135,7 @@ int git_branch_delete(git_reference *branch)
135135
assert(branch);
136136

137137
if (!git_reference_is_branch(branch) && !git_reference_is_remote(branch)) {
138-
giterr_set(GITERR_INVALID, "Reference '%s' is not a valid branch.",
138+
giterr_set(GITERR_INVALID, "reference '%s' is not a valid branch.",
139139
git_reference_name(branch));
140140
return GIT_ENOTFOUND;
141141
}
@@ -144,7 +144,7 @@ int git_branch_delete(git_reference *branch)
144144
return is_head;
145145

146146
if (is_head) {
147-
giterr_set(GITERR_REFERENCE, "Cannot delete branch '%s' as it is "
147+
giterr_set(GITERR_REFERENCE, "cannot delete branch '%s' as it is "
148148
"the current HEAD of the repository.", git_reference_name(branch));
149149
return -1;
150150
}
@@ -306,7 +306,7 @@ int git_branch_name(
306306
branch_name += strlen(GIT_REFS_REMOTES_DIR);
307307
} else {
308308
giterr_set(GITERR_INVALID,
309-
"Reference '%s' is neither a local nor a remote branch.", ref->name);
309+
"reference '%s' is neither a local nor a remote branch.", ref->name);
310310
return -1;
311311
}
312312
*out = branch_name;
@@ -436,7 +436,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
436436

437437
/* Verify that this is a remote branch */
438438
if (!git_reference__is_remote(refname)) {
439-
giterr_set(GITERR_INVALID, "Reference '%s' is not a remote branch.",
439+
giterr_set(GITERR_INVALID, "reference '%s' is not a remote branch.",
440440
refname);
441441
error = GIT_ERROR;
442442
goto cleanup;
@@ -463,7 +463,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
463463
git_remote_free(remote);
464464

465465
giterr_set(GITERR_REFERENCE,
466-
"Reference '%s' is ambiguous", refname);
466+
"reference '%s' is ambiguous", refname);
467467
error = GIT_EAMBIGUOUS;
468468
goto cleanup;
469469
}
@@ -477,7 +477,7 @@ int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refna
477477
error = git_buf_puts(buf, remote_name);
478478
} else {
479479
giterr_set(GITERR_REFERENCE,
480-
"Could not determine remote for '%s'", refname);
480+
"could not determine remote for '%s'", refname);
481481
error = GIT_ENOTFOUND;
482482
}
483483

@@ -566,7 +566,7 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
566566
local = 0;
567567
else {
568568
giterr_set(GITERR_REFERENCE,
569-
"Cannot set upstream for branch '%s'", shortname);
569+
"cannot set upstream for branch '%s'", shortname);
570570
return GIT_ENOTFOUND;
571571
}
572572

src/buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -962,14 +962,14 @@ int git_buf_unquote(git_buf *buf)
962962
case '0': case '1': case '2': case '3':
963963
if (j == buf->size-3) {
964964
giterr_set(GITERR_INVALID,
965-
"Truncated quoted character \\%c", ch);
965+
"truncated quoted character \\%c", ch);
966966
return -1;
967967
}
968968

969969
if (buf->ptr[j+1] < '0' || buf->ptr[j+1] > '7' ||
970970
buf->ptr[j+2] < '0' || buf->ptr[j+2] > '7') {
971971
giterr_set(GITERR_INVALID,
972-
"Truncated quoted character \\%c%c%c",
972+
"truncated quoted character \\%c%c%c",
973973
buf->ptr[j], buf->ptr[j+1], buf->ptr[j+2]);
974974
return -1;
975975
}
@@ -981,7 +981,7 @@ int git_buf_unquote(git_buf *buf)
981981
break;
982982

983983
default:
984-
giterr_set(GITERR_INVALID, "Invalid quoted character \\%c", ch);
984+
giterr_set(GITERR_INVALID, "invalid quoted character \\%c", ch);
985985
return -1;
986986
}
987987
}
@@ -995,6 +995,6 @@ int git_buf_unquote(git_buf *buf)
995995
return 0;
996996

997997
invalid:
998-
giterr_set(GITERR_INVALID, "Invalid quoted line");
998+
giterr_set(GITERR_INVALID, "invalid quoted line");
999999
return -1;
10001000
}

src/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int git_cache_init(git_cache *cache)
7070
cache->map = git_oidmap_alloc();
7171
GITERR_CHECK_ALLOC(cache->map);
7272
if (git_rwlock_init(&cache->lock)) {
73-
giterr_set(GITERR_OS, "Failed to initialize cache rwlock");
73+
giterr_set(GITERR_OS, "failed to initialize cache rwlock");
7474
return -1;
7575
}
7676
return 0;

0 commit comments

Comments
 (0)