Skip to content

Commit 782a719

Browse files
peffgitster
authored andcommitted
remote: drop const return of tracking_for_push_dest()
The string returned from tracking_for_push_dest() comes from apply_refspec(), and thus is always an allocated string (or NULL). We should return a non-const pointer so that the caller knows that ownership of the string is being transferred. This goes back to the function's origin in e291c75 (remote.c: add branch_get_push, 2015-05-21). It never really mattered because our return is just forwarded through branch_get_push_1(), which returns a const string as part of an intentionally hacky memory management scheme (see that commit for details). As the first step of untangling that hackery, let's drop the extra const from this helper function (and from the variables that store its result). There should be no functional change (yet). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9500b21 commit 782a719

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

remote.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,9 +1876,9 @@ const char *branch_get_upstream(struct branch *branch, struct strbuf *err)
18761876
return branch->merge[0]->dst;
18771877
}
18781878

1879-
static const char *tracking_for_push_dest(struct remote *remote,
1880-
const char *refname,
1881-
struct strbuf *err)
1879+
static char *tracking_for_push_dest(struct remote *remote,
1880+
const char *refname,
1881+
struct strbuf *err)
18821882
{
18831883
char *ret;
18841884

@@ -1906,7 +1906,7 @@ static const char *branch_get_push_1(struct repository *repo,
19061906

19071907
if (remote->push.nr) {
19081908
char *dst;
1909-
const char *ret;
1909+
char *ret;
19101910

19111911
dst = apply_refspecs(&remote->push, branch->refname);
19121912
if (!dst)
@@ -1936,7 +1936,8 @@ static const char *branch_get_push_1(struct repository *repo,
19361936
case PUSH_DEFAULT_UNSPECIFIED:
19371937
case PUSH_DEFAULT_SIMPLE:
19381938
{
1939-
const char *up, *cur;
1939+
const char *up;
1940+
char *cur;
19401941

19411942
up = branch_get_upstream(branch, err);
19421943
if (!up)

0 commit comments

Comments
 (0)