emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
@ 2023-01-15 20:01 No Wayman
  2023-01-15 20:55 ` No Wayman
  2023-01-16 13:38 ` Ihor Radchenko
  0 siblings, 2 replies; 14+ messages in thread
From: No Wayman @ 2023-01-15 20:01 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]


In order to properly generate org-version.el, the current build in 
mk/targets.mk requires a query of the repo's tags. Shallow clones 
do not have tags and so org-version will be generated as "N/A". In 
the attached patch, support for generating org-version.el from 
shallow clones is added. It is done by querying the upstream 
remote via git ls-remote and parsing the output. In this case, a 
more well formed org-version string will be generated. However, it 
will be missing the "commits since last tag" information. e.g.

"release_9.6.1-n/a-gabc123"


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mk-targets.mk-GITVERSION-support-shallow-repo-clones.patch --]
[-- Type: text/x-patch, Size: 1544 bytes --]

From 28c596320f48e4606f8eaf69fdc1c83fb084749e Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Sun, 15 Jan 2023 14:55:11 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa91..300fc8e0b 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,14 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+    REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+    COMMIT     := $(shell echo $(firstword $(REMOTETAGS)) | cut -c 1-6)
+    TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+    GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0


[-- Attachment #3: Type: text/plain, Size: 218 bytes --]


Emacs  : GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.36, cairo version 1.17.6)
 of 2023-01-08
Package: Org mode version 9.6.1 (release_9.6.1-137-gecb62e @ 
/home/n/.emacs.d/elpaca/builds/org/)

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-15 20:01 [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)] No Wayman
@ 2023-01-15 20:55 ` No Wayman
  2023-01-16 13:38 ` Ihor Radchenko
  1 sibling, 0 replies; 14+ messages in thread
From: No Wayman @ 2023-01-15 20:55 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 134 bytes --]


No Wayman <iarchivedmywholelife@gmail.com> writes:

Sorry, wrong commit value in the previous patch.
Fixed the patch attached here.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: revised patch --]
[-- Type: text/x-patch, Size: 1526 bytes --]

From a4cd70e17455894aec5d15d97eb41b56769e5cde Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Sun, 15 Jan 2023 15:44:45 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..20d375aa 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,14 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+    REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+    COMMIT     := $(shell git rev-parse --short=6 HEAD)
+    TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+    GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-15 20:01 [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)] No Wayman
  2023-01-15 20:55 ` No Wayman
@ 2023-01-16 13:38 ` Ihor Radchenko
  2023-01-16 19:11   ` No Wayman
  1 sibling, 1 reply; 14+ messages in thread
From: Ihor Radchenko @ 2023-01-16 13:38 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman <iarchivedmywholelife@gmail.com> writes:

> In order to properly generate org-version.el, the current build in 
> mk/targets.mk requires a query of the repo's tags. Shallow clones 
> do not have tags and so org-version will be generated as "N/A". In 
> the attached patch, support for generating org-version.el from 
> shallow clones is added. It is done by querying the upstream 
> remote via git ls-remote and parsing the output. In this case, a 
> more well formed org-version string will be generated. However, it 
> will be missing the "commits since last tag" information. e.g.
>
> "release_9.6.1-n/a-gabc123"

As discussed, this is a reasonable addition.

However, I am concerned about the following scenario:
1. Shallow clone is created
2. make autoloads is issues when system is disconnected from internet

May it be properly handled? We can put N/A at the version tag as well in
such case.

What we should not have is "make autoloads" failing without internet.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-16 13:38 ` Ihor Radchenko
@ 2023-01-16 19:11   ` No Wayman
  2023-01-17 10:38     ` Ihor Radchenko
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2023-01-16 19:11 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]


Ihor Radchenko <yantar92@posteo.net> writes:

> What we should not have is "make autoloads" failing without 
> internet.

The attached patch should take care of that.
If the ls-remote errors, GITVERSION will be set to N/A as when it 
is generally unavailable. 


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: revised-to-handle-upstream-unavailable --]
[-- Type: text/x-patch, Size: 1549 bytes --]

From 4ce8b2dfc2cf2ca1507aa14be15f5212eb1de229 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..9a62cbd4 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,15 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+    REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+    COMMIT     := $(shell git rev-parse --short=6 HEAD)
+    TAGPREFIX  := $(subst refs/tags/,,$(lastword $(REMOTETAGS)))
+    GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT),$(TAGPREFIX))
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-16 19:11   ` No Wayman
@ 2023-01-17 10:38     ` Ihor Radchenko
  2023-01-18 23:11       ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Ihor Radchenko @ 2023-01-17 10:38 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman <iarchivedmywholelife@gmail.com> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> What we should not have is "make autoloads" failing without 
>> internet.
>
> The attached patch should take care of that.
> If the ls-remote errors, GITVERSION will be set to N/A as when it 
> is generally unavailable. 

I just tried your patch running make without internet. I got the
following Org version:

Subject: [BUG] test [9.6.1 ( @ /tmp/org-mode/lisp/)]

As you can see, the last commit number is not listed even though I can
see it via git log.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-17 10:38     ` Ihor Radchenko
@ 2023-01-18 23:11       ` No Wayman
  2023-01-18 23:12         ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2023-01-18 23:11 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 686 bytes --]


Ihor Radchenko <yantar92@posteo.net> writes:

> No Wayman <iarchivedmywholelife@gmail.com> writes:
>
>> Ihor Radchenko <yantar92@posteo.net> writes:
>>
>>> What we should not have is "make autoloads" failing without 
>>> internet.
>>
>> The attached patch should take care of that.
>> If the ls-remote errors, GITVERSION will be set to N/A as when 
>> it 
>> is generally unavailable. 
>
> I just tried your patch running make without internet. I got the
> following Org version:
>
> Subject: [BUG] test [9.6.1 ( @ /tmp/org-mode/lisp/)]
>
> As you can see, the last commit number is not listed even though 
> I can
> see it via git log.


The attached patch should take care of that.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: add commit when offline --]
[-- Type: text/x-patch, Size: 1679 bytes --]

From 872ba4bf04313692758bcb3d8622c16bbd407101 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..ca6d8c42 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,20 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+    REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+    COMMIT     := $(shell git rev-parse --short=6 HEAD)
+    TAG        := $(lastword $(REMOTETAGS))
+    ifneq ($(TAG),)
+      TAGPREFIX  := $(subst refs/tags/,,$(TAG))
+      GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT), $(TAGPREFIX)) 
+    else
+      GITVERSION ?= $(ORGVERSION)-n/a-g$(COMMIT)
+    endif
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-18 23:11       ` No Wayman
@ 2023-01-18 23:12         ` No Wayman
  2023-01-19 11:19           ` Ihor Radchenko
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2023-01-18 23:12 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]


No Wayman <iarchivedmywholelife@gmail.com> writes:

> The attached patch should take care of that.

Sorry. Had trailing whitespace in that version. 
Attached here without trailing whitespace.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: without trailing space --]
[-- Type: text/x-patch, Size: 1678 bytes --]

From 85990610ca7572f5a6ff7604d957efdf00747094 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Mon, 16 Jan 2023 14:00:41 -0500
Subject: [PATCH] * mk/targets.mk (GITVERSION): support shallow repo clones

If Org is being built from a shallow clone, tags are not locally available.
Query the upstream remote via git ls-remote and parse the output.
Note this will result in a "n/a" indicator in org-version where the
number of commits since the last tag is usually present.
e.g. "release_9.6.1-n/a-gabc123"
---
 mk/targets.mk | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa9..be79a127 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,20 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  ifneq ($(wildcard .git/shallow),)
+    REMOTETAGS := $(strip $(shell git ls-remote --tags 2>/dev/null | tail -n 1))
+    COMMIT     := $(shell git rev-parse --short=6 HEAD)
+    TAG        := $(lastword $(REMOTETAGS))
+    ifneq ($(TAG),)
+      TAGPREFIX  := $(subst refs/tags/,,$(TAG))
+      GITVERSION ?= $(subst ^{},-n/a-g$(COMMIT), $(TAGPREFIX))
+    else
+      GITVERSION ?= $(ORGVERSION)-n/a-g$(COMMIT)
+    endif
+  else
+    GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  endif
+  GITVERSION ?= N/A
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-18 23:12         ` No Wayman
@ 2023-01-19 11:19           ` Ihor Radchenko
  2023-01-20  1:38             ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Ihor Radchenko @ 2023-01-19 11:19 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman <iarchivedmywholelife@gmail.com> writes:

> No Wayman <iarchivedmywholelife@gmail.com> writes:
>
>> The attached patch should take care of that.

Thanks!

I played a bit more with the patch and noticed that remote tag lookup is
not performed prior to _any_ make command.
For example, there is a noticeable delay on my network when running
something as simple as make clean.

Maybe it would be better to download the tags instead of running
ls-remote every time? I also imagine that ls-remote might pull newer
tags compared to the actual clone.

An alternative could be postponing git ls-remote call to when the actual
targets using GITVERSION are being called.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-19 11:19           ` Ihor Radchenko
@ 2023-01-20  1:38             ` No Wayman
  2023-01-20 12:44               ` Ihor Radchenko
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2023-01-20  1:38 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


Ihor Radchenko <yantar92@posteo.net> writes:

> No Wayman <iarchivedmywholelife@gmail.com> writes:
>
>> No Wayman <iarchivedmywholelife@gmail.com> writes:
>>
>>> The attached patch should take care of that.
>
> Thanks!
>
> I played a bit more with the patch and noticed that remote tag 
> lookup is
> not performed prior to _any_ make command.
> For example, there is a noticeable delay on my network when 
> running
> something as simple as make clean.
>
> Maybe it would be better to download the tags instead of running
> ls-remote every time? I also imagine that ls-remote might pull 
> newer
> tags compared to the actual clone.
>
> An alternative could be postponing git ls-remote call to when 
> the actual
> targets using GITVERSION are being called.

Feel free to take this the patch as a base to do whatever you 
please with it.
I've run out of free time to iterate on it. 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-20  1:38             ` No Wayman
@ 2023-01-20 12:44               ` Ihor Radchenko
  2023-01-20 14:50                 ` Max Nikulin
  2023-01-20 17:34                 ` No Wayman
  0 siblings, 2 replies; 14+ messages in thread
From: Ihor Radchenko @ 2023-01-20 12:44 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

No Wayman <iarchivedmywholelife@gmail.com> writes:

> Feel free to take this the patch as a base to do whatever you 
> please with it.

Then, I am thinking about a simple approach that will not involve
internet connection. See the attached.

Note that you, in fact, can fetch the latest tags from remote into
shallow clone. See
https://stackoverflow.com/questions/66349002/get-latest-tag-git-describe-tags-when-repo-is-cloned-with-depth-1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-mk-targets.mk-GITVERSION-Provide-commit-number-for-s.patch --]
[-- Type: text/x-patch, Size: 1182 bytes --]

From 93a75bcd3f8badf11c9234e5336e450d2d2baf60 Mon Sep 17 00:00:00 2001
Message-Id: <93a75bcd3f8badf11c9234e5336e450d2d2baf60.1674218582.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Fri, 20 Jan 2023 15:25:33 +0300
Subject: [PATCH] * mk/targets.mk(GITVERSION): Provide commit number for
 shallow clones

Fall back to using git log when git describe fails in Org repo.

See https://orgmode.org/list/87bkmve8qv.fsf@gmail.com
---
 mk/targets.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/targets.mk b/mk/targets.mk
index 4435daa..164b092 100644
--- a/mk/targets.mk
+++ b/mk/targets.mk
@@ -14,7 +14,7 @@ ifneq ($(wildcard .git),)
   # Use the org.el header.
   ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
     --visit lisp/org.el --eval '(princ (lm-header "version"))'))
-  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
+  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD 2>/dev/null || echo  "release_N/A-N/A-$(shell git log --format=%h HEAD^..HEAD)")
   GITSTATUS  ?= $(shell git status -uno --porcelain)
 else
  -include mk/version.mk
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-20 12:44               ` Ihor Radchenko
@ 2023-01-20 14:50                 ` Max Nikulin
  2023-02-10 13:21                   ` Ihor Radchenko
  2023-01-20 17:34                 ` No Wayman
  1 sibling, 1 reply; 14+ messages in thread
From: Max Nikulin @ 2023-01-20 14:50 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

On 20/01/2023 19:44, Ihor Radchenko wrote:
> diff --git a/mk/targets.mk b/mk/targets.mk
> index 4435daa..164b092 100644
> --- a/mk/targets.mk
> +++ b/mk/targets.mk
> @@ -14,7 +14,7 @@ ifneq ($(wildcard .git),)
>    # Use the org.el header.
>    ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
>      --visit lisp/org.el --eval '(princ (lm-header "version"))'))
> -  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
> +  GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD 2>/dev/null || echo  "release_N/A-N/A-$(shell git log --format=%h 

another option is to use --always

git describe --match release\* --abbrev=6 --always HEAD
52f29d

and some make code that prepends it with release_$(ORGVERSION)- if it 
has not release prefix.

Earlier posted patches attempts to make remote query even if history 
depth of local copy is enough to include a commit tagged as release. I 
have found some recipes how to modify "git fetch" to get enough objects 
for "git describe", but I have never used them, so unsure concerning 
their reliability. Perhaps they may be used in CI configuration, namely 
in the script preparing source directory, since fetch is not 
responsibility of make.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-20 12:44               ` Ihor Radchenko
  2023-01-20 14:50                 ` Max Nikulin
@ 2023-01-20 17:34                 ` No Wayman
  2023-01-21  9:36                   ` Ihor Radchenko
  1 sibling, 1 reply; 14+ messages in thread
From: No Wayman @ 2023-01-20 17:34 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


Ihor Radchenko <yantar92@posteo.net> writes:

> No Wayman <iarchivedmywholelife@gmail.com> writes:
>
>> Feel free to take this the patch as a base to do whatever you 
>> please with it.
>
> Then, I am thinking about a simple approach that will not 
> involve
> internet connection. See the attached.

I think that's the best solution. I landed on something similar 
for Elpaca (and will likely suggest the same for straight.el).

> Note that you, in fact, can fetch the latest tags from remote 
> into
> shallow clone. See
> https://stackoverflow.com/questions/66349002/get-latest-tag-git-describe-tags-when-repo-is-cloned-with-depth-1

Seems more complicated than it's worth at this point.
 
>    # Use the org.el header.
>    ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval 
>    "(require 'lisp-mnt)" \
>      --visit lisp/org.el --eval '(princ (lm-header 
>      "version"))'))
> -  GITVERSION ?= $(shell git describe --match release\* 
> --abbrev=6 HEAD)
> +  GITVERSION ?= $(shell git describe --match release\* 
> --abbrev=6 HEAD 2>/dev/null || echo  "release_N/A-N/A-$(shell 
> git log --format=%h HEAD^..HEAD)")

Why not use ORGVERSION here? Is the metadata in org.el's version 
header not updated when a commit is tagged as a release?



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-20 17:34                 ` No Wayman
@ 2023-01-21  9:36                   ` Ihor Radchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Ihor Radchenko @ 2023-01-21  9:36 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman <iarchivedmywholelife@gmail.com> writes:

> Why not use ORGVERSION here? Is the metadata in org.el's version 
> header not updated when a commit is tagged as a release?

ORGVERSION can be ahead of the last released version.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)]
  2023-01-20 14:50                 ` Max Nikulin
@ 2023-02-10 13:21                   ` Ihor Radchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Ihor Radchenko @ 2023-02-10 13:21 UTC (permalink / raw)
  To: Max Nikulin; +Cc: No Wayman, emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> another option is to use --always
>
> git describe --match release\* --abbrev=6 --always HEAD
> 52f29d

This is indeed more reliable.
Applied, onto main. With your version instead of git log.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=6d37d2a8e

> and some make code that prepends it with release_$(ORGVERSION)- if it 
> has not release prefix.

This is not needed. ORGVERSION as defined in Org .el files will be
available. The patch only deals the git tags, when they are missing.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-02-10 13:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-15 20:01 [PATCH] Support building Org from shallow clone [9.6.1 (release_9.6.1-137-gecb62e @ /home/n/.emacs.d/elpaca/builds/org/)] No Wayman
2023-01-15 20:55 ` No Wayman
2023-01-16 13:38 ` Ihor Radchenko
2023-01-16 19:11   ` No Wayman
2023-01-17 10:38     ` Ihor Radchenko
2023-01-18 23:11       ` No Wayman
2023-01-18 23:12         ` No Wayman
2023-01-19 11:19           ` Ihor Radchenko
2023-01-20  1:38             ` No Wayman
2023-01-20 12:44               ` Ihor Radchenko
2023-01-20 14:50                 ` Max Nikulin
2023-02-10 13:21                   ` Ihor Radchenko
2023-01-20 17:34                 ` No Wayman
2023-01-21  9:36                   ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).