summaryrefslogtreecommitdiff
path: root/builtin-blame.c
AgeCommit message (Collapse)AuthorFilesLines
2010-02-08Merge branch 'maint-1.6.5' into maintLibravatar Junio C Hamano1-1/+1
* maint-1.6.5: blame: prevent a segv when -L given start > EOF
2010-02-08blame: prevent a segv when -L given start > EOFLibravatar Jay Soffian1-1/+1
blame would segv if given -L <lineno> with <lineno> past the end of the file. While we're fixing the bug, add test cases for an invalid <start> when called as -L <start>,<end> or -L<start>. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-22Merge branch 'maint'Libravatar Junio C Hamano1-3/+10
* maint: Prevent git blame from segfaulting on a missing author name
2009-12-22Prevent git blame from segfaulting on a missing author nameLibravatar David Reiss1-3/+10
The human-readable author and committer name can be missing from commits imported from foreign SCM interfaces. Make sure we parse the "author" and "committer" line a bit more leniently and avoid segfaulting by assuming the name always exists. Signed-off-by: David Reiss <dreiss@facebook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-23Merge branch 'jc/log-stdin'Libravatar Junio C Hamano1-0/+1
* jc/log-stdin: Add trivial tests for --stdin option to log family Make --stdin option to "log" family read also pathspecs setup_revisions(): do not call get_pathspec() too early Teach --stdin option to "log" family read_revision_from_stdin(): use strbuf Conflicts: revision.c
2009-11-20Teach --stdin option to "log" familyLibravatar Junio C Hamano1-0/+1
Move the logic to read revs from standard input that rev-list knows about from it to revision machinery, so that all the users of setup_revisions() can feed the list of revs from the standard input when "--stdin" is used on the command line. Allow some users of the revision machinery that want different semantics from the "--stdin" option to disable it by setting an option in the rev_info structure. This also cleans up the kludge made to bundle.c via cut and paste. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-21blame: make sure that the last line ends in an LFLibravatar Johannes Schindelin1-0/+6
This is convenient when parsing multiple the blame of multiple files, for example: git ls-files -z --exclude-standard -- "*.[ch]" | xargs --null -n 1 git blame -p > output and then analyzing the 'output' file using a seperate script. Currently the parsing is difficult when not all files have a newline at EOF, this patch ensures that even such files have a newline at the end of the blame output. Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> CC: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-31Style fixes, add a space after if/for/while.Libravatar Brian Gianforcaro1-1/+1
The majority of code in core git appears to use a single space after if/for/while. This is an attempt to bring more code to this standard. These are entirely cosmetic changes. Signed-off-by: Brian Gianforcaro <b.gianfo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-27Use die_errno() instead of die() when checking syscallsLibravatar Thomas Rast1-4/+4
Lots of die() calls did not actually report the kind of error, which can leave the user confused as to the real problem. Use die_errno() where we check a system/library call that sets errno on failure, or one of the following that wrap such calls: Function Passes on error from -------- -------------------- odb_pack_keep open read_ancestry fopen read_in_full xread strbuf_read xread strbuf_read_file open or strbuf_read_file strbuf_readlink readlink write_in_full xwrite Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-27Convert existing die(..., strerror(errno)) to die_errno()Libravatar Thomas Rast1-4/+3
Change calls to die(..., strerror(errno)) to use the new die_errno(). In the process, also make slight style adjustments: at least state _something_ about the function that failed (instead of just printing the pathname), and put paths in single quotes. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-03Merge branch 'maint'Libravatar Junio C Hamano1-8/+18
* maint: blame: correctly handle a path that used to be a directory add -i: do not dump patch during application Update draft release notes for 1.6.3.2 grep: fix colouring of matches with zero length Documentation: teach stash/pop workflow instead of stash/apply Change xdl_merge to generate output even for null merges t6023: merge-file fails to output anything for a degenerate merge
2009-06-03blame: correctly handle a path that used to be a directoryLibravatar Junio C Hamano1-8/+18
When trying to see if the same path exists in the parent, we ran "diff-tree" with pathspec set to the path we are interested in with the parent, and expect either to have exactly one resulting filepair (either "changed from the parent", "created when there was none") or nothing (when there is no change from the parent). If the path used to be a directory, however, we will also see unbounded number of entries that talk about the files that used to exist underneath the directory in question. Correctly pick only the entry that describes the path we are interested in in such a case (namely, the creation of the path as a regular file). Noticed by Ben Willard. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-25parse-opts: prepare for OPT_FILENAMELibravatar Stephen Boyd1-1/+1
To give OPT_FILENAME the prefix, we pass the prefix to parse_options() which passes the prefix to parse_options_start() which sets the prefix member of parse_opts_ctx accordingly. If there isn't a prefix in the calling context, passing NULL will suffice. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-01Fix a bunch of pointer declarations (codestyle)Libravatar Felipe Contreras1-4/+4
Essentially; s/type* /type */ as per the coding guidelines. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-26Merge branch 'jc/maint-1.6.0-blame-s'Libravatar Junio C Hamano1-4/+4
* jc/maint-1.6.0-blame-s: blame: read custom grafts given by -S before calling setup_revisions() Conflicts: builtin-blame.c
2009-03-18blame: read custom grafts given by -S before calling setup_revisions()Libravatar Junio C Hamano1-4/+4
setup_revisions() while getting the command line arguments parses the given commits from the command line, which means their direct parents will not be rewritten by the custom graft file. Call read_ancestry() early to work around this issue. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-11Merge branch 'el/blame-date'Libravatar Junio C Hamano1-16/+51
* el/blame-date: Make git blame's date output format configurable, like git log
2009-03-05Make git blame's date output format configurable, like git logLibravatar Eugene Letuchy1-16/+51
Add the following: - git config value blame.date that expects one of the git log date formats (e.g. relative,local,default,iso,...); - git blame command line option --date expects one of the git log date formats; - documentation in blame-options.txt; - git blame uses the appropriate date.c functions and enums to make sense of the date format and provide appropriate data; git blame continues to line up the output columns by padding the date column up to the max width of the chosen date format. The date format for git blame without both blame.date and --date continues to be ISO for backwards compatibility. git annotate ignores the date format specifiers and continues to uses the ISO format, as before. Signed-off-by: Eugene Letuchy <eugene@facebook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-05Merge branch 'jc/blame'Libravatar Junio C Hamano1-64/+43
* jc/blame: blame: show "previous" information in --porcelain/--incremental format git-blame: refactor code to emit "porcelain format" output
2009-02-15Merge branch 'ms/mailmap'Libravatar Junio C Hamano1-20/+32
* ms/mailmap: Move mailmap documentation into separate file Change current mailmap usage to do matching on both name and email of author/committer. Add map_user() and clear_mailmap() to mailmap Add find_insert_index, insert_at_index and clear_func functions to string_list Add mailmap.file as configurational option for mailmap location
2009-02-08Change current mailmap usage to do matching on both name and email of ↵Libravatar Marius Storm-Olsen1-19/+31
author/committer. Signed-off-by: Marius Storm-Olsen <marius@trolltech.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-08Add mailmap.file as configurational option for mailmap locationLibravatar Marius Storm-Olsen1-1/+1
This allows us to augment the repo mailmap file, and to use mailmap files elsewhere than the repository root. Meaning that the entries in mailmap.file will override the entries in "./.mailmap", should they match. Signed-off-by: Marius Storm-Olsen <marius@trolltech.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-04builtin-blame.c: Use utf8_strwidth for author's namesLibravatar Geoffrey Thomas1-5/+7
git blame misaligns output if a author's name has a differing display width and strlen; for instance, an accented Latin letter that takes two bytes to encode will cause the rest of the line to be shifted to the left by one. To fix this, use utf8_strwidth instead of strlen (and compute the padding ourselves, since printf doesn't know about UTF-8). Signed-off-by: Geoffrey Thomas <geofft@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-17builtin-blame.c: use strbuf_readlink()Libravatar Junio C Hamano1-4/+1
When faking a commit out of the work tree contents, use strbuf_readlink() to read the contents of symbolic links. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-11-08Merge branch 'rs/blame'Libravatar Junio C Hamano1-151/+56
* rs/blame: blame: use xdi_diff_hunks(), get rid of struct patch add xdi_diff_hunks() for callers that only need hunk lengths Allow alternate "low-level" emit function from xdl_diff Always initialize xpparam_t to 0 blame: inline get_patch()
2008-10-25blame: use xdi_diff_hunks(), get rid of struct patchLibravatar René Scharfe1-139/+52
Based on a patch by Brian Downing, this replaces the struct patch based code for blame passing with calls to xdi_diff_hunks(). This way we avoid generating and then parsing patches; we only let the interesting infos be passed to our callbacks instead. This makes blame a bit faster: $ blame="./git blame -M -C -C -p --incremental v1.6.0" # master $ /usr/bin/time $blame Makefile >/dev/null 1.38user 0.14system 0:01.52elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+12226minor)pagefaults 0swaps $ /usr/bin/time $blame cache.h >/dev/null 1.66user 0.13system 0:01.80elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+12262minor)pagefaults 0swaps # this patch series $ /usr/bin/time $blame Makefile >/dev/null 1.27user 0.12system 0:01.40elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+11836minor)pagefaults 0swaps $ /usr/bin/time $blame cache.h >/dev/null 1.52user 0.12system 0:01.70elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (0major+12052minor)pagefaults 0swaps Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-25Always initialize xpparam_t to 0Libravatar Brian Downing1-0/+1
We're going to be adding some parameters to this, so we can't have any uninitialized data in it. Signed-off-by: Brian Downing <bdowning@lavos.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-25blame: inline get_patch()Libravatar René Scharfe1-20/+11
Inline get_patch() to its only call site as a preparation for getting rid of struct patch. Also we don't need to check the ptr members because fill_origin_blob() already did, and the caller didn't check for NULL anyway, so drop the test. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-21builtin-blame: Reencode commit messages according to git-log rules.Libravatar Alexander Gavrilov1-5/+11
Currently git-blame outputs text from the commit messages (e.g. the author name and the summary string) as-is, without even providing any information about the encoding used for the data. It makes interpreting the data in multilingual environment very difficult. This commit changes the blame implementation to recode the messages using the rules used by other commands like git-log. Namely, the target encoding can be specified through the i18n.commitEncoding or i18n.logOutputEncoding options, or directly on the command line using the --encoding parameter. Converting the encoding before output seems to be more friendly to the porcelain tools than simply providing the value of the encoding header, and does not require changing the output format. If anybody needs the old behavior, it is possible to achieve it by specifying --encoding=none. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-12blame: show "previous" information in --porcelain/--incremental formatLibravatar Junio C Hamano1-30/+12
When the final blame is laid for a line to a <commit, path> pair, it also gives a "previous" information to --porcelain and --incremental output format. It gives the parent commit of the blamed commit, _and_ a path in that parent commit that corresponds to the blamed path --- in short, it is the origin that would have been blamed (or passed blame through) for the line _if_ the blamed commit did not change that line. This unfortunately makes sanity checking of refcount quite complex, so I ripped it out for now. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-12git-blame: refactor code to emit "porcelain format" outputLibravatar Junio C Hamano1-34/+31
Both the --porcelain and --incremental format shared the same output format but implemented with two identical codepaths. This merges them into one shared function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-12Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerLibravatar Brandon Casey1-2/+1
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-10-06Merge branch 'maint'Libravatar Shawn O. Pearce1-0/+2
* maint: Update release notes for 1.6.0.3 Teach rebase -i to honor pre-rebase hook docs: describe pre-rebase hook do not segfault if make_cache_entry failed make prefix_path() never return NULL fix bogus "diff --git" header from "diff --no-index" Fix fetch/clone --quiet when stdout is connected builtin-blame: Fix blame -C -C with submodules. bash: remove fetch, push, pull dashed form leftovers Conflicts: diff.c
2008-10-05builtin-blame: Fix blame -C -C with submodules.Libravatar Alexander Gavrilov1-0/+2
When performing copy detection, git-blame tries to read gitlinks as blobs, which causes it to die. This patch adds a check to skip them. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-06Merge branch 'maint'Libravatar Junio C Hamano1-4/+5
* maint: Update draft release notes for 1.6.0.2 stash: refresh the index before deciding if the work tree is dirty Mention the fact that 'git annotate' is only for backward compatibility. "blame -c" should be compatible with "annotate" git-gui: Fix diff parsing for lines starting with "--" or "++" git-gui: Fix string escaping in po2msg.sh git gui: show diffs with a minimum of 1 context line git-gui: update all remaining translations to French. git-gui: Update french translation
2008-09-05"blame -c" should be compatible with "annotate"Libravatar Junio C Hamano1-4/+5
There is no reason to have a separate variable cmd_is_annotate; OUTPUT_ANNOTATE_COMPAT option is supposed to produce the compatibility output, and we should produce the same output even when the command was not invoked as "annotate" but as "blame -c". Noticed by Pasky. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-03Merge branch 'maint'Libravatar Junio C Hamano1-1/+1
* maint: Start 1.6.0.2 maintenance cycle tests: use "git xyzzy" form (t7200 - t9001) tests: use "git xyzzy" form (t7000 - t7199) Fix passwd(5) ref and reflect that commit doens't use commit-tree improve handling of sideband message display tests: use "git xyzzy" form (t3600 - t6999) tests: use "git xyzzy" form (t0000 - t3599) checkout: fix message when leaving detached HEAD clone: fix creation of explicitly named target directory 'git foo' program identifies itself without dash in die() messages setup_git_directory(): fix move to worktree toplevel directory update-index: fix worktree setup Start conforming code to "git subcmd" style read-tree: setup worktree if merge is required grep: fix worktree setup diff*: fix worktree setup Conflicts: RelNotes t/t3900-i18n-commit.sh t/t7003-filter-branch.sh
2008-08-30Start conforming code to "git subcmd" styleLibravatar Heikki Orsila1-1/+1
User notifications are presented as 'git cmd', and code comments are presented as '"cmd"' or 'git's cmd', rather than 'git-cmd'. Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-14xdiff-interface: hide the whole "xdiff_emit_state" business from the callerLibravatar Junio C Hamano1-3/+1
This further enhances xdi_diff_outf() interface so that it takes two common parameters: the callback function that processes one line at a time, and a pointer to its application specific callback data structure. xdi_diff_outf() creates its own "xdiff_emit_state" structure and stashes these two away inside it, which is used by the lowest level output function in the xdiff_outf() callchain, consume_one(), to call back to the application layer. With this restructuring, we lift the requirement that the caller supplied callback data structure embeds xdiff_emit_state structure as its first member. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-13Make xdi_diff_outf interface for running xdiff_outf diffsLibravatar Brian Downing1-3/+1
To prepare for the need to initialize and release resources for an xdi_diff with the xdiff_outf output function, make a new function to wrap this usage. Old: ecb.outf = xdiff_outf; ecb.priv = &state; ... xdi_diff(file_p, file_o, &xpp, &xecfg, &ecb); New: xdi_diff_outf(file_p, file_o, &state.xm, &xpp, &xecfg, &ecb); Signed-off-by: Brian Downing <bdowning@lavos.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-31Teach --find-copies-harder to "git blame"Libravatar Junio C Hamano1-0/+4
It's equivalent to "-C -C" with the diff family. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21Rename path_list to string_listLibravatar Johannes Schindelin1-5/+5
The name path_list was correct for the first usage of that data structure, but it really is a general-purpose string list. $ perl -i -pe 's/path-list/string-list/g' $(git grep -l path-list) $ perl -i -pe 's/path_list/string_list/g' $(git grep -l path_list) $ git mv path-list.h string-list.h $ git mv path-list.c string-list.c $ perl -i -pe 's/has_path/has_string/g' $(git grep -l has_path) $ perl -i -pe 's/path/string/g' string-list.[ch] $ git mv Documentation/technical/api-path-list.txt \ Documentation/technical/api-string-list.txt $ perl -i -pe 's/strdup_paths/strdup_strings/g' $(git grep -l strdup_paths) ... and then fix all users of string-list to access the member "string" instead of "path". Documentation/technical/api-string-list.txt needed some rewrapping, too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-16Merge branch 'sb/dashless'Libravatar Junio C Hamano1-1/+1
* sb/dashless: Make usage strings dash-less t/: Use "test_must_fail git" instead of "! git" t/test-lib.sh: exit with small negagive int is ok with test_must_fail Conflicts: builtin-blame.c builtin-mailinfo.c builtin-mailsplit.c builtin-shortlog.c git-am.sh t/t4150-am.sh t/t4200-rerere.sh
2008-07-15Do not try to detect move/copy for entries below threshold.Libravatar Alexander Gavrilov1-5/+11
Splits for such entries are rejected anyway, so there is no point even trying to compute them. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-15Avoid rescanning unchanged entries in search for copies.Libravatar Alexander Gavrilov1-2/+19
Repeatedly comparing the same entry against the same set of blobs in search for copies is quite pointless. This huge waste of effort can be avoided using a flag in the blame_entry structure. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-13Make usage strings dash-lessLibravatar Stephan Beyer1-1/+1
When you misuse a git command, you are shown the usage string. But this is currently shown in the dashed form. So if you just copy what you see, it will not work, when the dashed form is no longer supported. This patch makes git commands show the dash-less version. For shell scripts that do not specify OPTIONS_SPEC, git-sh-setup.sh generates a dash-less usage string now. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-09revisions: refactor handle_revision_opt into parse_revision_opt.Libravatar Pierre Habouzit1-10/+1
It seems we're using handle_revision_opt the same way each time, have a wrapper around it that does the 9-liner we copy each time instead. handle_revision_opt can be static in the module for now, it's always possible to make it public again if needed. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-09git-blame: fix lapsusLibravatar Pierre Habouzit1-1/+1
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-08git-blame: migrate to incremental parse-option [2/2]Libravatar Pierre Habouzit1-92/+38
Now use handle_revision_args instead of parse_revisions, and simplify the handling of old-style arguments a lot thanks to the filtering. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-08git-blame: migrate to incremental parse-option [1/2]Libravatar Pierre Habouzit1-102/+118
This step merely moves the parser to an incremental version, still using parse_revisions. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>