aboutsummaryrefslogtreecommitdiff
path: root/blame.c
Commit message (Collapse)AuthorAge
* Replace uses of strdup with xstrdup.Shawn Pearce2006-09-02
| | | | | | | | | | | | | | | | Like xmalloc and xrealloc xstrdup dies with a useful message if the native strdup() implementation returns NULL rather than a valid pointer. I just tried to use xstrdup in new code and found it to be missing. However I expected it to be present as xmalloc and xrealloc are already commonly used throughout the code. [jc: removed the part that deals with last_XXX, which I am finding more and more dubious these days.] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memset(hash,0,20) to hashclr(hash).Junio C Hamano2006-08-23
| | | | | | In the same spirit as hashcmp() and hashcpy(). Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce2006-08-23
| | | | | | | | | | | | | | | | | | | | | | | This abstracts away the size of the hash values when copying them from memory location to memory location, much as the introduction of hashcmp abstracted away hash value comparsion. A few call sites were using char* rather than unsigned char* so I added the cast rather than open hashcpy to be void*. This is a reasonable tradeoff as most call sites already use unsigned char* and the existing hashcmp is also declared to be unsigned char*. [jc: Splitted the patch to "master" part, to be followed by a patch for merge-recursive.c which is not in "master" yet. Fixed the cast in the latter hunk to combine-diff.c which was wrong in the original. Also converted ones left-over in combine-diff.c, diff-lib.c and upload-pack.c ] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* remove unnecessary initializationsDavid Rientjes2006-08-15
| | | | | | | | [jc: I needed to hand merge the changes to the updated codebase, so the result needs to be checked.] Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame.c return cleanupDavid Rientjes2006-08-14
| | | | | | | Removes conditional from return Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fixup command names in some usage strings.Ramsay Allan Jones2006-08-03
| | | | | | | | | Most usage strings, such as for command xxx, start with "git-xxx". This updates the rebels to conform to the general pattern. (The git wrapper is an exception to this, of course ...) Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Call setup_git_directory() earlyLinus Torvalds2006-07-28
| | | | | | | | | | | | | | | Any git command that expects to work in a subdirectory of a project, and that reads the git config files (which is just about all of them) needs to make sure that it does the "setup_git_directory()" call before it tries to read the config file. This means, among other things, that we need to move the call out of "init_revisions()", and into the caller. This does the mostly trivial conversion to do that. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Avoid C99 comments, use old-style C comments instead.Pavel Roskin2006-07-10
| | | | | | | | | | This doesn't make the code uglier or harder to read, yet it makes the code more portable. This also simplifies checking for other potential incompatibilities. "gcc -std=c89 -pedantic" can flag many incompatible constructs as warnings, but C99 comments will cause it to emit an error. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix more typos, primarily in the codePavel Roskin2006-07-10
| | | | | | | | | The only visible change is that git-blame doesn't understand "--compability" anymore, but it does accept "--compatibility" instead, which is already documented. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Cast pointers to `void *' when used in a format.Florian Forster2006-06-18
| | | | | | | | ANSI C99 requires void-pointers when using the `%p' format. This patch adds the neccessary cast in `blame.c'. Signed-off-by: Florian Forster <octo@verplant.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Move "void *util" from "struct object" into "struct commit"Linus Torvalds2006-06-17
| | | | | | | | | | | | | | | | | Every single user actually wanted this only for commit objects, and we have no reason to waste space on it for other object types. So just move the structure member from the low-level "struct object" into the "struct commit". This leaves the commit object the same size, and removes one unnecessary pointer from all other object allocations. This shrinks memory usage (still at a fairly hefty half-gig, admittedly) of "git-rev-list --all --objects" on the mozilla repo by another 5% in my tests. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: Add --time to produce raw timestampsFredrik Kuivinen2006-06-16
| | | | | | | fix the usage string and clean up the docs while we are at it Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Make "tree_entry" have a SHA1 instead of a union of object pointersLinus Torvalds2006-05-29
| | | | | | | | This is preparatory work for further cleanups, where we try to make tree_entry look more like the more efficient tree-walk descriptor. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: Fix path pruningFredrik Kuivinen2006-05-03
| | | | | | | | This makes git-blame useable again, it has been totally broken for some time on larger repositories. Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame and friends: adjust to multiple pathspec change.Junio C Hamano2006-04-10
| | | | | | | | | | | This makes things that include revision.h build again. Blame is also built, but I am not sure how well it works (or how well it worked to begin with) -- it was relying on tree-diff to be using whatever pathspec was used the last time, which smells a bit suspicious. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/blame' into nextJunio C Hamano2006-04-07
|\ | | | | | | | | | | * jc/blame: blame -S <ancestry-file> Match ofs/cnt types in diff interface.
| * blame -S <ancestry-file>Junio C Hamano2006-04-07
| | | | | | | | | | | | | | This adds the -S <ancestry-file> option to blame, which is needed by the CVS server emulation. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'master' into nextJunio C Hamano2006-04-05
|\ \ | |/ |/| | | | | * master: blame.c: fix completely broken ancestry traversal.
| * blame.c: fix completely broken ancestry traversal.Junio C Hamano2006-04-05
| | | | | | | | | | | | | | | | Recent revision.c updates completely broken the assignment of blames by not rewriting commit->parents field unless explicitly asked to by the caller. The caller needs to set revs.parents. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | blame: use built-in xdiffJunio C Hamano2006-04-05
|/ | | | | | | | This removes the last use of external diff from core git suite. Also addresses the use of index() -- elsewhere we tend to use strchr(). Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use blob_, commit_, tag_, and tree_type throughout.Peter Eriksen2006-04-04
| | | | | | | | | This replaces occurences of "blob", "commit", "tag", and "tree", where they're really used as type specifiers, which we already have defined global constants for. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/name' into nextJunio C Hamano2006-03-23
|\ | | | | | | | | | | * jc/name: sha1_name: make core.warnambiguousrefs the default. sha1_name: warning ambiguous refs.
| * sha1_name: warning ambiguous refs.Junio C Hamano2006-03-23
| | | | | | | | | | | | | | | | | | This makes sure that many commands that take refs on the command line to honor core.warnambiguousrefs configuration. Earlier, the commands affected by this patch did not read the configuration file. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | fix field width/precision warnings in blame.cLuck, Tony2006-03-21
|/ | | | | | | | Using "size_t" values for printf field width/precision upsets gcc, it wants to see an "int". Signed-off-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: Fix git-blame <directory>Fredrik Kuivinen2006-03-17
| | | | | | | | | Before this patch git-blame <directory> gave non-sensible output. (It assigned blame to some random file in <directory>) Abort with an error message instead. Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: Nicer outputFredrik Kuivinen2006-03-17
| | | | | | | | | | | | | | As pointed out by Junio, it may be dangerous to cut off people's names after 15 bytes. If the name is encoded in an encoding which uses more than one byte per code point we may end up with outputting garbage. Instead of trying to do something smart, just output the entire name. We don't gain much screen space by chopping it off anyway. Furthermore, only output the file name if we actually found any renames. Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: Rename detection (take 2)Fredrik Kuivinen2006-03-10
| | | | | Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: unbreak "diff -U 0".Junio C Hamano2006-03-06
| | | | | | | | | | | | | The commit 604c86d15bb319a1e93ba218fca48ce1c500ae52 changed the original "diff -u0" to "diff -u -U 0" for portability. A big mistake without proper testing. The form "diff -u -U 0" shows the default 3-line contexts, because -u and -U 0 contradicts with each other; "diff -U 0" (or its longhand "diff --unified=0") is what we meant. Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: avoid "diff -u0".Junio C Hamano2006-03-05
| | | | | | As Linus suggests, use "diff -u -U 0" instead. Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame and annotate: show localtime with timezone.Junio C Hamano2006-03-05
| | | | | | | Earlier they showed gmtime and timezone, which was inconsistent with the way our commits and tags are pretty-printed. Signed-off-by: Junio C Hamano <junkio@cox.net>
* blame: avoid -lm by not using log().Junio C Hamano2006-03-05
| | | | | | ... as suggested on the list. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-blame: Make the output human readableFredrik Kuivinen2006-03-05
| | | | | | | | | The default output mode is slightly different from git-annotate's. However, git-annotate's output mode can be obtained by using the '-c' flag. Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Const tightening.Junio C Hamano2006-03-05
| | | | | | | | | Mark Wooding noticed there was a type mismatch warning in git.c; this patch does things slightly differently (mostly tightening const) and was what I was holding onto, waiting for the setup-revisions change to be merged into the master branch. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-blame, take 2Fredrik Kuivinen2006-03-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here is an updated version of git-blame. The main changes compared to the first version are: * Use the new revision.h interface to do the revision walking * Do the right thing in a lot of more cases than before. In particular parallel development tracks are hopefully handled sanely. * Lots of clean-up It still won't follow file renames though. There are still some differences in the output between git-blame and git-annotate. For example, in 'Makefile' git-blame assigns lines 354-358 to 455a7f3275d264f6e66045b92c83747ec461dda5 and git-annotate assigns the same lines to 79a9d8ea0d88a3667ad19be8e705405ab5d896f1. I think git-blame is correct in this case. This patterns occur in several other places, git-annotate seems to sometimes assign lines to merge commits when the lines actually changed in some other commit which precedes the merge. [jc: I have conned Ryan into doing test cases, so that it would help development and fixes on both implementations. Let the battle begin! ;-) ] Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge part of 'lt/rev-list' into 'fk/blame'Junio C Hamano2006-03-02
| | | | | | | | Now blame will depend on the new revision walker infrastructure, we need to make it depend on earlier parts of Linus' rev-list topic branch, hence this merge. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add git-blame, a tool for assigning blame.Fredrik Kuivinen2006-02-21
I have also been working on a blame program. The algorithm is pretty much the one described by Junio in his blame.perl. My variant doesn't handle renames, but it shouldn't be too hard to add that. The output is minimal, just the line number followed by the commit SHA1. An interesting observation is that the output from my git-blame and your git-annotate doesn't match on all files in the git repository. One example where several lines differ is read-cache.c. I haven't investigated it further to find out which one is correct. The code should be considered as a work in progress. It certainly has a couple of rough edges. The output looks fairly sane on the few files I have tested it on, but it wouldn't be too surprising if it gets some cases wrong. [jc: adding it to pu for wider comments. I did minimum whitespace fixups but it still needs an indent run and -Wdeclaration-after-statement fixups.] Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>