1
0
mirror of https://github.com/git/git.git synced 2024-10-20 09:59:05 +02:00
Commit Graph

5239 Commits

Author SHA1 Message Date
Junio C Hamano
be0dca39e9 Merge branch 'maint'
* maint:
  t3701: fix here document
  git-fast-import.txt: --relative-marks takes no parameter
  shell: add missing initialization of argv0_path
2011-05-05 14:43:45 -07:00
Junio C Hamano
8fe6177ac6 t3701: fix here document
A broken here-document was not caught because end of file is taken by
an implicit end of the here document (POSIX does not seem to say it is
an error to lack the delimiter), and everything in the test just turned
into a single "cat into a file".

Noticed-by: Kacper Kornet <draenog@pld-linux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-05 11:28:52 -07:00
Brian Gernhardt
c01bd5a29f t/annotate-tests: Use echo & cat instead of sed
The use of the sed command "1i No robots allowed" caused the version
of sed in OS X to die with

   sed: 1: "1i "No robots allowed"\n": command i expects \ followed by
   text

Since this command was just trying to add a single line to the
beginning of the file, do the same with "echo" followed by "cat".

Unbreaks t8001 and t8002 on OS X 10.6.7

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-05 09:24:21 -07:00
Junio C Hamano
34d87985d5 Merge branch 'ml/test-readme'
* ml/test-readme:
  t/README: unify documentation of test function args
2011-05-04 15:52:00 -07:00
Junio C Hamano
117374fe3c Merge branch 'mg/rev-list-count-cherry'
* mg/rev-list-count-cherry:
  rev-list --count: separate count for --cherry-mark
2011-05-04 15:51:53 -07:00
Junio C Hamano
5ead6a6fdb Merge branch 'jk/format-patch-multiline-header'
* jk/format-patch-multiline-header:
  format-patch: wrap email addresses after long names
2011-05-04 15:51:27 -07:00
Junio C Hamano
59b2389c32 Merge branch 'jm/mergetool-submodules'
* jm/mergetool-submodules:
  mergetool: Teach about submodules
2011-05-04 15:51:23 -07:00
Junio C Hamano
f5bf1b5f6b Merge branch 'jh/dirstat' into maint
* jh/dirstat:
  --dirstat: In case of renames, use target filename instead of source filename
  Teach --dirstat not to completely ignore rearranged lines within a file
  --dirstat-by-file: Make it faster and more correct
  --dirstat: Describe non-obvious differences relative to --stat or regular diff
2011-05-04 14:59:07 -07:00
Junio C Hamano
be44a20aa8 Merge branch 'jk/maint-stash-oob' into maint
* jk/maint-stash-oob:
  stash: fix false positive in the invalid ref test.
  stash: fix accidental apply of non-existent stashes

Conflicts:
	t/t3903-stash.sh
2011-05-04 14:58:42 -07:00
Junio C Hamano
e9f1878da7 Merge branch 'dm/stash-k-i-p' into maint
* dm/stash-k-i-p:
  stash: ensure --no-keep-index and --patch can be used in any order
  stash: add two more tests for --no-keep-index
2011-05-04 14:57:49 -07:00
Junio C Hamano
f6bfe76714 Merge branch 'mg/reflog-with-options' into maint
* mg/reflog-with-options:
  reflog: fix overriding of command line options
  t/t1411: test reflog with formats
  builtin/log.c: separate default and setup of cmd_log_init()
2011-05-04 14:57:33 -07:00
Junio C Hamano
0752000c2a Merge branch 'jk/stash-loosen-safety' into maint
* jk/stash-loosen-safety:
  stash: drop dirty worktree check on apply
2011-05-04 14:57:15 -07:00
Junio C Hamano
391b493344 Merge branch 'ar/clean-rmdir-empty' into maint
* ar/clean-rmdir-empty:
  clean: unreadable directory may still be rmdir-able if it is empty
2011-05-04 14:57:06 -07:00
Junio C Hamano
a3402c18b6 Merge branch 'mg/sha1-path-advise' into maint
* mg/sha1-path-advise:
  sha1_name: Suggest commit:./file for path in subdir
  t1506: factor out test for "Did you mean..."
2011-05-04 14:56:51 -07:00
Tay Ray Chuan
0cc6330d0c t5541-http-push: add test for chunked
Trigger the chunked type of pushing for smart HTTP. This can serve as a
regression test for the issue fixed in 1e41827 (http: clear POSTFIELDS
when initializing a slot).

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-04 13:30:37 -07:00
Junio C Hamano
23f536cf62 Merge branch 'jk/notes-ui-updates'
* jk/notes-ui-updates:
  contrib/completion: --notes, --no-notes
  log/pretty-options: Document --[no-]notes and deprecate old notes options
  revision.c: make --no-notes reset --notes list
  revision.c: support --notes command-line option
  notes: refactor display notes default handling
  notes: refactor display notes extra refs field
  revision.c: refactor notes ref expansion
  notes: make expand_notes_ref globally accessible
2011-05-02 15:58:50 -07:00
Junio C Hamano
a75c3523d3 Merge branch 'ab/i18n-fixup'
* ab/i18n-fixup: (24 commits)
  i18n: use test_i18n{cmp,grep} in t7600, t7607, t7611 and t7811
  i18n: use test_i18n{grep,cmp} in t7508
  i18n: use test_i18ngrep in t7506
  i18n: use test_i18ngrep and test_i18ncmp in t7502
  i18n: use test_i18ngrep in t7501
  i18n: use test_i18ncmp in t7500
  i18n: use test_i18ngrep in t7201
  i18n: use test_i18ncmp and test_i18ngrep in t7102 and t7110
  i18n: use test_i18ncmp and test_i18ngrep in t5541, t6040, t6120, t7004, t7012 and t7060
  i18n: use test_i18ncmp and test_i18ngrep in t3700, t4001 and t4014
  i18n: use test_i18ncmp and test_i18ngrep in t3203, t3501 and t3507
  i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200
  i18n: use test_i18ngrep in lib-httpd and t2019
  i18n: do not overuse C_LOCALE_OUTPUT (grep)
  i18n: use test_i18ncmp in t1200 and t2200
  i18n: .git file is not a human readable message (t5601)
  i18n: do not overuse C_LOCALE_OUTPUT
  i18n: mark init-db messages for translation
  i18n: mark checkout plural warning for translation
  i18n: mark checkout --detach messages for translation
  ...
2011-05-02 15:58:40 -07:00
Junio C Hamano
0d405d72f5 Merge branch 'nm/submodule-update-force'
* nm/submodule-update-force:
  submodule: Add --force option for git submodule update

Conflicts:
	t/t7406-submodule-update.sh
2011-05-02 15:58:36 -07:00
Junio C Hamano
2d23c64ba2 Merge branch 'jh/notes-add-ui'
* jh/notes-add-ui:
  Make "git notes add" more user-friendly when there are existing notes

Conflicts:
	builtin/notes.c
2011-05-02 15:58:32 -07:00
Junio C Hamano
2db8926236 Merge branch 'mz/maint-rename-unmerged'
* mz/maint-rename-unmerged:
  diffcore-rename: don't consider unmerged path as source
2011-05-02 15:58:27 -07:00
Jeff King
6aaeca900b merge-one-file: fix broken merges with alternate work trees
The merge-one-file tool predates the invention of
GIT_WORK_TREE. By the time GIT_WORK_TREE was invented, most
people were using the merge-recursive strategy, which
handles resolving internally. Therefore these features have
had very little testing together.

For the most part, merge-one-file just works with
GIT_WORK_TREE; most of its heavy lifting is done by plumbing
commands which do respect GIT_WORK_TREE properly. The one
exception is a shell redirection which touches the worktree
directly, writing results to the wrong place in the presence
of a GIT_WORK_TREE variable.

This means that merges won't even fail; they will silently
produce incorrect results, throwing out the entire "theirs"
side of files which need content-level merging!

This patch makes merge-one-file chdir to the toplevel of the
working tree (and exit if we don't have one). This most
closely matches the assumption made by the original script
(before separate work trees were invented), and matches what
happens when the script is called as part of a merge
strategy.

While we're at it, we'll also error-check the call to cat.
Merging a file in a subdirectory could in fact fail, as the
redirection relies on the "checkout-index" call just prior
to create leading directories. But we never noticed, since
we ignored the error return from running cat.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 15:37:43 -07:00
Jeff King
cf1af1b1f3 add tests for merge-index / merge-one-file
There were no tests for either, except a brief use in
t1200-tutorial.

These tools are not used much these days, as most people
use the merge-recursive strategy, which handles everything
internally. However, they are used by the "octopus" and
"resolve" strategies, as well as any custom strategies
or merge scripts people have built around them.

For example, together with read-tree, they are the simplest
way to do a basic content-level merge without checking out
the entire repository contents beforehand.

This script adds a basic test of the tools to perform one
content-level merge. It also shows a failure of the tools to
work properly in the face of GIT_WORK_TREE or core.worktree.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 15:37:08 -07:00
Junio C Hamano
f3217e2b17 t3701: Editing a split hunk in an "add -p" session
Arnaud Lacombe reported that with the recent change to reject overlapping
hunks fed to "git apply", the edit mode of an "add -p" session that lazily
feeds overlapping hunks without coalescing adjacent ones claim that the
patch does not apply.  Expose the problem to be fixed.

Cf. http://thread.gmane.org/gmane.comp.version-control.git/170685/focus=171000

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 15:26:41 -07:00
Jakub Narebski
12b1443c2c gitweb: Restructure projects list generation
Extract filtering out forks (which is done if 'forks' feature is
enabled) into filter_forks_from_projects_list subroutine, and
searching projects (via projects search form, or via content tags)
into search_projects_list subroutine.

Both are now run _before_ displaying projects, and not while printing;
this allow to know upfront if there were any found projects.  Gitweb
now can and do print 'No such projects found' if user searches for
phrase which does not correspond to any project (any repository).
This also would allow splitting projects list into pages, if we so
desire.

Filtering out forks and marking repository (project) as having forks
is now consolidated into one subroutine (special case of handling
forks in git_get_projects_list only for $projects_list being file is
now removed).  Forks handling is also cleaned up and simplified.
$pr->{'forks'} now contains un-filled list of forks; we can now also
detect situation where the way for having forks is prepared, but there
are no forks yet.

Sorting projects got also refactored in a very straight way (just
moving code) into sort_projects_list subroutine.

The interaction between forks, content tags and searching is now made
more explicit: searching whether by tag, or via search form turns off
fork filtering (gitweb searches also forks, and will show all
results).  If 'ctags' feature is disabled, then searching by tag is
too.

The t9500 test now includes some basic test for 'forks' and 'ctags'
features; the t9502 includes test checking if gitweb correctly filters
out forks.

Generating list of projects by scanning given directory is now also a
bit simplified wrt. handling filtering; it is byproduct of extracting
filtering forks to separate subroutine.

While at it we now detect that there are no projects and respond with
"404 No projects found" also for 'project_index' and 'opml' actions.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 14:21:48 -07:00
Junio C Hamano
04a67dc622 Merge branch 'mg/x-years-12-months' into maint
* mg/x-years-12-months:
  date: avoid "X years, 12 months" in relative dates
2011-04-29 11:43:18 -07:00
Johan Herland
7478ac57c4 Mark dirstat error messages for translation
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:22:56 -07:00
Johan Herland
51670fc87e Improve error handling when parsing dirstat parameters
When encountering errors or unknown tokens while parsing parameters to the
--dirstat option, it makes sense to die() with an error message informing
the user of which parameter did not make sense. However, when parsing the
diff.dirstat config variable, we cannot simply die(), but should instead
(after warning the user) ignore the erroneous or unrecognized parameter.
After all, future Git versions might add more dirstat parameters, and
using two different Git versions on the same repo should not cripple the
older Git version just because of a parameter that is only understood by
a more recent Git version.

This patch fixes the issue by refactoring the dirstat parameter parsing
so that parse_dirstat_params() keeps on parsing parameters, even if an
earlier parameter was not recognized. When parsing has finished, it returns
zero if all parameters were successfully parsed, and non-zero if one or
more parameters were not recognized (with appropriate error messages
appended to the 'errmsg' argument).

The parse_dirstat_params() callers then decide (based on the return value
from parse_dirstat_params()) whether to warn and ignore (in case of
diff.dirstat), or to warn and die (in case of --dirstat).

The patch also adds a couple of tests verifying the correct behavior of
--dirstat and diff.dirstat in the face of unknown (possibly future) dirstat
parameters.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:22:56 -07:00
Johan Herland
1c57a627bf New --dirstat=lines mode, doing dirstat analysis based on diffstat
This patch adds an alternative implementation of show_dirstat(), called
show_dirstat_by_line(), which uses the more expensive diffstat analysis
(as opposed to show_dirstat()'s own (relatively inexpensive) analysis)
to derive the numbers from which the --dirstat output is computed.

The alternative implementation is controlled by the new "lines" parameter
to the --dirstat option (or the diff.dirstat config variable).

For binary files, the diffstat analysis counts bytes instead of lines,
so to prevent binary files from dominating the dirstat results, the
byte counts for binary files are divided by 64 before being compared to
their textual/line-based counterparts. This is a stupid and ugly - but
very cheap - heuristic.

In linux-2.6.git, running the three different --dirstat modes:

  time git diff v2.6.20..v2.6.30 --dirstat=changes > /dev/null
vs.
  time git diff v2.6.20..v2.6.30 --dirstat=lines > /dev/null
vs.
  time git diff v2.6.20..v2.6.30 --dirstat=files > /dev/null

yields the following average runtimes on my machine:

 - "changes" (default): ~6.0 s
 - "lines":             ~9.6 s
 - "files":             ~0.1 s

So, as expected, there's a considerable performance hit (~60%) by going
through the full diffstat analysis as compared to the default "changes"
analysis (obviously, "files" is much faster than both). As such, the
"lines" mode is probably only useful if you really need the --dirstat
numbers to be consistent with the numbers returned from the other
--*stat options.

The patch also includes documentation and tests for the new dirstat mode.

Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:22:55 -07:00
Johan Herland
712d2c7dd8 Allow specifying --dirstat cut-off percentage as a floating point number
Only the first digit after the decimal point is kept, as the dirstat
calculations all happen in permille.

Selftests verifying floating-point percentage input has been added.

Improved-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:20:11 -07:00
Johan Herland
2d17495196 Add config variable for specifying default --dirstat behavior
The new diff.dirstat config variable takes the same arguments as
'--dirstat=<args>', and specifies the default arguments for --dirstat.
The config is obviously overridden by --dirstat arguments passed on the
command line.

When not specified, the --dirstat defaults are 'changes,noncumulative,3'.

The patch also adds several tests verifying the interaction between the
diff.dirstat config variable, and the --dirstat command line option.

Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:20:03 -07:00
Johan Herland
333f3fb0c5 Refactor --dirstat parsing; deprecate --cumulative and --dirstat-by-file
Instead of having multiple interconnected dirstat-related options, teach
the --dirstat option itself to accept all behavior modifiers as parameters.

 - Preserve the current --dirstat=<limit> (where <limit> is an integer
   specifying a cut-off percentage)
 - Add --dirstat=cumulative, replacing --cumulative
 - Add --dirstat=files, replacing --dirstat-by-file
 - Also add --dirstat=changes and --dirstat=noncumulative for specifying the
   current default behavior. These allow the user to reset other --dirstat
   parameters (e.g. 'cumulative' and 'files') occuring earlier on the
   command line.

The deprecated options (--cumulative and --dirstat-by-file) are still
functional, although they have been removed from the documentation.

Allow multiple parameters to be separated by commas, e.g.:
  --dirstat=files,10,cumulative

Update the documentation accordingly, and add testcases verifying the
behavior of the new syntax.

Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:17:36 -07:00
Johan Herland
58a8756a98 Make --dirstat=0 output directories that contribute < 0.1% of changes
The expected output from --dirstat=0, is to include any directory with
changes, even if those changes contribute a minuscule portion of the total
changes. However, currently, directories that contribute less than 0.1% are
not included, since their 'permille' value is 0, and there is an
'if (permille)' check in gather_dirstat() that causes them to be ignored.

This test is obviously intended to exclude directories that contribute no
changes whatsoever, but in this case, it hits too broadly. The correct
check is against 'this_dir' from which the permille is calculated. Only if
this value is 0 does the directory truly contribute no changes, and should
be skipped from the output.

This patches fixes this issue, and updates corresponding testcases to
expect the new behvaior.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:17:36 -07:00
Johan Herland
5502039d87 Add several testcases for --dirstat and friends
Currently, t4013 is the only selftest that exercises the --dirstat machinery,
but it only does a superficial verification of --dirstat's output.

This patch adds a new selftest - t4047-diff-dirstat.sh - which prepares a
commit containing:
 - unchanged files, changed files and files with rearranged lines
 - copied files, moved files, and unmoved files

It then verifies the correct dirstat output for that commit in the following
dirstat modes:
 - --dirstat
 - -X
 - --dirstat=0
 - -X0
 - --cumulative
 - --dirstat-by-file
 - (plus combinations of the above)

Each of the above tests are also run with:
 - no rename detection
 - rename detection (-M)
 - expensive copy detection (-C -C)

Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:17:36 -07:00
Josh Stone
9b01f0038b blame: tolerate bogus e-mail addresses a bit better
The names and e-mails are sanitized by fmt_ident() when creating commits,
so that they do not contain "<" nor ">", and the "committer" and "author"
lines in the commit object will always be in the form:

    ("author" | "committer") name SP "<" email ">" SP timestamp SP zone

When parsing the email part out, the current code looks for SP starting
from the end of the email part, but the author could obfuscate the address
as "author at example dot com".

We should instead look for SP followed by "<", to match the logic of the
side that formats these lines.

Signed-off-by: Josh Stone <jistone@redhat.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 11:09:42 -07:00
Mathias Lafeldt
c54e6be75a t/test-lib.sh: minor readability improvements
Apply parameter expansion. Also use here document to save
test results instead of appending each line with ">>".

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-29 08:27:52 -07:00
Junio C Hamano
50d3062ab2 Merge branch 'jc/diff-irreversible-delete'
* jc/diff-irreversible-delete:
  git diff -D: omit the preimage of deletes
2011-04-28 14:11:47 -07:00
Junio C Hamano
76a89d6d82 Merge branch 'jc/rename-degrade-cc-to-c'
* jc/rename-degrade-cc-to-c:
  diffcore-rename: fall back to -C when -C -C busts the rename limit
  diffcore-rename: record filepair for rename src
  diffcore-rename: refactor "too many candidates" logic
  builtin/diff.c: remove duplicated call to diff_result_code()
2011-04-28 14:11:43 -07:00
Junio C Hamano
78c6e0f3fa Merge branch 'mz/rebase'
* mz/rebase: (34 commits)
  rebase: define options in OPTIONS_SPEC
  Makefile: do not install sourced rebase scripts
  rebase: use @{upstream} if no upstream specified
  rebase -i: remove unnecessary state rebase-root
  rebase -i: don't read unused variable preserve_merges
  git-rebase--am: remove unnecessary --3way option
  rebase -m: don't print exit code 2 when merge fails
  rebase -m: remember allow_rerere_autoupdate option
  rebase: remember strategy and strategy options
  rebase: remember verbose option
  rebase: extract code for writing basic state
  rebase: factor out sub command handling
  rebase: make -v a tiny bit more verbose
  rebase -i: align variable names
  rebase: show consistent conflict resolution hint
  rebase: extract am code to new source file
  rebase: extract merge code to new source file
  rebase: remove $branch as synonym for $orig_head
  rebase -i: support --stat
  rebase: factor out call to pre-rebase hook
  ...
2011-04-28 14:11:39 -07:00
Junio C Hamano
ac9666f84a Merge branch 'en/merge-recursive'
* en/merge-recursive:
  merge-recursive: tweak magic band-aid
  merge-recursive: When we detect we can skip an update, actually skip it
  t6022: New test checking for unnecessary updates of files in D/F conflicts
  t6022: New test checking for unnecessary updates of renamed+modified files
2011-04-28 14:11:35 -07:00
Junio C Hamano
d98a509ec3 Merge branch 'jh/dirstat'
* jh/dirstat:
  --dirstat: In case of renames, use target filename instead of source filename
  Teach --dirstat not to completely ignore rearranged lines within a file
  --dirstat-by-file: Make it faster and more correct
  --dirstat: Describe non-obvious differences relative to --stat or regular diff
2011-04-28 14:11:19 -07:00
Andrew Wong
c192f9c865 git-rebase--interactive.sh: preserve-merges fails on merges created with no-ff
'git rebase' uses 'git merge' to preserve merges (-p).  This preserves
the original merge commit correctly, except when the original merge
commit was created by 'git merge --no-ff'.  In this case, 'git rebase'
will fail to preserve the merge, because during 'git rebase', 'git
merge' will simply fast-forward and skip the commit.  For example:

               B
              / \
             A---M
            /
    ---o---O---P---Q

If we try to rebase M onto P, we lose the merge commit and this happens:

                 A---B
                /
    ---o---O---P---Q

To correct this, we simply do a "no fast-forward" on all merge commits
when rebasing.  Since by the time we decided to do a 'git merge' inside
'git rebase', it means there was a merge originally, so 'git merge'
should always create a merge commit regardless of what the merge
branches look like. This way, when rebase M onto P from the above
example, we get:

                   B
                  / \
                 A---M
                /
    ---o---O---P---Q

Signed-off-by: Andrew Wong <andrew.kw.w@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-28 09:56:55 -07:00
Junio C Hamano
9f5df6fa67 Merge branch 'mg/x-years-12-months'
* mg/x-years-12-months:
  date: avoid "X years, 12 months" in relative dates
2011-04-27 11:36:43 -07:00
Junio C Hamano
c5a5f12e5a Merge branch 'ef/maint-strbuf-init'
* ef/maint-strbuf-init:
  config: support values longer than 1023 bytes
  strbuf: make sure buffer is zero-terminated
2011-04-27 11:36:43 -07:00
Junio C Hamano
65bc83d704 Merge branch 'dm/stash-k-i-p'
* dm/stash-k-i-p:
  stash: ensure --no-keep-index and --patch can be used in any order
  stash: add two more tests for --no-keep-index
2011-04-27 11:36:42 -07:00
Junio C Hamano
fcbf164fcb Merge branch 'jk/maint-stash-oob'
* jk/maint-stash-oob:
  stash: fix false positive in the invalid ref test.
  stash: fix accidental apply of non-existent stashes

Conflicts:
	t/t3903-stash.sh
2011-04-27 11:36:42 -07:00
Junio C Hamano
6213ccaac9 Merge branch 'jk/stash-loosen-safety'
* jk/stash-loosen-safety:
  stash: drop dirty worktree check on apply
2011-04-27 11:36:41 -07:00
Junio C Hamano
698a9ab3f1 Merge branch 'mh/git-svn-automkdirs'
* mh/git-svn-automkdirs:
  git-svn: add an option to skip the creation of empty directories
2011-04-27 11:36:41 -07:00
Junio C Hamano
95fd6e21f1 Merge branch 'mg/reflog-with-options'
* mg/reflog-with-options:
  reflog: fix overriding of command line options
  t/t1411: test reflog with formats
  builtin/log.c: separate default and setup of cmd_log_init()
2011-04-27 11:36:41 -07:00
Junio C Hamano
1de0746d84 Merge branch 'ar/clean-rmdir-empty'
* ar/clean-rmdir-empty:
  clean: unreadable directory may still be rmdir-able if it is empty
2011-04-27 11:36:41 -07:00
Junio C Hamano
385185403e Merge branch 'mg/sha1-path-advise'
* mg/sha1-path-advise:
  sha1_name: Suggest commit:./file for path in subdir
  t1506: factor out test for "Did you mean..."
2011-04-27 11:36:40 -07:00
Michael J Gruber
7cf16a14f5 handle_alias: provide GIT_PREFIX to !alias
Provide an environment variable GIT_PREFIX which contains the subdirectory
from which a !alias was called (i.e. 'git rev-parse --show-prefix') since
these cd to the to level directory before they are executed.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-27 10:50:05 -07:00
Michael J Gruber
0daed41791 t1020: test !alias in subdirectory
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-27 10:49:59 -07:00
Jeff King
4d03c18a3e pretty: quote rfc822 specials in email addresses
If somebody has a name that includes an rfc822 special, we
will output it literally in the "From:" header. This is
usually OK, but certain characters (like ".") are supposed
to be enclosed in double-quotes in a mail header.

In practice, whether this matters may depend on your MUA.
Some MUAs will happily take in:

   From: Foo B. Bar <author@example.com>

without quotes, and properly quote the "." when they send
the actual mail.  Others may not, or may screw up harder
things like:

  From: Foo "The Baz" Bar <author@example.com>

For example, mutt will strip the quotes, thinking they are
actual syntactic rfc822 quotes.

So let's quote properly, and then (if necessary) we still
apply rfc2047 encoding on top of that, which should make all
MUAs happy.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-26 15:07:02 -07:00
Michael J Gruber
b388e14b89 rev-list --count: separate count for --cherry-mark
When --count is used with --cherry-mark, omit the patch equivalent
commits from the count for left and right commits and print the count of
equivalent commits separately.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-26 13:13:20 -07:00
Mathias Lafeldt
72942a617c t/README: unify documentation of test function args
Document all test function arguments in the same way.

While at it, tweak the description of test_path_is_* (thanks to Junio),
and correct some grammatical errors.

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-26 11:45:56 -07:00
Junio C Hamano
75973b2cb5 Fix "add -u" that sometimes fails to resolve unmerged paths
"git add -u" updates the index with the updated contents from the working
tree by internally running "diff-files" to grab the set of paths that are
different from the index. Then it updates the index entries for the paths
that are modified in the working tree, and deletes the index entries for
the paths that are deleted in the working tree.

It ignored the output from the diff-files that indicated that a path is
unmerged.  For these paths, it instead relied on the fact that an unmerged
path is followed by the result of comparison between stage #2 (ours) and
the working tree, and used that to update or delete such a path when it is
used to record the resolution of a conflict.

As the result, when a path did not have stage #2 (e.g. "we deleted while
the other side added"), these unmerged stages were left behind, instead of
recording what the user resolved in the working tree.

Since we recently fixed "diff-files" to indicate if the corresponding path
exists on the working tree for an unmerged path, we do not have to rely on
the comparison with stage #2 anymore. We can instead tell the diff-files
not to compare with higher stages, and use the unmerged output to update
the index to reflect the state of the working tree.

The changes to the test vector in t2200 illustrates the nature of the bug
and the fix.  The test expected stage #1 and #3 entries be left behind,
but it was codifying the buggy behaviour.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-23 23:13:28 -07:00
Junio C Hamano
095ce9538b diff-files: show unmerged entries correctly
Earlier, e9c8409 (diff-index --cached --raw: show tree entry on the LHS
for unmerged entries., 2007-01-05) taught the command to show the object
name and the mode from the entry coming from the tree side when comparing
a tree with an unmerged index.

This is a belated companion patch that teaches diff-files to show the mode
from the entry coming from the working tree side, when comparing an
unmerged index and the working tree.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-23 22:35:13 -07:00
Junio C Hamano
3749fde561 test: use $_z40 from test-lib
There is no need to duplicate the definition of $_z40 and $_x40 that
test-lib.sh supplies the test scripts.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-23 22:34:43 -07:00
Jonathan Nieder
0fc63ec4e7 revisions: allow --glob and friends in parse_options-enabled commands
As v1.6.0-rc2~42 (2008-07-31) explains, even pseudo-options like --not
and --glob that need to be parsed in order with revisions should be
marked handled by handle_revision_opt to avoid an error when
parse_revision_opt callers like "git shortlog" encounter them.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-21 10:56:39 -07:00
Michael J Gruber
f1e9c548ce date: avoid "X years, 12 months" in relative dates
When relative dates are more than about a year ago, we start
writing them as "Y years, M months".  At the point where we
calculate Y and M, we have the time delta specified as a
number of days. We calculate these integers as:

  Y = days / 365
  M = (days % 365 + 15) / 30

This rounds days in the latter half of a month up to the
nearest month, so that day 16 is "1 month" (or day 381 is "1
year, 1 month").

We don't round the year at all, though, meaning we can end
up with "1 year, 12 months", which is silly; it should just
be "2 years".

Implement this differently with months of size

  onemonth = 365/12

so that

  totalmonths = (long)( (days + onemonth/2)/onemonth )
  years = totalmonths / 12
  months = totalmonths % 12

In order to do this without floats, we write the first formula as

  totalmonths = (days*12*2 + 365) / (365*2)

Tests and inspiration by Jeff King.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-20 19:23:16 -07:00
Jonathan Nieder
c0f19bf3b9 tests: check error message from run_command
In git versions starting at v1.7.5-rc0~29^2 until v1.7.5-rc3~2 (Revert
"run-command: prettify -D_FORTIFY_SOURCE workaround", 2011-04-18)
fixed it, the run_command facility would write a truncated error
message when the command is present but cannot be executed for some
other reason.  For example, if I add a 'hello' command to git:

	$ echo 'echo hello' >git-hello
	$ chmod +x git-hello
	$ PATH=.:$PATH git hello
	hello

and make it non-executable, this is what I normally get:

	$ chmod -x git-hello
	$ git hello
	fatal: cannot exec 'git-hello': Permission denied

But with the problematic versions, we get disturbing output:

	$ PATH=.:$PATH git hello
	fatal: $

Add some tests to make sure it doesn't happen again.

The hello-script used in these tests uses cat instead of echo because
on Windows the bash spawned by git converts LF to CRLF in text written
by echo while the bash running tests does not, causing the test to
fail if "echo" is used.  Thanks to Hannes for noticing.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Improved-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-20 10:08:54 -07:00
Jeff King
990f6e30eb format-patch: wrap email addresses after long names
We already wrap names in "from" headers, which tend to be
the long part of an address. But it's also possible for a
long name to not be wrapped, but to make us want to wrap the
email address. For example (imagine for the sake of
readability we want to wrap at 50 characters instead of 78):

  From: this is my really long git name <foo@example.com>

The name does not overflow the line, but the name and email
together do. So we would rather see:

  From: this is my really long git name
    <git@example.com>

Because we wrap the name separately during add_rfc2047, we
neglected this case. Instead, we should see how long the
final line of the wrapped name ended up, and decide whether
or not to wrap based on that. We can't break the address
into multiple parts, so we either leave it with the name, or
put it by itself on a line.

Test by Erik Faye-Lund.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-14 15:42:04 -07:00
Junio C Hamano
c9ea118e75 i18n: use test_i18n{cmp,grep} in t7600, t7607, t7611 and t7811
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-14 14:36:14 -07:00
Junio C Hamano
cc6658e7b4 i18n: use test_i18n{grep,cmp} in t7508
Two tests looked for "[Uu]sage" in the output, but we cannot expect the
l10n to use that phrase.  Mark them with test_i18ngrep so that in later
versions we can test truly localized versions with the same tests, not
just GETTEXT_POISON that happens to keep the original string in the
output.

Merge a few tests that were artificially split into "do" and "test output
under C_LOCALE_OUTPUT" in the original i18n patches back.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-14 14:24:02 -07:00
Junio C Hamano
7a23d2d28a i18n: use test_i18ngrep in t7506
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-14 13:37:54 -07:00
Junio C Hamano
4d8b32a2e1 Merge branch 'maint'
* maint:
  archive: document limitation of tar.umask config setting
  t3306,t5304: avoid clock skew issues
  git.txt: fix list continuation
2011-04-14 12:26:45 -07:00
Michael J Gruber
e3b02bc953 t3306,t5304: avoid clock skew issues
On systems where the local time and file modification time may be out of
sync (e.g. test directory on NFS) t3306 and t5305 can fail because prune
compares times such as "now" (client time) with file modification times
(server times for remote file systems). I.e., these are spurious test
failures.

Avoid this by setting the relevant modification times to the local time.

Noticed on a system with as little as 2s time skew.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-14 10:47:18 -07:00
Junio C Hamano
f79ce8dbe5 i18n: use test_i18ngrep and test_i18ncmp in t7502
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 16:17:50 -07:00
Junio C Hamano
32177ba663 i18n: use test_i18ngrep in t7501
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 16:17:29 -07:00
Junio C Hamano
29853c8242 i18n: use test_i18ncmp in t7500
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
69382976aa i18n: use test_i18ngrep in t7201
Some test were mistakenly disabled under GETTEXT_POISON as well,
and they have been resurrected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
476cca692c i18n: use test_i18ncmp and test_i18ngrep in t7102 and t7110
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
b3e1900a74 i18n: use test_i18ncmp and test_i18ngrep in t5541, t6040, t6120, t7004, t7012 and t7060
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
68b2a0055c i18n: use test_i18ncmp and test_i18ngrep in t3700, t4001 and t4014
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
fff1bb3a34 i18n: use test_i18ncmp and test_i18ngrep in t3203, t3501 and t3507
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
f2c8c8007c i18n: use test_i18ngrep in t2020, t2204, t3030, and t3200
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
d3bd0425b2 i18n: use test_i18ngrep in lib-httpd and t2019
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
127df8c6cf i18n: do not overuse C_LOCALE_OUTPUT (grep)
Instead of skipping the whole test, introduce test_i18ngrep wrapper that
pretends a successful result under GETTEXT_POISON build.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
c36f94123b i18n: use test_i18ncmp in t1200 and t2200
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
33d56fa076 i18n: .git file is not a human readable message (t5601)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 15:52:47 -07:00
Junio C Hamano
302de7a685 Merge branch 'js/checkout-untracked-symlink' into maint
* js/checkout-untracked-symlink:
  t2021: mark a test as fixed
2011-04-13 13:55:53 -07:00
Jonathon Mah
ff7f089ed1 mergetool: Teach about submodules
When the index has conflicted submodules, mergetool used to mildly
clobber the module, renaming it to mymodule.BACKUP.nnnn, then failing to
copy it non-recursively.

Recognize submodules and offer a resolution instead:

  Submodule merge conflict for 'Shared':
    {local}: submodule commit ad9f12e3e6205381bf2163a793d1e596a9e211d0
    {remote}: submodule commit f5893fb70ec5646efcd9aa643c5136753ac89253
  Use (l)ocal or (r)emote, or (a)bort?

Selecting a commit will stage it, but not update the submodule (as git
does had there been no conflict). Type changes are also supported,
should the path be a submodule on one side, and a file, symlink,
directory, or deleted on the other.

Signed-off-by: Jonathon Mah <me@JonathonMah.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-13 12:21:45 -07:00
Junio C Hamano
cabdee2c5e i18n: do not overuse C_LOCALE_OUTPUT
It is too coarse-grained way that led to artificial splitting of a
logically single test case into "do" and "check only without poison".
As the majority of check is done by comparing expected and actual output
stored in a file with test_cmp anyway, just introduce test_i18ncmp that
pretends the actual output matched the expected one when gettext-poison
is in effect.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12 11:23:23 -07:00
Ævar Arnfjörð Bjarmason
2c050e017a i18n: mark init-db messages for translation
Mark the init-db messages that were added in v1.7.5-rc1~16^2 (init,
clone: support --separate-git-dir for .git file) by Nguyễn Thái Ngọc
Duy for translation.

This requires splitting up the tests that the patch added so that
certain parts of them can be skipped unless the C_LOCALE_OUTPUT
prerequisite is satisfied.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12 10:46:29 -07:00
Ævar Arnfjörð Bjarmason
f06f08b78c i18n: mark checkout plural warning for translation
Mark the "Warning: you are leaving %d commit(s) behind" message added
in v1.7.5-rc0~74^2 (commit: give final warning when reattaching HEAD
to leave commits behind) by Junio C Hamano for translation.

This message requires the use of ngettext() features, and is the first
message to use the Q_() wrapper around ngettext().

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12 00:20:28 -07:00
Junio C Hamano
9db1941458 Merge branch 'js/checkout-untracked-symlink'
* js/checkout-untracked-symlink:
  t2021: mark a test as fixed
2011-04-12 00:05:50 -07:00
Junio C Hamano
5dee1532e1 Merge branch 'nd/init-gitdir'
* nd/init-gitdir:
  t0001: guard a new test with SYMLINKS prerequisite
2011-04-12 00:04:53 -07:00
Johannes Sixt
9973d9329b t2021: mark a test as fixed
The failure was fixed by the previous commit.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-12 00:03:54 -07:00
Johannes Sixt
4e95fb6c37 t0001: guard a new test with SYMLINKS prerequisite
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 23:57:56 -07:00
Erik Faye-Lund
e96c19c50f config: support values longer than 1023 bytes
parse_value in config.c has a static buffer of 1024 bytes that it
parse the value into. This can sometimes be a problem when a
config file contains very long values.

It's particularly amusing that git-config already is able to write
such files, so it should probably be able to read them as well.

Fix this by using a strbuf instead of a fixed-size buffer.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 14:10:06 -07:00
Johan Herland
2ff3a80334 Teach --dirstat not to completely ignore rearranged lines within a file
Currently, the --dirstat analysis ignores when lines within a file are
rearranged, because the "damage" calculated by show_dirstat() is 0.
However, if the object name has changed, we already know that there is
some damage, and it is unintuitive to claim there is _no_ damage.

Teach show_dirstat() to assign a minimum amount of damage (== 1) to
entries for which the analysis otherwise yields zero damage, to still
represent that these files are changed, instead of saying that there
is no change.

Also, skip --dirstat analysis when the object names are the same (e.g. for
a pure file rename).

Signed-off-by: Johan Herland <johan@herland.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 11:16:15 -07:00
Johan Herland
0133dab75d --dirstat-by-file: Make it faster and more correct
Currently, when using --dirstat-by-file, it first does the full --dirstat
analysis (using diffcore_count_changes()), and then resets 'damage' to 1,
if any damage was found by diffcore_count_changes().

But --dirstat-by-file is not interested in the file damage per se. It only
cares if the file changed at all. In that sense it only cares if the blob
object for a file has changed. We therefore only need to compare the
object names of each file pair in the diff queue and we can skip the
entire --dirstat analysis and simply set 'damage' to 1 for each entry
where the object name has changed.

This makes --dirstat-by-file faster, and also bypasses --dirstat's practice
of ignoring rearranged lines within a file.

The patch also contains an added testcase verifying that --dirstat-by-file
now detects changes that only rearrange lines within a file.

Signed-off-by: Johan Herland <johan@herland.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 10:12:24 -07:00
Johan Herland
204f01a2f7 --dirstat: Describe non-obvious differences relative to --stat or regular diff
Also add a testcase documenting the current behavior.

Improved-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johan Herland <johan@herland.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-11 10:11:17 -07:00
Dan McGee
3a243f7024 stash: ensure --no-keep-index and --patch can be used in any order
Don't assume one comes after the other on the command line. Use a
three-state variable to track and check its value accordingly.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-07 15:54:04 -07:00
Dan McGee
21ec98a75d stash: add two more tests for --no-keep-index
One of these passes just fine; the other one exposes a problem where
command line flag order matters for --no-keep-index and --patch
interaction.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-07 15:53:02 -07:00
Junio C Hamano
0c41f33c19 Merge branch 'nm/maint-conflicted-submodule-entries' into maint
* nm/maint-conflicted-submodule-entries:
  submodule: process conflicting submodules only once
2011-04-06 10:41:17 -07:00
Junio C Hamano
cea667e955 Merge branch 'jk/maint-remote-mirror-safer'
* jk/maint-remote-mirror-safer:
  remote: deprecate --mirror
  remote: separate the concept of push and fetch mirrors
  remote: disallow some nonsensical option combinations
2011-04-06 10:38:14 -07:00
Jeff King
e0e2a9cbfa stash: drop dirty worktree check on apply
Before we apply a stash, we make sure there are no changes
in the worktree that are not in the index. This check dates
back to the original git-stash.sh, and is presumably
intended to prevent changes in the working tree from being
accidentally lost during the merge.

However, this check has two problems:

  1. It is overly restrictive. If my stash changes only file
     "foo", but "bar" is dirty in the working tree, it will
     prevent us from applying the stash.

  2. It is redundant. We don't touch the working tree at all
     until we actually call merge-recursive. But it has its
     own (much more accurate) checks to avoid losing working
     tree data, and will abort the merge with a nicer
     message telling us which paths were problems.

So we can simply drop the check entirely.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-06 09:41:22 -07:00
Jon Seymour
9355fc9c35 stash: fix false positive in the invalid ref test.
Jeff King reported a problem with git stash apply incorrectly
applying an invalid stash reference.

There is an existing test that should have caught this, but
the test itself was broken, resulting in a false positive.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-05 20:01:52 -07:00
Jeff King
59d418fe10 stash: fix accidental apply of non-existent stashes
Once upon a time, "git rev-parse ref@{9999999}" did not
generate an error. Therefore when we got an invalid stash
reference in "stash apply", we could end up not noticing
until quite late.  Commit b0f0ecd (detached-stash: work
around git rev-parse failure to detect bad log refs,
2010-08-21) handled this by checking for the "Log for stash
has only %d entries" warning on stderr when we validated the
ref.

A few days later, e6eedc3 (rev-parse: exit with non-zero
status if ref@{n} is not valid., 2010-08-24) fixed the
original issue. That made the extra stderr test superfluous,
but also introduced a new bug. Now the early call to:

  git rev-parse --symbolic "$@"

fails, but we don't notice the exit code. Worse, its empty
output means we think the user didn't provide us a ref, and
we try to apply stash@{0}.

This patch checks the rev-parse exit code and fails early in
the revision parsing process. We can also get rid of the
stderr test; as a bonus, this means that "stash apply" can
now run under GIT_TRACE=1 properly.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-04-05 20:01:37 -07:00