git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Patch (apply) vs. Pull

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 23, 2005, 22:20 UTC
Message-ID
<Pine.LNX.4.58.0506231510370.11175@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.21.0506231522080.30848-100000@iabervon.org>
On Thu, 23 Jun 2005, Daniel Barkalow wrote:
Show 10 quoted lines
>
> On Thu, 23 Jun 2005, Linus Torvalds wrote:
> > 
> > Right, that would mean that we don't control the hash generation at both 
> > points, and would make it fundamentally harder. But since the whole point 
> > is that we should be able to generate the ID _without_ it actually being 
> > stored away anywhere, this hash approach should work fine.
> 
> ("We" in this case being the developer checking whether the patch went in,
> not the maintainer)
Yes.
> We'll need to see if the performance is okay this way, both in terms of
> time spent searching for the patch you're checking on and in terms of
> recognizing the patch as being the same. No point in designing anything
> more complex until we determine if we can't just recognize it already.

Actually, this is a _very_ efficient check to do, because I'm just incredibly smart.

What you do is to download the current git tree (give it a while to mirror out, actually), and you get a magic "git-patch-id" program.

Now, the reason this is very efficient is magical. Let's say that you have my tree as branch "linus", and you have your own tree (branch "daniel"), and you want to see what commits are in both (but are not the _same_ commit - you just wonder if they have the same diff). That's a big clue that you should drop your copy, because I applied it as a diff.

What you do is simply:
	git-whatchanged -p linus..daniel | git-patch-id | sort > daniel-patch-id
	git-whatchanged -p daniel..linus | git-patch-id | sort > linus-patch-id
	join -j 1 linus-patch-id daniel-patch-id

and you're done. You've just created a list of commits that have the same patch ID (and it will list the patch ID _and_ the two commit ID's, just to be really nice about it).

It's all totally linear in number of patches involved (yeah, the "sort" is obviously reall NlogN, and technically the git-rev-list between the two trees _could_ be more than linear, but in practice they are very cheap and very close to linear anyway).

It's also obviously totally untested, but hey, I always write perfect code, so what could _possibly_ go wrong..

		Linus
Previous: Daniel BarkalowNext: Linus Torvalds
Message 21 of 33 in “Patch (apply) vs. Pull”
  1. Darrin ThompsonJun 20, 2005
  2. Junio C HamanoJun 20, 2005
  3. Darrin ThompsonJun 20, 2005
  4. Daniel BarkalowJun 21, 2005
  5. Junio C HamanoJun 22, 2005
  6. Catalin MarinasJun 22, 2005
  7. Linus TorvaldsJun 21, 2005
  8. Junio C HamanoJun 22, 2005
  9. Linus TorvaldsJun 22, 2005
  10. Daniel BarkalowJun 22, 2005
  11. Linus TorvaldsJun 22, 2005
  12. Daniel BarkalowJun 22, 2005
  13. Linus TorvaldsJun 22, 2005
  14. Daniel BarkalowJun 23, 2005
  15. Linus TorvaldsJun 23, 2005
  16. Daniel BarkalowJun 23, 2005
  17. Linus TorvaldsJun 23, 2005
  18. Daniel BarkalowJun 23, 2005
  19. Linus TorvaldsJun 23, 2005
  20. Daniel BarkalowJun 23, 2005
  21. Linus TorvaldsJun 23, 2005
  22. Linus TorvaldsJun 23, 2005
  23. Catalin MarinasJun 23, 2005
  24. Daniel BarkalowJun 23, 2005
  25. Catalin MarinasJun 24, 2005
  26. Martin LanghoffJun 23, 2005
  27. Darrin ThompsonJun 22, 2005
  28. Martin LanghoffJun 23, 2005
  29. 0/3 Rebasing for "individual developer" usageJunio C Hamano, Jun 23, 2005
  30. 1/3 git-commit-script: get commit message from an existing one.Junio C Hamano, Jun 23, 2005
  31. 2/3 git-cherry: find commits not merged upstream.Junio C Hamano, Jun 23, 2005
  32. 3/3 git-rebase-script: rebase local commits to new upstream head.Junio C Hamano, Jun 23, 2005
  33. Catalin MarinasJun 22, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.