Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:31:20+00:00 2026-06-05T17:31:20+00:00

How do I add the output of # Get tag distance $(TAGDIST) git describe

  • 0

How do I add the output of

# Get tag distance $(TAGDIST) 
git describe --tags | \
awk '{split($0,TagNameWithTagDist,"-g");
     i=split(TagNameWithTagDist[1],TagDist,"-");
     print(TagDist[i]);}'

to the output of the following?

git log --graph --format=format:'%h - %s + $TAGDIST'

I don’t see in the “Pretty Formats” section of the git-log documentation a placeholders that corresponds to this value. Placeholder %d shows the tag name on the commit where it was created only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:31:23+00:00Added an answer on June 5, 2026 at 5:31 pm

    Copy the code below as a file named git-logtagdist in some directory in your path. Note that it runs slowly because it forks a new git-describe process for each commit. You could speed it up by batching the git-describe runs.

    #! /usr/bin/env perl
    
    use strict;
    use warnings;
    
    use Git;
    
    my $repo = Git->repository;
    
    my @logcmd = (
      "log", "--color=always", "--graph",
      "--format=format:%h - %s - !!!DISTANCE!!!",
    );
    
    my($fh,$ctx) = $repo->command_output_pipe(@logcmd);
    
    if (-t STDOUT) {
      my(@pager) = $ENV{GIT_PAGER} || $ENV{PAGER} || ("less", "-R");
      open STDOUT, "|-", @pager or die "$0: open: $!";
    }
    
    while (<$fh>) {
      # e.g., 797166c - Merge branch 'maint' - !!!DISTANCE!!!
      s<([0-9a-f]{7,})\b(.+ - )!!!DISTANCE!!!> {
        my($sha1,$msg) = ($1,$2);
        my $distance;
    
        # e.g., v1.7.9.2-334-g797166c
        chomp(my $describe = $repo->command("describe", "--tags", $sha1));
        if ($describe =~ /^(.+?)-([0-9]+)-g/) {
          $distance = "$2 past $1";
        }
        else {
          $distance = "tagged: $describe";
        }
    
        $sha1 . $msg . $distance;
      }e;
    
      print;
    }
    
    close STDOUT or warn "$0: close: $!";
    

    Sample output:

    $ git logtagdist
    * 9bea2b5 - Git 1.7.11-rc3 - tagged: v1.7.11-rc3
    *   3a2c135 - Merge git://github.com/git-l10n/git-po - 17 past v1.7.11-rc2
    |\
    | *   3482b14 - Merge git://github.com/ralfth/git-po-de - 5 past v1.7.11-rc2
    | |\
    | | * d7f22ed - l10n: de.po: translate 27 new messages - 3 past v1.7.11-rc2
    | * | 6cb4571 - l10n: Update  po/vi.po to v1.7.11.rc2.2.gb694fbb - 3 past v1.7.11-rc2
    | |/
    | * b694fbb - l10n: zh_CN.po: translate 27 new messages - 2 past v1.7.11-rc2
    | * 7256fd7 - l10n: Update git.pot (27 new, 1 removed messages) - 1 past v1.7.11-rc2
    * |   73a6e3c - Merge branch 'mm/api-credentials-doc' - 11 past v1.7.11-rc2
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add an xmlns to the root element in the output of
when asp.net output a page ,I want to add some same parameters for all
Typically views appear to output anchors without 'title' attributes. How would you add 'title'
I've read several articles that tell you how to add text to the output
I have to fix all the closing tags of the <img> tag as shown
I'm trying to add tags to a Story entity. I've created my own bundle,
I need to add <b> tags around the first line of text, but not
When running Rails unit tests I get output specifying line numbers and methods when
I need to get some JSON output in a .NET 2.0 C# script. The
We add Struts errors and messages using ActionSupport.addActionError(...) and addActionMessage(...) and then output the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.