{"thread":{"id":"25717","subject":"git blame --reverse: it's all a bit mysterious","startedAt":"2010-11-11T19:51:34Z","lastAt":"2010-11-11T22:15:04Z","messageCount":2,"participants":["Robin Green","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155736","messageId":"87hbfnabax.wl%greenrd@greenrd.org","threadId":"25717","inReplyTo":null,"subject":"git blame --reverse: it's all a bit mysterious","fromName":"Robin Green","fromEmail":"greenrd@greenrd.org","sentAt":"2010-11-11T19:51:34Z","receivedAt":"2010-11-11T19:51:34Z","isPatch":false,"sender":{"key":"greenrd@greenrd.org","avatar":"https://gravatar.com/avatar/fe9d42e91e6aee9f60063d7f29a314449a3e04d3ed3e2c521c464ea8c3a2859e?d=mp&s=160"},"body":"The --reverse option to git blame (which isn't listed in the option summary when you type just \"git blame\",\nbut *is* listed in the cross-referenced git-rev-list(1), though that's not terribly helpful) doesn't seem\nto understand what I'm trying to ask, and the man page is not much help.\n\ngreenrd@cspcnh /var/db/paludis/repositories/arbor $ strace -f -e trace=file git blame --reverse 48d96ce0e486eedea9fda0f8e480ba3c6caffc90..HEAD exlibs/eutils.exlib\nexecve(\"/usr/bin/git\", [\"git\", \"blame\", \"--reverse\", \"48d96ce0e486eedea9fda0f8e480ba3c\"..., \"exlibs/eutils.exlib\"], [/* 41 vars */]) = 0\naccess(\"/etc/ld.so.preload\", R_OK)      = -1 ENOENT (No such file or directory)\nopen(\"/etc/ld.so.cache\", O_RDONLY)      = 3\nopen(\"/usr/lib/libz.so.1\", O_RDONLY)    = 3\nopen(\"/usr/lib/libcrypto.so.0.9.8\", O_RDONLY) = 3\nopen(\"/lib/libpthread.so.0\", O_RDONLY)  = 3\nopen(\"/lib/libc.so.6\", O_RDONLY)        = 3\nopen(\"/lib/libdl.so.2\", O_RDONLY)       = 3\ngetcwd(\"/var/db/paludis/repositories/arbor\", 4096) = 35\nstat64(\".\", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0\nstat64(\".git\", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0\naccess(\".git/objects\", X_OK)            = 0\naccess(\".git/refs\", X_OK)               = 0\nlstat64(\".git/HEAD\", {st_mode=S_IFREG|0644, st_size=23, ...}) = 0\nopen(\".git/HEAD\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/etc/gitconfig\", R_OK)          = 0\nopen(\"/etc/gitconfig\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/home/greenrd/.gitconfig\", R_OK) = 0\nopen(\"/home/greenrd/.gitconfig\", O_RDONLY|O_LARGEFILE) = 3\nstat64(\".git\", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0\naccess(\".git/config\", R_OK)             = 0\nopen(\".git/config\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/etc/gitconfig\", R_OK)          = 0\nopen(\"/etc/gitconfig\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/home/greenrd/.gitconfig\", R_OK) = 0\nopen(\"/home/greenrd/.gitconfig\", O_RDONLY|O_LARGEFILE) = 3\naccess(\".git/config\", R_OK)             = 0\nopen(\".git/config\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/etc/gitconfig\", R_OK)          = 0\nopen(\"/etc/gitconfig\", O_RDONLY|O_LARGEFILE) = 3\naccess(\"/home/greenrd/.gitconfig\", R_OK) = 0\nopen(\"/home/greenrd/.gitconfig\", O_RDONLY|O_LARGEFILE) = 3\naccess(\".git/config\", R_OK)             = 0\nopen(\".git/config\", O_RDONLY|O_LARGEFILE) = 3\nlstat64(\"exlibs/eutils.exlib\", 0xbf896768) = -1 ENOENT (No such file or directory)\nstat64(\".git\", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0\ngetcwd(\"/var/db/paludis/repositories/arbor\", 1024) = 35\nchdir(\".git\")                           = 0\ngetcwd(\"/var/db/paludis/repositories/arbor/.git\", 4096) = 40\nlstat64(\"/var/db/paludis/repositories/arbor/.git\", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0\nchdir(\"/var/db/paludis/repositories/arbor\") = 0\nchdir(\"/var/db/paludis/repositories/arbor\") = 0\nlstat64(\"48d96ce0e486eedea9fda0f8e480ba3c6caffc90..HEAD\", 0xbf896768) = -1 ENOENT (No such file or directory)\nfatal: cannot stat path '48d96ce0e486eedea9fda0f8e480ba3c6caffc90..HEAD': No such file or directory\n\nNow this error message is very unhelpful. Why is git blame trying to interpret this as a filename,\nwhen the man page implies that it expects a revision range (or possibly a single revision, if you\nbelieve the option summary at the top of the man page)?\n\nThis isn't the first time I've noticed git misinterpreting a revision (range) as a filename, but\nin this case, I have no clue what is going on.\n\nI notice from the strace output that it's looking for the specified filename first, which of course\nno longer exists in HEAD. The man page implies that blame --reverse only needs the file to exist\nin the first revision of the revision range; if it also needs to exist in the *working tree* or\nsomething like that, that should be documented in the man page.\n\nI'm using git version 1.7.3.2.\n-- \nRobin Green\n"},{"id":"155743","messageId":"201011112315.04299.trast@student.ethz.ch","threadId":"25717","inReplyTo":"87hbfnabax.wl%greenrd@greenrd.org","subject":"Re: git blame --reverse: it's all a bit mysterious","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-11-11T22:15:04Z","receivedAt":"2010-11-11T22:15:04Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Robin Green wrote:\n> greenrd@cspcnh /var/db/paludis/repositories/arbor $ strace -f -e trace=file git blame --reverse 48d96ce0e486eedea9fda0f8e480ba3c6caffc90..HEAD exlibs/eutils.exlib\n[...]\n> I notice from the strace output that it's looking for the specified filename first, which of course\n> no longer exists in HEAD.\n\nThis can be fixed by saying\n\n  git blame --reverse 48d96ce0e486eedea9fda0f8e480ba3c6caffc90..HEAD -- exlibs/eutils.exlib\n\ni.e., you need to supply the -- to explicitly tell it that the stuff\nafter it is a filename.\n\nIt's probably a code (not documentation) bug since blame takes only a\nsingle revision range anyway, so everything after that should be\nassumed to be a filename, but maybe I'm missing something.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}