2

I have a script that generates other scripts. I want to put some identity in the generated script so that I can find the version of the script that generated it.

I have followed the instructions on How do I enable ident string for Git repos? (which uses $Id$). Now that I have hash for the file (not the commit), how do I go find the version of the file from the repo?

Community
  • 1
  • 1
chrish
  • 2,352
  • 1
  • 17
  • 32

1 Answers1

1

Use git cat-file.

To see the type of an object, use git cat-file -t revspec, where revspec is any valid revision specifier (see gitrevisions). For instance:

$ git cat-file -t master
commit

To see the contents of an object, use git cat-file -p revspec. If the revspec identifies a "blob" (a file), this gives you the raw contents of the file. Note that no filters are applied.

(If it identifies a commit, tag, or tree, you get a printable representation of that.)

(You can only apply filters to paths, not raw object-IDs. Turning a blob ID into a set of paths that specify that blob is nontrivial, but not impossible unless the blob is unreferenced; however, there may be multiple paths referring to a single blob, a la Unix/Linux hard links.)

torek
  • 448,244
  • 59
  • 642
  • 775