Skip to content

Commit 4216329

Browse files
committed
Merge branch 'ps/no-writable-strings'
Building with "-Werror -Wwrite-strings" is now supported. * ps/no-writable-strings: (27 commits) config.mak.dev: enable `-Wwrite-strings` warning builtin/merge: always store allocated strings in `pull_twohead` builtin/rebase: always store allocated string in `options.strategy` builtin/rebase: do not assign default backend to non-constant field imap-send: fix leaking memory in `imap_server_conf` imap-send: drop global `imap_server_conf` variable mailmap: always store allocated strings in mailmap blob revision: always store allocated strings in output encoding remote-curl: avoid assigning string constant to non-const variable send-pack: always allocate receive status parse-options: cast long name for OPTION_ALIAS http: do not assign string constant to non-const field compat/win32: fix const-correctness with string constants pretty: add casts for decoration option pointers object-file: make `buf` parameter of `index_mem()` a constant object-file: mark cached object buffers as const ident: add casts for fallback name and GECOS entry: refactor how we remove items for delayed checkouts line-log: always allocate the output prefix line-log: stop assigning string constant to file parent buffer ...
2 parents 42b8b5b + d66fe07 commit 4216329

Some content is hidden

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

68 files changed

+443
-366
lines changed

builtin/bisect.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ static int bisect_reset(const char *commit)
262262
return bisect_clean_state();
263263
}
264264

265-
static void log_commit(FILE *fp, char *fmt, const char *state,
265+
static void log_commit(FILE *fp,
266+
const char *fmt, const char *state,
266267
struct commit *commit)
267268
{
268269
struct pretty_print_context pp = {0};

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void get_ac_line(const char *inbuf, const char *what,
134134
{
135135
struct ident_split ident;
136136
size_t len, maillen, namelen;
137-
char *tmp, *endp;
137+
const char *tmp, *endp;
138138
const char *namebuf, *mailbuf;
139139

140140
tmp = strstr(inbuf, what);

builtin/bugreport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
107107
struct tm tm;
108108
enum diagnose_mode diagnose = DIAGNOSE_NONE;
109109
char *option_output = NULL;
110-
char *option_suffix = "%Y-%m-%d-%H%M";
110+
const char *option_suffix = "%Y-%m-%d-%H%M";
111111
const char *user_relative_path = NULL;
112112
char *prefixed_filename;
113113
size_t output_path_len;

builtin/check-ignore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ static const struct option check_ignore_options[] = {
3535

3636
static void output_pattern(const char *path, struct path_pattern *pattern)
3737
{
38-
char *bang = (pattern && pattern->flags & PATTERN_FLAG_NEGATIVE) ? "!" : "";
39-
char *slash = (pattern && pattern->flags & PATTERN_FLAG_MUSTBEDIR) ? "/" : "";
38+
const char *bang = (pattern && pattern->flags & PATTERN_FLAG_NEGATIVE) ? "!" : "";
39+
const char *slash = (pattern && pattern->flags & PATTERN_FLAG_MUSTBEDIR) ? "/" : "";
4040
if (!nul_term_line) {
4141
if (!verbose) {
4242
write_name_quoted(path, stdout, '\n');

builtin/clone.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static char *option_branch = NULL;
7171
static struct string_list option_not = STRING_LIST_INIT_NODUP;
7272
static const char *real_git_dir;
7373
static const char *ref_format;
74-
static char *option_upload_pack = "git-upload-pack";
74+
static const char *option_upload_pack = "git-upload-pack";
7575
static int option_verbosity;
7676
static int option_progress = -1;
7777
static int option_sparse_checkout;
@@ -177,8 +177,8 @@ static struct option builtin_clone_options[] = {
177177

178178
static const char *get_repo_path_1(struct strbuf *path, int *is_bundle)
179179
{
180-
static char *suffix[] = { "/.git", "", ".git/.git", ".git" };
181-
static char *bundle_suffix[] = { ".bundle", "" };
180+
static const char *suffix[] = { "/.git", "", ".git/.git", ".git" };
181+
static const char *bundle_suffix[] = { ".bundle", "" };
182182
size_t baselen = path->len;
183183
struct stat st;
184184
int i;
@@ -523,6 +523,9 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
523523
struct ref *head = copy_ref(find_ref_by_name(refs, "HEAD"));
524524
struct ref *local_refs = head;
525525
struct ref **tail = head ? &head->next : &local_refs;
526+
struct refspec_item tag_refspec;
527+
528+
refspec_item_init(&tag_refspec, TAG_REFSPEC, 0);
526529

527530
if (option_single_branch) {
528531
struct ref *remote_head = NULL;
@@ -545,7 +548,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
545548
&tail, 0);
546549

547550
/* if --branch=tag, pull the requested tag explicitly */
548-
get_fetch_map(remote_head, tag_refspec, &tail, 0);
551+
get_fetch_map(remote_head, &tag_refspec, &tail, 0);
549552
}
550553
free_refs(remote_head);
551554
} else {
@@ -555,8 +558,9 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
555558
}
556559

557560
if (!option_mirror && !option_single_branch && !option_no_tags)
558-
get_fetch_map(refs, tag_refspec, &tail, 0);
561+
get_fetch_map(refs, &tag_refspec, &tail, 0);
559562

563+
refspec_item_clear(&tag_refspec);
560564
return local_refs;
561565
}
562566

builtin/commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,16 @@ static char *template_file;
113113
* the commit message and/or authorship.
114114
*/
115115
static const char *author_message, *author_message_buffer;
116-
static char *edit_message, *use_message;
116+
static const char *edit_message, *use_message;
117117
static char *fixup_message, *fixup_commit, *squash_message;
118118
static const char *fixup_prefix;
119119
static int all, also, interactive, patch_interactive, only, amend, signoff;
120120
static int edit_flag = -1; /* unspecified */
121121
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
122122
static int config_commit_verbose = -1; /* unspecified */
123123
static int no_post_rewrite, allow_empty_message, pathspec_file_nul;
124-
static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
125-
static char *sign_commit, *pathspec_from_file;
124+
static const char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
125+
static const char *sign_commit, *pathspec_from_file;
126126
static struct strvec trailer_args = STRVEC_INIT;
127127

128128
/*

builtin/diagnose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int cmd_diagnose(int argc, const char **argv, const char *prefix)
1818
struct tm tm;
1919
enum diagnose_mode mode = DIAGNOSE_STATS;
2020
char *option_output = NULL;
21-
char *option_suffix = "%Y-%m-%d-%H%M";
21+
const char *option_suffix = "%Y-%m-%d-%H%M";
2222
char *prefixed_filename;
2323

2424
const struct option diagnose_options[] = {

builtin/fetch.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,16 @@ static struct ref *get_ref_map(struct remote *remote,
582582
}
583583
}
584584

585-
if (tags == TAGS_SET)
585+
if (tags == TAGS_SET) {
586+
struct refspec_item tag_refspec;
587+
586588
/* also fetch all tags */
587-
get_fetch_map(remote_refs, tag_refspec, &tail, 0);
588-
else if (tags == TAGS_DEFAULT && *autotags)
589+
refspec_item_init(&tag_refspec, TAG_REFSPEC, 0);
590+
get_fetch_map(remote_refs, &tag_refspec, &tail, 0);
591+
refspec_item_clear(&tag_refspec);
592+
} else if (tags == TAGS_DEFAULT && *autotags) {
589593
find_non_local_tags(remote_refs, NULL, &ref_map, &tail);
594+
}
590595

591596
/* Now append any refs to be updated opportunistically: */
592597
*tail = orefs;

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
12831283
o2->flags = flags2;
12841284
}
12851285

1286-
static void gen_message_id(struct rev_info *info, char *base)
1286+
static void gen_message_id(struct rev_info *info, const char *base)
12871287
{
12881288
struct strbuf buf = STRBUF_INIT;
12891289
strbuf_addf(&buf, "%s.%"PRItime".git.%s", base,

builtin/mailsplit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ static int populate_maildir_list(struct string_list *list, const char *path)
113113
DIR *dir;
114114
struct dirent *dent;
115115
char *name = NULL;
116-
char *subs[] = { "cur", "new", NULL };
117-
char **sub;
116+
const char *subs[] = { "cur", "new", NULL };
117+
const char **sub;
118118
int ret = -1;
119119

120120
for (sub = subs; *sub; ++sub) {

0 commit comments

Comments
 (0)