1

I have a similar problem as the one in this question, but with a fundamental difference:

We got the code from a client, for evaluation and start working before signing contracts. They gave us pure code, no git repo. We created a git repo from it and used it for some time.

As the project got the go-ahead, we got access to their git repo for that project. That code has evolved as well. I am supposed to create a new branch on their repo and rebase our work into that new branch.

Reading the aforementioned question, I learned about graft, where a repo B can have a parent repo A by using graft to tell that the base of B is some commit of A. But in my case, I don't know which commit of A (their repo) is the base of B (my repo).

It's a very odd situation, where two repos can be considered different - since I don't know the commit that could be the parent of the second, but the changes in the second should be rebased to the files in the first.

Community
  • 1
  • 1
Roberto
  • 11,557
  • 16
  • 54
  • 68

2 Answers2

2

Interpreting your question as "find the revision(s) in their repository with the tree for the source they sent you",

ours=$( git rev-parse our_commit_of_their_source^{tree} )
git rev-list --pretty=format:'%h %T %s' | grep $ours

If there aren't any identical trees, you can at least efficiently list the files with differences with git diff-tree --name-status $ours $theirs to see how many files in a commit are different than yours, it's one way to do what Robin suggested. Maybe do the diff-trees with '-b` to ignore whitespace-only changes.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • What if we have a slightly different set o files when we started our repo? Someone may changed .gitignore or added a few files. Unfortunately I'm using Windows and MINGW32 crashes when I run the first command, I think the output is just too big set to `ours`. – Roberto Dec 22 '13 at 20:50
  • my apologies, `show` should have been a simple `rev-parse`. Fixed that. – jthill Dec 22 '13 at 23:19
  • @Roberto for the we-changed-something-first scenario, best I can do is some ideas for how to help with the judicious selection of what to manually compare in Robin's answer – jthill Dec 22 '13 at 23:41
1

You can maybe do a search over all the revisions in some reasonable date range, to find the matching revision in their repo. Of course you will have to ignore files in .gitignore.

But a reasonable first guess is that the revision will be on the same day as the day they sent you the code... so you should only have to check a few revisions.

You can use git diff HEAD to check for differences.

Robin Green
  • 32,079
  • 16
  • 104
  • 187