Skip to content

Commit d196b1f

Browse files
mjggitster
authored andcommitted
do not discard const: the ugly truth
ISOC23 reveals that we mutate argv strings in place. Confess to this with explicit casts. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7cf0b2b commit d196b1f

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

builtin/rev-parse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int show_file(const char *arg, int output_prefix)
265265
return 0;
266266
}
267267

268-
static int try_difference(const char *arg)
268+
static int try_difference(char *arg)
269269
{
270270
char *dotdot;
271271
struct object_id start_oid;
@@ -325,7 +325,7 @@ static int try_difference(const char *arg)
325325
return 0;
326326
}
327327

328-
static int try_parent_shorthands(const char *arg)
328+
static int try_parent_shorthands(char *arg)
329329
{
330330
char *dotdot;
331331
struct object_id oid;
@@ -1145,9 +1145,9 @@ int cmd_rev_parse(int argc,
11451145
}
11461146

11471147
/* Not a flag argument */
1148-
if (try_difference(arg))
1148+
if (try_difference((char *) arg))
11491149
continue;
1150-
if (try_parent_shorthands(arg))
1150+
if (try_parent_shorthands((char *) arg))
11511151
continue;
11521152
name = arg;
11531153
type = NORMAL;

revision.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ static int handle_dotdot(const char *arg,
21322132
int cant_be_filename)
21332133
{
21342134
struct object_context a_oc = {0}, b_oc = {0};
2135-
char *dotdot = strstr(arg, "..");
2135+
char *dotdot = (char *) strstr(arg, "..");
21362136
int ret;
21372137

21382138
if (!dotdot)
@@ -2176,7 +2176,7 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
21762176
goto out;
21772177
}
21782178

2179-
mark = strstr(arg, "^@");
2179+
mark = (char *) strstr(arg, "^@");
21802180
if (mark && !mark[2]) {
21812181
*mark = 0;
21822182
if (add_parents_only(revs, arg, flags, 0)) {
@@ -2185,13 +2185,13 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
21852185
}
21862186
*mark = '^';
21872187
}
2188-
mark = strstr(arg, "^!");
2188+
mark = (char *) strstr(arg, "^!");
21892189
if (mark && !mark[2]) {
21902190
*mark = 0;
21912191
if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM), 0))
21922192
*mark = '^';
21932193
}
2194-
mark = strstr(arg, "^-");
2194+
mark = (char *) strstr(arg, "^-");
21952195
if (mark) {
21962196
int exclude_parent = 1;
21972197

0 commit comments

Comments
 (0)