From: Prarit Bhargava prarit@redhat.com
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=d3590ebf6f91350192737dd1d1b219c05277f067 TAG=v5.8-rc7-39-gd3590ebf6f91 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 --- redhat/Makefile.common | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 6d048415ba6d..e67f2c9dec50 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -41,8 +41,7 @@ else VERSION_ON_UPSTREAM:=0 endif ifeq ($(VERSION_ON_UPSTREAM),1) - # master is expected to track mainline. - MERGE_BASE:=$(shell git merge-base HEAD master) + MERGE_BASE:=$(shell git merge-base HEAD master >& /dev/null && git merge-base HEAD master || git merge-base HEAD upstream/master) TAG:=$(shell git describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(TAG) | grep -c '-g')
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/588#note_53515640...
@prarit - still need this? I think I would prefer you check for 'master' and generate a graceful exit message then to try and cycle through various possible tree names like 'upstream'. ARK always has a master branch, hence why we use it. Though I would like to get rid of the is command all together, it is difficult.
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/588#note_54403122...
@prarit Does this work better?
``` diff --git a/redhat/Makefile.common b/redhat/Makefile.common index 64aaa40e5adaf..2fa7a5c8e13f8 100644 --- a/redhat/Makefile.common +++ b/redhat/Makefile.common @@ -48,7 +48,12 @@ else endif ifeq ($(VERSION_ON_UPSTREAM),1) # master is expected to track mainline. - MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master) + MASTER:=$(shell $(GIT) rev-parse -q --verify master || \ + $(GIT) rev-parse -q --verify upstream/master) + ifeq ($(MASTER),) + $(error "Missing 'master' or 'upstream/master' branch") + endif + MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) $(MASTER)) _TAG:=$(shell $(GIT) describe $(MERGE_BASE)) # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash] SNAPSHOT:=$(shell echo $(_TAG) | grep -c '-g') ```
From: Don Zickus on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/588#note_54403723...
@prarit Can we close this in favor of https://gitlab.com/cki- project/kernel-ark/-/merge_requests/995? This helps address an issue in the documentation !772 where there is ambiguity between master and upstream/master.
From: Prarit Bhargava on gitlab.com https://gitlab.com/cki-project/kernel-ark/-/merge_requests/588#note_54595541...
Yup, sounds good to me.
kernel@lists.fedoraproject.org