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

Re: Bizarre missing changes (git bug?)

From
RZRoman Zippel <zippel@linux-m68k.org>
Date
Jul 27, 2008, 17:50 UTC
Message-ID
<Pine.LNX.4.64.0807270049290.6791@localhost.localdomain>
In-Reply-To
<alpine.LFD.1.10.0807261249430.4188@nehalem.linux-foundation.org>
Hi,
On Sat, 26 Jul 2008, Linus Torvalds wrote:
> > Is there a way to change that default?
> 
> Use an alias or something.

This doesn't help with the graphical front ends and they only use what git gives them.

Show 14 quoted lines
> To see why it's the default, do a few tests. In particular, try it with 
> gitk on the kernel. Try it on some fairly simple file that doesn't get a 
> lot of churn. Example:
> 
> 	gitk lib/vsprintf.c
> 
> vs
> 
> 	gitk --full-history lib/vsprintf.c
> 
> and if you don't _immediately_ see why --full-history isn't the default, 
> there's likely something wrong with you. One is useful. The other is not.
> 
> So we absolutely _have_ to simplify merges. There is no question about it.

Well, I don't want that much history. Let's take a different example. Look at kernel/sched_rt.c with git-log, --full-history shows an extra commit of a patch which was committed and merged twice, but there is no information how this other patch was merged. If you have giggle installed, you'll see that commit as a loose end.

(I have git version 1.5.6.2 installed in case it matters.)
Show 12 quoted lines
> That said, we currently simplify merges the simple and stupid way, and 
> I've hinted several times on this mailing list that there is a better way 
> to do it (last time it was the discussion about "filter-branch".
> 
> In fact, if you google for 
> 
> 	filter-branch full-history
> 
> you'll find some of the discussion. In order to make --full-history useful 
> as a default, we'd need to do an after-the-fact merge cleanup (ie remove 
> lines of development that are later found to really be totally 
> uninteresting), but that is *hard*.

I played a little with it in the ruby script below, which produces a complete connected graph of all content nodes and which have been merged into the head, e.g. for sched_rt.c it produces that extra commit merge. The script basically eliminates all empty merges. As input to the script I used "git log --parents --name-only --full-history kernel/sched_rt.c | grep -e ^commit -e ^kernel", which seems to produce the same amount of commits as "gitk --full-history ...".

The main function is to check, whether one parent of a commit is an ancestor of another parent, so that this path can be eliminated. I tried it with other paths and too simple implementations quickly lead to exponential behaviour. :) It probably also shouldn't be recursive, I had to increase the stack limit, otherwise I got stack exceptions. Otherwise it seems to work fine, it wasn't that hard :-)

The ruby syntax shouldn't be too hard too read, the nonobvious thing is maybe that '$' marks global variables.

bye, Roman
#! /usr/bin/ruby

$parent = Hash.new $content = Hash.new $result = Hash.new

commit = nil
head = nil
while l = $stdin.gets
	a = l.split(" ")
	if a[0] == "commit"
		commit = a[1]
		head = commit unless head
		$parent[commit] = a[2..-1]
	else
		$content[commit] = true
	end
end

$parent_check = Hash.new $parent_cache = Hash.new

def commit_has_parent?(commit, commit2)
	if $parent_check[commit]
		print "parent loop for #{commit} (#{commit2})?\n"
		p $parent_check
		return false
	end
	return $parent_cache[commit] if $parent_cache.has_key?(commit)
	$parent_check[commit] = true
	res = false
	if $content[commit] > $content[commit2]
		$parent[commit].each do |parent|
			if parent == commit2 || commit_has_parent?(parent, commit2)
				res = true
				break;
			end
		end
	end
	$parent_cache[commit] = res
	$parent_check.delete(commit)
	$parent_cache.clear if $parent_check.empty?
	return res
end
def check_commit(commit)
	return $result[commit] if $result.has_key? commit
	a = Array.new
	$parent[commit].each do |parent|
		parent = check_commit(parent)
		if parent
			a.each_index do |i|
				if a[i] == parent || commit_has_parent?(a[i], parent)
					parent = nil
					break
				elsif commit_has_parent?(parent, a[i])
					a[i] = parent
					parent = nil
					break
				end
			end
		end
		a.push(parent) if parent
	end
	$parent[commit] = a
	$content[commit] = true if a.size > 1
	if $content[commit]
		$result[commit] = commit
		max = 1
		a.each do |parent|
			max = $content[parent] + 1 if max <= $content[parent]
		end
		$content[commit] = max
	else
		$result[commit] = a[0]
	end
	return $result[commit]
end

check_commit(head) #p $result #p $parent

p $content.keys.size
$content.each_key do |commit|
	p [ commit, $parent[commit] ]
	commit = $parent[commit][0]
end
Previous: Linus TorvaldsNext: Linus Torvalds
Message 7 of 58 in “Bizarre missing changes (git bug?)”
  1. Tim HarperJul 21, 2008
  2. Linus TorvaldsJul 21, 2008
  3. Tim HarperJul 21, 2008
  4. Tim HarperJul 21, 2008
  5. Roman ZippelJul 26, 2008
  6. Linus TorvaldsJul 26, 2008
  7. Roman ZippelJul 27, 2008
  8. Linus TorvaldsJul 27, 2008
  9. Roman ZippelJul 27, 2008
  10. Linus TorvaldsJul 27, 2008
  11. Roman ZippelJul 28, 2008
  12. Linus TorvaldsJul 28, 2008
  13. Linus TorvaldsJul 28, 2008
  14. Roman ZippelJul 29, 2008
  15. Martin LanghoffJul 29, 2008
  16. Roman ZippelJul 30, 2008
  17. Martin LanghoffJul 30, 2008
  18. Linus TorvaldsJul 30, 2008
  19. Linus TorvaldsJul 30, 2008
  20. Junio C HamanoJul 30, 2008
  21. Junio C HamanoJul 31, 2008
  22. Linus TorvaldsJul 31, 2008
  23. revision traversal: show full history with merge simplificationJunio C Hamano, Jul 31, 2008
  24. Junio C HamanoJul 31, 2008
  25. Linus TorvaldsJul 31, 2008
  26. revision traversal: show full history with merge simplificationJunio C Hamano, Jul 31, 2008
  27. Linus TorvaldsJul 31, 2008
  28. Junio C HamanoJul 31, 2008
  29. Junio C HamanoAug 1, 2008
  30. Linus TorvaldsAug 1, 2008
  31. Junio C HamanoAug 1, 2008
  32. Jakub NarebskiJul 30, 2008
  33. Linus TorvaldsJul 29, 2008
  34. Linus TorvaldsJul 29, 2008
  35. Roman ZippelJul 29, 2008
  36. David KastrupJul 29, 2008
  37. Linus TorvaldsJul 29, 2008
  38. Roman ZippelJul 30, 2008
  39. Kevin BallardJul 30, 2008
  40. Linus TorvaldsJul 30, 2008
  41. Jeff KingJul 29, 2008
  42. Roman ZippelJul 29, 2008
  43. Olivier GalibertJul 29, 2008
  44. Jeff KingJul 29, 2008
  45. Linus TorvaldsJul 29, 2008
  46. Roman ZippelJul 30, 2008
  47. Linus TorvaldsJul 30, 2008
  48. Jeff KingJul 30, 2008
  49. Linus TorvaldsJul 30, 2008
  50. Roman ZippelJul 30, 2008
  51. Kevin BallardJul 30, 2008
  52. Linus TorvaldsJul 30, 2008
  53. Linus TorvaldsJul 30, 2008
  54. Jeff KingJul 30, 2008
  55. Martin LanghoffJul 27, 2008
  56. Roman ZippelJul 28, 2008
  57. Alex RiesenJul 21, 2008
  58. Linus TorvaldsJul 21, 2008

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.