summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* cvsserver: Determinize output to combat Perl 5.18 hash randomizationak/cvsserver-stabilize-use-of-hash-keysAnders Kaseorg2013-10-301-5/+5
| | | | | | | | | | | | | | | | | | Perl 5.18 randomizes the seed used by its hash function, so iterating through hashes results in different orders from run to run: http://perldoc.perl.org/perl5180delta.html#Hash-overhaul This usually broke t9400 (gitcvs.dbname, gitcvs.ext.dbname, when running cmp on two .sqlite files) and t9402 (check [cvswork3] diff, when running test_cmp on two diffs). To fix this, hide the internal order of hashes with sort when sending output or running database queries. (An alternative workaround is PERL_HASH_SEED=0, but this seems nicer.) Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cvsserver: pick up the right mode bitsjc/cvsserver-perm-bit-fixJunio C Hamano2013-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | When determining the file mode from either ls-tree or diff-tree output, we used to grab these octal mode string (typically 100644 or 100755) and then did $git_perms .= "r" if ( $mode & 4 ); $git_perms .= "w" if ( $mode & 2 ); $git_perms .= "x" if ( $mode & 1 ); which was already wrong, as (100644 & 4) is very different from oct("100644") & 4. An earlier refactoring 2c3af7e7 (cvsserver: factor out git-log parsing logic, 2012-10-13) further changed it to pick the third octal digit (10*0*644 or 10*0*755) from the left and then do the above conversion, which does not make sense, either. Let's use the third digit from the last of the octal mode string to make sure we get the executable and read bits right. Signed-off-by: Junio C Hamano <gitster@pobox.com> Tested-by: Michael Cronenworth <mike@cchtml.com>
* Merge branch 'mo/cvs-server-updates'Junio C Hamano2013-01-233-317/+2198
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various git-cvsserver updates. * mo/cvs-server-updates: t9402: Use TABs for indentation t9402: Rename check.cvsCount and check.list t9402: Simplify git ls-tree t9402: Add missing &&; Code style t9402: No space after IO-redirection t9402: Dont use test_must_fail cvs t9402: improve check_end_tree() and check_end_full_tree() t9402: sed -i is not portable cvsserver Documentation: new cvs ... -r support cvsserver: add t9402 to test branch and tag refs cvsserver: support -r and sticky tags for most operations cvsserver: Add version awareness to argsfromdir cvsserver: generalize getmeta() to recognize commit refs cvsserver: implement req_Sticky and related utilities cvsserver: add misc commit lookup, file meta data, and file listing functions cvsserver: define a tag name character escape mechanism cvsserver: cleanup extra slashes in filename arguments cvsserver: factor out git-log parsing logic
| * t9402: Use TABs for indentationTorsten Bögershausen2012-12-091-375/+376
| | | | | | | | | | | | | | | | Use TAB's for indentation, and wrap overlong lines. Put the closing ' at the beginning of the line. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: Rename check.cvsCount and check.listTorsten Bögershausen2012-12-091-6/+6
| | | | | | | | | | | | | | | | | | | | | | Checking and comparing the number of line in check.list and check.cvsCount had been replaced by comparing both files line by line. Rename the filenames to make clear which is expected and which is actual: check.list -> list.expected check.cvsCount-> list.actual Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: Simplify git ls-treeTorsten Bögershausen2012-12-091-1/+1
| | | | | | | | | | | | | | Use "git ls-tree --name-only" which does not need a sed to filter out the sha Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: Add missing &&; Code styleTorsten Bögershausen2012-12-091-56/+50
| | | | | | | | | | | | | | | | | | Add missing && at 2 places Re-formated the sub-shell parantheses (coding style) Added missing ] in the test_expect_success header at 2 places Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: No space after IO-redirectionTorsten Bögershausen2012-12-091-30/+30
| | | | | | | | | | | | | | | | Redirection should not have SP before the filename (i.e. ">out", not "> out"). Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: Dont use test_must_fail cvsTorsten Bögershausen2012-12-091-10/+10
| | | | | | | | | | | | | | Replace "test_must_fail cvs" with "! cvs" Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: improve check_end_tree() and check_end_full_tree()Torsten Bögershausen2012-12-091-18/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check_end_tree(): - Instead of counting lines using wc in expectCount and cvsCount: Sort and compare the files byte by byte with test_cmp, which is more exact and easier to debug - Chain all shell comands together using && check_end_full_tree() - Instead of counting lines using wc in expectCount, cvsCount and gitCount: Sort and compare the files byte by byte with test_cmp, which is more exact and easier to debug - Break the test using two conditions anded together with -a into to call to test_cmp - Chain all shell comands together using && Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * t9402: sed -i is not portableTorsten Bögershausen2012-12-091-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | On some systems sed allows the usage of e.g. sed -i -e "s/line1/line2/" afile to edit the file "in place". Other systems don't allow that: one observed behaviour is that sed -i -e "s/line1/line2/" afile creates a backup file called afile-e, which breaks the test. As sed -i is not part of POSIX, avoid it. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver Documentation: new cvs ... -r supportMatthew Ogilvie2012-10-161-0/+37
| | | | | | | | | | Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: add t9402 to test branch and tag refsMatthew Ogilvie2012-10-161-0/+558
| | | | | | | | | | Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: support -r and sticky tags for most operationsMatthew Ogilvie2012-10-161-203/+510
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Split off prepDirForOutput for "update" and "commit". Some low level protocol details were changed to more closely resemble CVS even in non-tagged cases. Hopefully it still works with finicky clients like Eclipse. - Substantial changes to "diff". The output is now closer to standard CVS (including exit status), and can be used as a patch, but there are still a number of differences compared to CVS. - Tweaks to "add", "remove", "status", and "commit". - FUTURE: CVS revision numbers for branches simply encode git commit IDs in a way that resembles CVS revision numbers, dropping all normal CVS structural relations between different revision numbers. - FUTURE: "log" doesn't try to work properly at all with branches and tags. - FUTURE: "annotate" probably doesn't work with branches or tags either (untested)? Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: Add version awareness to argsfromdirMatthew Ogilvie2012-10-161-30/+198
| | | | | | | | | | Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: generalize getmeta() to recognize commit refsMatthew Ogilvie2012-10-161-11/+145
| | | | | | | | | | | | | | | | This allows getmeta() to recognize any commitish (sha1, tag/branch name, etc). Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: implement req_Sticky and related utilitiesMatthew Ogilvie2012-10-161-2/+169
| | | | | | | | | | | | | | Nothing sets sticky yet, or uses the values set by this, but soon... Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: add misc commit lookup, file meta data, and file listing functionsMatthew Ogilvie2012-10-161-1/+365
| | | | | | | | | | | | | | | | | | | | | | | | These will be used soon, but not yet. PERFORMANCE NOTE: getMetaFromCommithash() does not scale well as currently implemented. See comment for possible optimization strategies. Fortunately, it will only be used in cases that would not have worked at all before this change. Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: define a tag name character escape mechanismMatthew Ogilvie2012-10-161-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | CVS tags are officially only allowed to use [-_0-9A-Za-f]. Git refs commonly uses other characters, especially [./]. Such characters need to be escaped from CVS in order to be referenced. This just defines functions to escape/unescape names. The functions are not used yet. Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: cleanup extra slashes in filename argumentsMatthew Ogilvie2012-10-161-0/+28
| | | | | | | | | | Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * cvsserver: factor out git-log parsing logicMatthew Ogilvie2012-10-161-71/+105
| | | | | | | | | | | | | | | | Some field conversion was already duplicated, and more calls will be added soon. Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'jc/makefile-perl-python-path-doc'Junio C Hamano2013-01-231-0/+5
|\ \ | | | | | | | | | | | | * 'jc/makefile-perl-python-path-doc': Makefile: add description on PERL/PYTHON_PATH
| * | Makefile: add description on PERL/PYTHON_PATHJunio C Hamano2013-01-131-0/+5
| | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge git://ozlabs.org/~paulus/gitkJunio C Hamano2013-01-232-365/+504
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * git://ozlabs.org/~paulus/gitk: gitk: Display important heads even when there are many gitk: Improve display of list of nearby tags and heads gitk: Fix display of branch names on some commits gitk: Update Swedish translation (296t) gitk: When searching, only highlight files when in Patch mode gitk: Fix error message when clicking on a connecting line gitk: Fix crash when not using themed widgets gitk: Use bindshiftfunctionkey to bind Shift-F5 gitk: Refactor code for binding modified function keys gitk: Work around empty back and forward images when buttons are disabled gitk: Highlight first search result immediately on incremental search gitk: Highlight current search hit in orange gitk: Synchronize highlighting in file view when scrolling diff
| * | | gitk: Display important heads even when there are manyPaul Mackerras2013-01-021-15/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there are more than $maxrefs descendant heads to display in the Branches field of the commit display, we currently just display "many", which is not very informative. To make the display more informative, we now look for "master" and whichever head is currently checked out, and display them even if there are too many heads to display them all. The display then looks like "Branches: master and many more (33)" for instance. Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Improve display of list of nearby tags and headsPaul Mackerras2013-01-011-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This provides a control in the preferences pane for the limit on how many tags or heads are displayed with the commit details under the Branch(es), Precedes and Follows headings. This limit is now saved in ~/.gitk so that changes are persistent. This also applies word-wrapping to the list of tags or heads under the Branch, Precedes and Follows headings, so that long lists are more readable. Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Fix display of branch names on some commitsPaul Mackerras2013-01-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes the code that divides commits up into arcs creates two successive arcs, but the commit between them (the commit at the end of the first arc and the beginning of the second arc) has only one parent and one child. If that commit is also the head of one or more branches, those branches get omitted from the "Branches" field in the commit display. The omission occurs because the commit gets erroneously identified as a commit which is part-way along an arc in [descheads]. This fixes it by changing the test to look at the arcouts array, which only contains elements for the commits at the start or end of an arc. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Update Swedish translation (296t)Peter Krefting2012-10-221-321/+352
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Peter Krefting <peter@softwolves.pp.se> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: When searching, only highlight files when in Patch modeStefan Haller2012-10-221-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes another regression that was introduced in b967135 ("gitk: Synchronize highlighting in file view when scrolling diff"): when searching for a string in tree mode, jumping to the next search hit would highlight the "Comments" entry in the file list. Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Fix error message when clicking on a connecting lineStefan Haller2012-10-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When clicking on the line that connects two commit nodes, gitk would bring up an error dialog saying "can't read "cflist_top": no such variable". This fixes a regression that was introduced with b967135 ("gitk: Synchronize highlighting in file view when scrolling diff"). Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Fix crash when not using themed widgetsMarcus Karlsson2012-10-221-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When configured not to use themed widgets gitk may crash on launch with a message that says that the image "bm-left disabled bm-left-gray" doesn't exist. This happens when the left and right arrow buttons are created. The crash can be avoided by configuring the buttons differently depending on whether or not themed widgets are used. If themed widgets are not used then only set the images to bm-left and bm-right respectively, and keep the old behavior when themed widgets are used. The previous behaviour was added in f062e50f to work around a bug in Tk on OS X where the disabled state did not display properly. The buttons may still not display correctly, however the workaround added in f062e50f will still apply if gitk is used with themed widgets. Make gitk not crash on launch when not using themed widgets. Signed-off-by: Marcus Karlsson <mk@acc.umu.se> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Use bindshiftfunctionkey to bind Shift-F5Andrew Wong2012-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Refactor code for binding modified function keysAndrew Wong2012-10-221-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function includes a workaround for systems where F* keys are mapped to XF86_Switch_VT_* when modifiers are used. Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Work around empty back and forward images when buttons are disabledStefan Haller2012-09-231-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Mac, the back and forward buttons show an empty rectange instead of a grayed-out arrow when they are disabled. The reason is a Tk bug on Mac that causes disabled images not to draw correctly (not to draw at all, that is); see <https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.tcl/V-nW1JBq0eU>. To work around this, we explicitly provide gray images for the disabled state; I think this looks better than the default stipple effect that you get on Windows as well, but that may be a matter of taste. Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Highlight first search result immediately on incremental searchStefan Haller2012-09-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When typing in the "Search" field, select the current search result (so that it gets highlighted in orange). This makes it easier to understand what will happen if you then type Ctrl-S. Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Highlight current search hit in orangeStefan Haller2012-09-231-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When searching for text in the diff, and there are multiple occurrences of the search string, the current one is highlighted in orange, and the other ones in yellow. This makes it much easier to understand what happens when you then click the Search button or hit Ctrl-S repeatedly. Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
| * | | gitk: Synchronize highlighting in file view when scrolling diffStefan Haller2012-09-231-11/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever the diff pane scrolls, highlight the corresponding file in the file list on the right. For a large commit with many files and long per-file diffs, this makes it easier to keep track of what you're looking at. This allows simplifying the prevfile and nextfile functions, because all they have to do is scroll the diff pane. In some situations we want to suppress this mechanism, for example when clicking on a file in the file list to select it, or when searching in the diff, in which case we want to highlight based on the current search hit and not the top line visible. In these cases it's not sufficient to set a "suppress" flag before scrolling and reset it afterwards, because the scrolltext notification is sent deferred from a timer or some such; so we need to remember the scroll position for which we want to suppress the auto-highlighting until the next call to scrolltext; a bit ugly, but does the job. Signed-off-by: Stefan Haller <stefan@haller-berlin.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
* | | | Merge branch 'jc/merge-blobs'Junio C Hamano2013-01-221-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | * jc/merge-blobs: Makefile: Replace merge-file.h with merge-blobs.h in LIB_H
| * | | | Makefile: Replace merge-file.h with merge-blobs.h in LIB_HRamsay Jones2013-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit fa2364ec ("Which merge_file() function do you mean?", 06-12-2012) renamed the files merge-file.[ch] to merge-blobs.[ch], but forgot to rename the header file in the definition of the LIB_H macro. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Update draft release notes to 1.8.2Junio C Hamano2013-01-221-2/+37
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Merge branch 'mz/reset-misc'Junio C Hamano2013-01-225-171/+214
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various 'reset' optimizations and clean-ups, followed by a change to allow "git reset" to work even on an unborn branch. * mz/reset-misc: reset: update documentation to require only tree-ish with paths reset [--mixed]: use diff-based reset whether or not pathspec was given reset: allow reset on unborn branch reset $sha1 $pathspec: require $sha1 only to be treeish reset.c: inline update_index_refresh() reset.c: finish entire cmd_reset() whether or not pathspec is given reset [--mixed]: only write index file once reset.c: move lock, write and commit out of update_index_refresh() reset.c: move update_index_refresh() call out of read_from_tree() reset.c: replace switch by if-else reset: avoid redundant error message reset --keep: only write index file once reset.c: share call to die_if_unmerged_cache() reset.c: extract function for updating {ORIG_,}HEAD reset.c: remove unnecessary variable 'i' reset.c: extract function for parsing arguments reset: don't allow "git reset -- $pathspec" in bare repo reset.c: pass pathspec around instead of (prefix, argv) pair reset $pathspec: exit with code 0 if successful reset $pathspec: no need to discard index
| * | | | | reset: update documentation to require only tree-ish with pathsMartin von Zweigbergk2013-01-162-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When resetting with paths, we no longer require a commit argument, but only a tree-ish. Update the documentation and synopsis accordingly. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset [--mixed]: use diff-based reset whether or not pathspec was givenMartin von Zweigbergk2013-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Thanks to b65982b (Optimize "diff-index --cached" using cache-tree, 2009-05-20), resetting with paths is much faster than resetting without paths. Some timings for the linux-2.6 repo to illustrate this (best of five, warm cache): reset reset . real 0m0.219s 0m0.080s user 0m0.140s 0m0.040s sys 0m0.070s 0m0.030s These two commands should do the same thing, so instead of having the user type the trailing " ." to get the faster do_diff_cache()-based implementation, always use it when doing a mixed reset, with or without paths (so "git reset $rev" would also be faster). Timing "git reset" shows that it indeed becomes as fast as "git reset ." after this patch. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset: allow reset on unborn branchMartin von Zweigbergk2013-01-152-6/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some users seem to think, knowingly or not, that being on an unborn branch is like having a commit with an empty tree checked out, but when run on an unborn branch, "git reset" currently fails with: fatal: Failed to resolve 'HEAD' as a valid ref. Instead of making users figure out that they should run git rm --cached -r . , let's teach "git reset" without a revision argument, when on an unborn branch, to behave as if the user asked to reset to an empty tree. Don't take the analogy with an empty commit too far, though, but still disallow explictly referring to HEAD in "git reset HEAD". Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset $sha1 $pathspec: require $sha1 only to be treeishMartin von Zweigbergk2013-01-152-21/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resetting with paths does not update HEAD and there is nothing else that a commit should be needed for. Relax the argument parsing so only a tree is required. The sha1 is only passed to read_from_tree(), which already only requires a tree. The "rev" variable we pass to run_add_interactive() will resolve to a tree. This is fine since interactive_reset only needs the parameter to be a treeish and doesn't use it for display purposes. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset.c: inline update_index_refresh()Martin von Zweigbergk2013-01-151-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that there is only one caller left to the single-line method update_index_refresh(), inline it. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset.c: finish entire cmd_reset() whether or not pathspec is givenMartin von Zweigbergk2013-01-151-24/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By not returning from inside the "if (pathspec)" block, we can let the pathspec-aware and pathspec-less code share a bit more, making it easier to make future changes that should affect both cases. This also highlights the similarity between read_from_tree() and reset_index(). Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset [--mixed]: only write index file onceMartin von Zweigbergk2013-01-151-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When doing a mixed reset without paths, the index is locked, read, reset, and written back as part of the actual reset operation (in reset_index()). Then, when showing the list of worktree modifications, we lock the index again, refresh it, and write it. Change this so we only write the index once, making "git reset" a little faster. It does mean that the index lock will be held a little longer, but the difference is small compared to the time spent refreshing the index. There is one minor functional difference: We used to say "Could not write new index file." if the first write failed, and "Could not refresh index" if the second write failed. Now, we will only use the first message. This speeds up "git reset" a little on the linux-2.6 repo (best of five, warm cache): Before After real 0m0.239s 0m0.214s user 0m0.160s 0m0.130s sys 0m0.070s 0m0.080s Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset.c: move lock, write and commit out of update_index_refresh()Martin von Zweigbergk2013-01-151-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for the/a following patch, move the locking, writing and committing of the index file out of update_index_refresh(). The code duplication caused will soon be taken care of. What remains of update_index_refresh() is just one line, but it is still called from two places, so let's leave it for now. In the process, we expose and fix the minor UI bug that makes us print "Could not refresh index" when we fail to write the index file when invoked with a pathspec. Copy the error message from the pathspec-less codepath ("Could not write new index file."). Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | | reset.c: move update_index_refresh() call out of read_from_tree()Martin von Zweigbergk2013-01-151-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The final part of cmd_reset() essentially looks like: if (pathspec) { ... read_from_tree(...); } else { ... reset_index(...); update_index_refresh(...); ... } where read_from_tree() internally also calls update_index_refresh(). Move the call to update_index_refresh() out of read_from_tree for symmetry with the 'else' block, making read_from_tree() and reset_index() closer in functionality. Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>