Skip to content

redhat/Makefile.common: Fix 'fatal: Not a valid object name master' error

Prarit Bhargava requested to merge prarit/kernel-ark:MERGE_BASE_fix into os-build

Hey everyone,

I spent 5-10 mins looking at the 'fatal: Not a valid object name master' error this morning. It comes from the redhat/Makefile.common:45

MERGE_BASE:=$(shell git merge-base HEAD master)

There is no master branch so 'git merge-base HEAD master' returns an error with message 'fatal: Not a valid object name master'.

If I add a Makefile target to dump the MERGE_BASE, TAG, and SNAPSHOT variables I get

MERGE_BASE= TAG=v5.8-rc7-1028-g305981a20220 SNAPSHOT=1

I thought about changing the MERGE_BASE value to

MERGE_BASE:=$(shell git merge-base HEAD master >& /dev/null && git merge-base HEAD master || git merge-base HEAD upstream/master)

but that seems really clunky. Anyone have a better idea? Maybe it should only be

MERGE_BASE:$(git merge-base HEAD upstream/master) ?

In any case, after changing the MERGE_BASE line in Makefile.common, and dumping the values the 'fatal' error no longer occurs and MERGE_BASE is set correctly:

MERGE_BASE=d3590ebf TAG=v5.8-rc7-39-gd3590ebf SNAPSHOT=1

P.

---8<----

Executing some redhat/Makefile targets results in a

 'fatal: Not a valid object name master'

error. This occurs because MERGE_BASE is calculated against the master branch which may not exist.

Check to see if master branch exists and if it doesn't use upstream/master instead.

Signed-off-by: Prarit Bhargava prarit@redhat.com

Merge request reports