@@ -1755,7 +1755,7 @@ static int do_fetch(struct transport *transport,
commit_fetch_head(&fetch_head);
if (set_upstream) {
- struct branch *branch = branch_get("HEAD");
+ struct branch *branch = branch_get(NULL);
struct ref *rm;
struct ref *source_ref = NULL;
@@ -335,7 +335,7 @@ static const char *config_get_ff(void)
*/
static enum rebase_type config_get_rebase(int *rebase_unspecified)
{
- struct branch *curr_branch = branch_get("HEAD");
+ struct branch *curr_branch = branch_get(NULL);
const char *value;
if (curr_branch) {
@@ -440,7 +440,7 @@ static int get_only_remote(struct remote *remote, void *cb_data)
*/
static void NORETURN die_no_merge_candidates(const char *repo, const char **refspecs)
{
- struct branch *curr_branch = branch_get("HEAD");
+ struct branch *curr_branch = branch_get(NULL);
const char *remote = curr_branch ? curr_branch->remote_name : NULL;
if (*refspecs) {
@@ -713,7 +713,7 @@ static const char *get_upstream_branch(const char *remote)
if (!rm)
return NULL;
- curr_branch = branch_get("HEAD");
+ curr_branch = branch_get(NULL);
if (!curr_branch)
return NULL;
@@ -777,7 +777,7 @@ static int get_rebase_fork_point(struct object_id *fork_point, const char *repo,
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf sb = STRBUF_INIT;
- curr_branch = branch_get("HEAD");
+ curr_branch = branch_get(NULL);
if (!curr_branch)
return -1;
Our recommendation is to use branch_get(NULL) to obtain the 'struct branch*' for the currently checked out branch in the current worktree. While branch_get("HEAD") produces the same result, it does not follow the recommended usage and may cause confusion. Let's change some calls to branch_get() we currently have in our codebase that do not follow the recommendation, applying the following semantic patch: @@ @@ - branch_get("HEAD") + branch_get(NULL) Signed-off-by: Rubén Justo <rjusto@gmail.com> --- builtin/fetch.c | 2 +- builtin/pull.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)