aboutsummaryrefslogtreecommitdiff
path: root/builtin-rerere.c
Commit message (Collapse)AuthorAge
* Move 'builtin-*' into a 'builtin/' subdirectoryLinus Torvalds2010-02-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shrinks the top-level directory a bit, and makes it much more pleasant to use auto-completion on the thing. Instead of [torvalds@nehalem git]$ em buil<tab> Display all 180 possibilities? (y or n) [torvalds@nehalem git]$ em builtin-sh builtin-shortlog.c builtin-show-branch.c builtin-show-ref.c builtin-shortlog.o builtin-show-branch.o builtin-show-ref.o [torvalds@nehalem git]$ em builtin-shor<tab> builtin-shortlog.c builtin-shortlog.o [torvalds@nehalem git]$ em builtin-shortlog.c you get [torvalds@nehalem git]$ em buil<tab> [type] builtin/ builtin.h [torvalds@nehalem git]$ em builtin [auto-completes to] [torvalds@nehalem git]$ em builtin/sh<tab> [type] shortlog.c shortlog.o show-branch.c show-branch.o show-ref.c show-ref.o [torvalds@nehalem git]$ em builtin/sho [auto-completes to] [torvalds@nehalem git]$ em builtin/shor<tab> [type] shortlog.c shortlog.o [torvalds@nehalem git]$ em builtin/shortlog.c which doesn't seem all that different, but not having that annoying break in "Display all 180 possibilities?" is quite a relief. NOTE! If you do this in a clean tree (no object files etc), or using an editor that has auto-completion rules that ignores '*.o' files, you won't see that annoying 'Display all 180 possibilities?' message - it will just show the choices instead. I think bash has some cut-off around 100 choices or something. So the reason I see this is that I'm using an odd editory, and thus don't have the rules to cut down on auto-completion. But you can simulate that by using 'ls' instead, or something similar. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make 'rerere forget' work from a subdirectory.Johannes Sixt2010-01-21
| | | | | | | | | It forgot to apply the prefix to the paths given on the command line. [jc: added test] Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jc/cache-unmerge'Junio C Hamano2010-01-20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * jc/cache-unmerge: rerere forget path: forget recorded resolution rerere: refactor rerere logic to make it independent from I/O rerere: remove silly 1024-byte line limit resolve-undo: teach "update-index --unresolve" to use resolve-undo info resolve-undo: "checkout -m path" uses resolve-undo information resolve-undo: allow plumbing to clear the information resolve-undo: basic tests resolve-undo: record resolved conflicts in a new index extension section builtin-merge.c: use standard active_cache macros Conflicts: builtin-ls-files.c builtin-merge.c builtin-rerere.c
| * rerere forget path: forget recorded resolutionJunio C Hamano2010-01-10
| | | | | | | | | | | | | | | | | | After you find out an earlier resolution you told rerere to use was a mismerge, there is no easy way to clear it. A new subcommand "forget" can be used to tell git to forget a recorded resolution, so that you can redo the merge from scratch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/rerere'Junio C Hamano2010-01-18
|\ \ | |/ |/| | | | | * jc/rerere: Teach --[no-]rerere-autoupdate option to merge, revert and friends
| * Teach --[no-]rerere-autoupdate option to merge, revert and friendsJunio C Hamano2009-12-04
| | | | | | | | | | | | | | Introduce a command line option to override rerere.autoupdate configuration variable to make it more useful. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Sync with 1.6.5.5Junio C Hamano2009-12-05
|\ \ | |/ |/| | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * rerere: don't segfault on failure to open rr-cacheJeff King2009-12-04
| | | | | | | | | | | | | | | | | | | | | | | | The rr-cache directory should always exist if we are doing garbage collection (earlier code paths check this explicitly), but we may not necessarily succeed in opening it (for example, due to permissions problems). In that case, we should print an error message rather than simply segfaulting. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Let 'git <command> -h' show usage without a git dirJonathan Nieder2009-11-10
|/ | | | | | | | | | There is no need for "git <command> -h" to depend on being inside a repository. Reported by Gerfried Fuchs through http://bugs.debian.org/462557 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* replace direct calls to unlink(2) with unlink_or_warnAlex Riesen2009-04-29
| | | | | | | | | | | | | | | | | This helps to notice when something's going wrong, especially on systems which lock open files. I used the following criteria when selecting the code for replacement: - it was already printing a warning for the unlink failures - it is in a function which already printing something or is called from such a function - it is in a static function, returning void and the function is only called from a builtin main function (cmd_) - it is in a function which handles emergency exit (signal handlers) - it is in a function which is obvously cleaning up the lockfiles Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere: remove duplicated functionsSZEDER Gábor2009-02-14
| | | | | | | | | | | | | | Both rerere.c and builtin-rerere.c define the static functions rr_path() and has_resolution() the exact same way. To eliminate this code duplication this patch turns the functions in rerere.c non-static, and makes builtin-rerere.c use them. Also, since this puts these two functions into the global namespace, rename them to rerere_path() and has_rerere_resolution(), respectively, and rename their "name" parameter to "hex", because it better reflects what that parameter actually is. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* add is_dot_or_dotdot inline functionAlexander Potashev2009-01-11
| | | | | | | | | | A new inline function is_dot_or_dotdot is used to check if the directory name is either "." or "..". It returns a non-zero value if the given string is "." or "..". It's applicable to a lot of Git source code. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Always initialize xpparam_t to 0Brian Downing2008-10-25
| | | | | | | | 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>
* Rename path_list to string_listJohannes Schindelin2008-07-21
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'sb/dashless'Junio C Hamano2008-07-16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * Make usage strings dash-lessStephan Beyer2008-07-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | rerere: Separate libgit and builtin functionsStephan Beyer2008-07-10
| | | | | | | | | | | | | | | | | | | | | | This patch moves rerere()-related functions into a newly created rerere.c file. The setup_rerere() function is needed by both rerere() and cmd_rerere(), so this function is moved to rerere.c and declared non-static (and "extern") in newly created rerere.h file. Signed-off-by: Stephan Beyer <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | builtin-rerere: more carefully find conflict markersOlivier Marin2008-07-10
|/ | | | | | | | | | | | | | | | | | When a conflicting file contains a line that begin with "=======", rerere failed to parse conflict markers. This result to a wrong preimage file and an unexpected error for the user. The boundary between ours and theirs not just begin with 7 equals, but is followed by either a SP or a LF. This patch enforces parsing rules so that markers match in the right order, and when ambiguous, the command does not autoresolve the conflicted file. Especially because we are introducing rerere.autoupdate configuration (which is off by default for safety) that automatically stages the resolution made by rerere, it is necessary to make sure that we do not autoresolve when there is any ambiguity. Signed-off-by: Olivier Marin <dkr@freesurf.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere.autoupdateJunio C Hamano2008-06-22
| | | | | When this configuration is set, paths that are autoresolved by git-rerere are updated in the index as well.
* rerere: remove dubious "tail_optimization"Junio C Hamano2008-06-22
| | | | | | | | | | It is dubious if it is cheaper to shift entries repeatedly using memmove() to collect entries that needs to be written out in front of an array than simply marking the entries to be skipped. In addition, the label called this "tail optimization", but this obviously is not what people usually call with that name. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git-rerere: detect unparsable conflictsJunio C Hamano2008-06-22
| | | | | | rerere did not detect the case where <<< === >>> markers did not match. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere: rerere_created_at() and has_resolution() abstractionJunio C Hamano2008-06-22
| | | | | | | | | | | | | | | | | | | | There were too many places in the code how an entry in the rerere database looks like, and the garbage_collect() function that iterates over subdirectories of the rr-cache directory was the worse offender. Introduce two helper functions, rerere_created_at() and has_resolution(), to abstract out the logic a bit better. Incidentally this fixes a small memory leak in garbage_collect() function. The path list to collect the entries to be pruned were defined to strdup the paths but the caller was feeding a path after doing an extra copy. Because the list does not have to be sorted by conflict signature hash, we use path_list_append() instead of path_list_insert(). While we are at it, make a conflicted hunk comparision in handle_file() a bit easier to read. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* builtin-rerere: fix a small leakJunio C Hamano2008-06-17
| | | | | | | | | | The data read from MERGE_RR file is kept in path-list by hanging textual 40-byte conflict signature to path of the blob that contains the conflict. The signature is strdup'ed twice, and the second copy is given to the path-list, leaking the first copy. Signed-off-by: Junio C Hamano <junio@pobox.com> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
* Provide git_config with a callback-data parameterJohannes Schindelin2008-05-14
| | | | | | | | | | | | git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'maint'Junio C Hamano2008-02-26
|\ | | | | | | | | | | | | | | | | | | | | * maint: Documentation/git-am.txt: Pass -r in the example invocation of rm -f .dotest timezone_names[]: fixed the tz offset for New Zealand. filter-branch documentation: non-zero exit status in command abort the filter rev-parse: fix potential bus error with --parseopt option spec handling Use a single implementation and API for copy_file() Documentation/git-filter-branch: add a new msg-filter example Correct fast-export file mode strings to match fast-import standard
| * Use a single implementation and API for copy_file()Daniel Barkalow2008-02-25
| | | | | | | | | | | | | | | | Originally by Kristian Hï¿œgsberg; I fixed the conversion of rerere, which had a different API. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Make on-disk index representation separate from in-core oneLinus Torvalds2008-01-21
|/ | | | | | | | | | | | | | | | This converts the index explicitly on read and write to its on-disk format, allowing the in-core format to contain more flags, and be simpler. In particular, the in-core format is now host-endian (as opposed to the on-disk one that is network endian in order to be able to be shared across machines) and as a result we can dispense with all the htonl/ntohl on accesses to the cache_entry fields. This will make it easier to make use of various temporary flags that do not exist in the on-disk format. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* Improve use of lockfile APIBrandon Casey2008-01-16
| | | | | | | Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
* xdl_diff: identify call sites.Junio C Hamano2007-12-13
| | | | | | | | This inserts a new function xdi_diff() that currently does not do anything other than calling the underlying xdl_diff() to the callchain of current callers of xdl_diff() function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Export rerere() and launch_editor().Kristian Høgsberg2007-09-27
| | | | | Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere: Fix use of an empty strbuf.bufJunio C Hamano2007-09-26
| | | | | | | | | The code incorrectly assumed that strbuf.buf is always an allocated piece of memory that has NUL at offset strbuf.len. That assumption does not hold for a freshly initialized empty strbuf. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make builtin-rerere use of strbuf nicer and more efficient.Pierre Habouzit2007-09-26
| | | | | | memory is now reused across hunks. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Now that cache.h needs strbuf.h, remove useless includes.Pierre Habouzit2007-09-16
| | | | | | Signed-off-by: Pierre Habouzit <madcoder@debian.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Strbuf API extensions and fixes.Pierre Habouzit2007-09-10
| | | | | | | | | | | | | | | | | | * Add strbuf_rtrim to remove trailing spaces. * Add strbuf_insert to insert data at a given position. * Off-by one fix in strbuf_addf: strbuf_avail() does not counts the final \0 so the overflow test for snprintf is the strict comparison. This is not critical as the growth mechanism chosen will always allocate _more_ memory than asked, so the second test will not fail. It's some kind of miracle though. * Add size extension hints for strbuf_init and strbuf_read. If 0, default applies, else: + initial buffer has the given size for strbuf_init. + first growth checks it has at least this size rather than the default 8192. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Use strbuf API in buitin-rerere.cPierre Habouzit2007-09-06
| | | | | Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make every builtin-*.c file #include "builtin.h"Peter Hagervall2007-07-14
| | | | | | | | | Make every builtin-*.c file #include "builtin.h". Also takes care of some declaration/definition mismatches. Signed-off-by: Peter Hagervall <hager@cs.umu.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere: record resolution even if file is not in merge baseJohannes Schindelin2007-07-09
| | | | | | | | | | | | | | | Two-file merges were rare enough that they were dropped outside of the radar. This fix is a trivial change to builtin-rerere.c::find_conflict(). It is still sane to insist that we do not do rerere for symlinks, and require to have stages #2 and #3, but we can drop the requirement to have stage #1. rerere does not use information from there anyway. This fix is from Junio, together with two tests to verify that it works as expected. Acked-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'jc/diff-mark'Junio C Hamano2007-07-07
|\ | | | | | | | | | | | | | | | | * jc/diff-mark: diff: honor binariness specified in attributes Fix configuration syntax to specify customized hunk header patterns. Per-path attribute based hunk header selection. Future-proof source for changes in xdemitconf_t Introduce diff_filespec_is_binary()
| * Future-proof source for changes in xdemitconf_tJohannes Schindelin2007-07-06
| | | | | | | | | | | | | | | | | | | | | | The instances of xdemitconf_t were initialized member by member. Instead, initialize them to all zero, so we do not have to update those places each time we introduce a new member. [jc: minimally fixed by getting rid of a new global] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Enable "git rerere" by the config variable rerere.enabledJohannes Schindelin2007-07-06
|/ | | | | | | | | | | | | | | | | | | Earlier, "git rerere" was enabled by creating the directory .git/rr-cache. That is definitely not in line with most other features, which are enabled by a config variable. So, check the config variable "rerere.enabled". If it is set to "false" explicitely, do not activate rerere, even if .git/rr-cache exists. This should help when you want to disable rerere temporarily. If "rerere.enabled" is not set at all, fall back to detection of the directory .git/rr-cache. [jc: with minimum tweaks] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* detect close failure on just-written file handlesJim Meyering2007-06-26
| | | | | | | | | | I audited git for potential undetected write failures. In the cases fixed below, the diagnostics I add mimic the diagnostics used in surrounding code, even when that means not reporting the precise strerror(errno) cause of the error. Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* War on whitespaceJunio C Hamano2007-06-07
| | | | | | | | | This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rerere: make sorting really stable.Junio C Hamano2007-04-04
| | | | | | | | The earlier code does not swap hunks when the beginning of the first side is identical to the whole of the second side. In such a case, the first one should sort later. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge 1.5.0.7 inJunio C Hamano2007-04-03
|\ | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
| * rerere should not repeat the earlier hunks in later onesJunio C Hamano2007-04-03
| | | | | | | | | | | | | | When a file has more then one conflicting hunks, it repeated the contents of previous hunks in output for later ones. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'maint'Junio C Hamano2007-02-25
|\ \ | |/ | | | | | | | | | | | | | | * maint: Add Release Notes to prepare for 1.5.0.2 Allow arbitrary number of arguments to git-pack-objects rerere: do not deal with symlinks. rerere: do not skip two conflicted paths next to each other. Don't modify CREDITS-FILE if it hasn't changed.
| * rerere: do not deal with symlinks.Junio C Hamano2007-02-25
| | | | | | | | | | | | | | Who would use multi-line symlinks that would benefit from rerere? Just ignore them. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * rerere: do not skip two conflicted paths next to each other.Junio C Hamano2007-02-25
| | | | | | | | | | | | | | The code forgot to take the for (;;) loop control into account, incrementing the index once too many. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | prefixcmp(): fix-up mechanical conversion.Junio C Hamano2007-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | | Previous step converted use of strncmp() with literal string mechanically even when the result is only used as a boolean: if (!strncmp("foo", arg, 3)) ==> if (!(-prefixcmp(arg, "foo"))) This step manually cleans them up to read: if (!prefixcmp(arg, "foo")) Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Mechanical conversion to use prefixcmp()Junio C Hamano2007-02-20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) This was done by using this script in px.perl #!/usr/bin/perl -i.bak -p if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; } if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; } and running: $ git grep -l strncmp -- '*.c' | xargs perl px.perl Signed-off-by: Junio C Hamano <junkio@cox.net>