bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* git-version-gen: add support for empty release commits
@ 2019-05-10 22:31 Bruno Haible
  2019-05-10 23:13 ` Paul Eggert
  2019-05-11  8:55 ` Dmitry V. Levin
  0 siblings, 2 replies; 4+ messages in thread
From: Bruno Haible @ 2019-05-10 22:31 UTC (permalink / raw)
  To: bug-gnulib

Hi,

I'm using git-version-gen in GNU gettext. For the 0.20 release, I
created an empty commit, like this:

    CURRENT_VERSION=0.20
    git commit --allow-empty -m "Release $CURRENT_VERSION"
    git tag v$CURRENT_VERSION

Now, git-version-gen ignores this release commit:

$ git describe --abbrev=4 --match="v*" HEAD
v0.19.8.1-519-g62b2a

$ git describe --abbrev=4 --match="v*" --debug HEAD
searching to describe HEAD
finished search at c737bf843616ca984c9416048a2da845e9ad3f50
 annotated        519 v0.19.8.1
traversed 520 commits
v0.19.8.1-519-g62b2a

The fix is to add a --tags option to the 'git describe' command:

$ git describe --abbrev=4 --tags --match="v*" HEAD
v0.20-4-g62b2a

$ git describe --abbrev=4 --tags --match="v*" --debug HEAD
searching to describe HEAD
finished search at c737bf843616ca984c9416048a2da845e9ad3f50
 lightweight        4 v0.20
 annotated        519 v0.19.8.1
traversed 520 commits
v0.20-4-g62b2a

Therefore here's the proposed fix:


2019-05-10  Bruno Haible  <bruno@clisp.org>

	git-version-gen: Add support for empty release commits.
	* build-aux/git-version-gen: Invoke 'git describe' with option --tags.

diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 45b5656..5e0e0dd 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -156,8 +156,8 @@ then
 # directory, and "git describe" output looks sensible, use that to
 # derive a version string.
 elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
-    && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \
-          || git describe --abbrev=4 HEAD 2>/dev/null` \
+    && v=`git describe --abbrev=4 --tags --match="$prefix*" HEAD 2>/dev/null \
+          || git describe --abbrev=4 --tags HEAD 2>/dev/null` \
     && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
     && case $v in
          $prefix[0-9]*) ;;



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

* Re: git-version-gen: add support for empty release commits
  2019-05-10 22:31 git-version-gen: add support for empty release commits Bruno Haible
@ 2019-05-10 23:13 ` Paul Eggert
  2019-05-11  8:55 ` Dmitry V. Levin
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Eggert @ 2019-05-10 23:13 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

Thanks, this looks good to me.


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

* Re: git-version-gen: add support for empty release commits
  2019-05-10 22:31 git-version-gen: add support for empty release commits Bruno Haible
  2019-05-10 23:13 ` Paul Eggert
@ 2019-05-11  8:55 ` Dmitry V. Levin
  2019-05-11 11:46   ` Bruno Haible
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry V. Levin @ 2019-05-11  8:55 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

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

Hi,

On Sat, May 11, 2019 at 12:31:16AM +0200, Bruno Haible wrote:
> Hi,
> 
> I'm using git-version-gen in GNU gettext. For the 0.20 release, I
> created an empty commit, like this:
> 
>     CURRENT_VERSION=0.20
>     git commit --allow-empty -m "Release $CURRENT_VERSION"
>     git tag v$CURRENT_VERSION

This doesn't create a tag object, so ...

> Now, git-version-gen ignores this release commit:
> 
> $ git describe --abbrev=4 --match="v*" HEAD
> v0.19.8.1-519-g62b2a

... this doesn't use v0.20 which is just a reference to a commit object.

> $ git describe --abbrev=4 --match="v*" --debug HEAD
> searching to describe HEAD
> finished search at c737bf843616ca984c9416048a2da845e9ad3f50
>  annotated        519 v0.19.8.1
> traversed 520 commits
> v0.19.8.1-519-g62b2a
> 
> The fix is to add a --tags option to the 'git describe' command:
> 
> $ git describe --abbrev=4 --tags --match="v*" HEAD
> v0.20-4-g62b2a
> 
> $ git describe --abbrev=4 --tags --match="v*" --debug HEAD
> searching to describe HEAD
> finished search at c737bf843616ca984c9416048a2da845e9ad3f50
>  lightweight        4 v0.20
>  annotated        519 v0.19.8.1
> traversed 520 commits
> v0.20-4-g62b2a
> 
> Therefore here's the proposed fix:
> 
> 
> 2019-05-10  Bruno Haible  <bruno@clisp.org>
> 
> 	git-version-gen: Add support for empty release commits.
> 	* build-aux/git-version-gen: Invoke 'git describe' with option --tags.

This change has nothing to do with empty release commits.
In fact, git describe doesn't care about emptiness of commits.

This change is about using lightweight tags (which are not tag objects
but references to commit objects) in git-version-gen.


-- 
ldv

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: git-version-gen: add support for empty release commits
  2019-05-11  8:55 ` Dmitry V. Levin
@ 2019-05-11 11:46   ` Bruno Haible
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Haible @ 2019-05-11 11:46 UTC (permalink / raw)
  To: Dmitry V. Levin; +Cc: bug-gnulib

Hi Dmitry,

> In fact, git describe doesn't care about emptiness of commits.

It does care during "git rebase -i".

> This change has nothing to do with empty release commits.
> This change is about using lightweight tags (which are not tag objects
> but references to commit objects) in git-version-gen.

Ah, thanks! I didn't know about this difference. The manual page [1] explains
it:

  "Annotated tags are meant for release while lightweight tags are meant
   for private or temporary object labels. For this reason, some git commands
   for naming objects (like git describe) will ignore lightweight tags
   by default."

I've changed the my gettext tag from a lightweight tag to an annotated tag,
and "git describe" now behaves as expected.
=> No need to change the git-version-gen script.

Bruno

[1] https://git-scm.com/docs/git-tag



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

end of thread, other threads:[~2019-05-11 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 22:31 git-version-gen: add support for empty release commits Bruno Haible
2019-05-10 23:13 ` Paul Eggert
2019-05-11  8:55 ` Dmitry V. Levin
2019-05-11 11:46   ` Bruno Haible

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).