git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Unknown software revision
@ 2011-02-10 22:33 Jason Brooks
  2011-02-10 23:22 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Brooks @ 2011-02-10 22:33 UTC (permalink / raw)
  To: git

Hello,

I am not sure what I am asking, so I thought I would start here.  If I
knew the name of this operation, I would look for it.  :)

I have also posted to the git-users google group, but signs there tell  
me this is the better place.

I have a software deployment that was copied out of a git repository
but without the .git directories.  Thus, I have no idea what revision
this deployment is, so I don't know how to upgrade from git.  Is there a
method, or script out there that can help me?

The trouble is, I should have made a branch or tag when I deployed it  
to at
least freeze that version.  At the very least so I can rebase and re-
deploy it again.  (I could be wrong about this last statement: I am  
definitely new to git)

I appreciate any assistance you all can give me...

--jason

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

* Re: Unknown software revision
  2011-02-10 22:33 Unknown software revision Jason Brooks
@ 2011-02-10 23:22 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2011-02-10 23:22 UTC (permalink / raw)
  To: Jason Brooks; +Cc: git

On Thu, Feb 10, 2011 at 02:33:47PM -0800, Jason Brooks wrote:

> I have a software deployment that was copied out of a git repository
> but without the .git directories.  Thus, I have no idea what revision
> this deployment is, so I don't know how to upgrade from git.  Is there a
> method, or script out there that can help me?

Does your set of files match what was in the git tree _exactly_? Or
might there be minor changes, new files, etc?

If it should match exactly, you can figure out what tree git would have
made out of this content:

  git init
  git add .
  git commit -m foo
  tree=`git rev-parse HEAD^{tree}`

And now you can search in the actual git repository for that tree:

  $ git log --pretty=raw -z | perl -0lne 'print $_, "\n" if /^tree '$tree'$/m'

But obviously that is all based on the hashes of the content, so if even
a single byte is missing, added, or different in your deployed copy, you
won't find a match.

In that case, your best bet is probably to script a bunch of diffs and
see which commit ends up closest. I would do something like:

  1. From the deployed version, prepare your best guess about what the
     git directory would have looked like. Put it in a directory
     "deployed".

  2. Now make a git commit from the deployed state:

       cd deployed
       git init
       git add .
       git commit -m 'deployed version'

  3. In the original git repo, fetch the deployed version in so you
     can diff against it.

       cd /path/to/real/git/repo
       git fetch /path/to/deployed master:deployed

  4. Now you can try diffing "deployed" against every commit in the real
     repo and see what comes closest. Here I'll just count up changed
     lines to assign a score to each commit and show the one with the
     fewest changes:

       git rev-list HEAD | while read commit; do
         git diff-tree --numstat $commit deployed |
         perl -ane '$total += $F[0] + $F[1];
                    END { print $total }'
         echo " $commit"
       done | sort -n

The top of the resulting list is the closest commit. Check it out with
"git show" to see if it makes sense.

Hope that helps.

-Peff

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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-10 22:33 Unknown software revision Jason Brooks
2011-02-10 23:22 ` Jeff King

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 NNTP newsgroup(s).