git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Rice, James M CIV NSWCDD, K73" <james.rice2@navy.mil>
Cc: git@vger.kernel.org
Subject: Re: Tracking changes in git with a change number....
Date: Tue, 12 Jul 2011 01:50:08 -0400	[thread overview]
Message-ID: <20110712055008.GC11644@sigill.intra.peff.net> (raw)
In-Reply-To: <C785F567A08DDE449FD4590C91E6AD13CB34BE@naeamillez01v.nadsusea.nads.navy.mil>

On Mon, Jul 11, 2011 at 01:29:52PM -0400, Rice, James M CIV NSWCDD, K73 wrote:

> Restating the problem.  I wish for our developers to be able to
> reference multiple commits with one number, and then find those
> commits via that number.  And I don't mind scripting to accomplish
> this.  I know, that CR # can be put in the commit message, then I can
> grep and parse the log, that is the hard way.

There are two ways to approach this: tell the CM tool about some git
commits, or tell some git commits about the CR number.

For telling the CM tool about git commits, refer to them by their sha1
commit ids.  If the commits are sequential, you can refer to the
sequence by its endpoints. And then if you want to know which files were
touched, you can just diff the endpoints, like:

  $ git diff-tree --name-only $start $end

It's not a number, exactly, but it is a fixed size (two 40-byte commit
ids). Would that work in your CM tool?

If the commits aren't sequential, you can do something similar, but you
have a variable-length list of commit ids, and you get the set of
changed files like:

  $ for i in $commits; do
      git diff-tree --name-only $i |
      tail -n +2
    done | sort -u

If you want to do the reverse and tell git about CR numbers, then I
don't think you have much option besides putting them in the commit
message. Which means you'll need to grep to get them out. You can do
something like:

  $ git log --grep='CR#' --pretty=format: --name-only

-Peff

  parent reply	other threads:[~2011-07-12  5:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 17:29 Tracking changes in git with a change number Rice, James M CIV NSWCDD, K73
2011-07-12  5:37 ` Damien Wyart
2011-07-12  5:50 ` Jeff King [this message]
2011-07-12 12:54   ` Stephen Bash
2011-07-12 21:28     ` Rice, James M CIV NSWCDD, K73

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110712055008.GC11644@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=james.rice2@navy.mil \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.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).