completion: fix PS1 display during a merge on detached HEAD
If your merge stops in a conflict while on a detached HEAD, recent
completion code fails to show anything. This was because various cases
added to support the operation-in-progress markers (e.g. REBASE, MERGING)
forgot that they need to set the variable "b" to something for the result
they computed to be displayed at all.
Probably not many people make trial merges on a detached HEAD (which is
tremendously useful feature of git, by the way), and that may be why this
was not noticed for a long time.
Acked-By: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This reverts commit 0beee4c6dec15292415e3d56075c16a76a22af54 but with a
bit of twist, as we have added "edit hunk manually" hack and we cannot
rely on the original line numbers of the hunks that were manually edited.
builtin-checkout: Don't tell user that HEAD has moved before it has
Previously, checkout would tell the user this message before moving HEAD,
without regard to whether the upcoming move will result in success.
If the move failed, this causes confusion.
Show the message after the move, unless the move failed.
Signed-off-by: Daniel Cordero <theappleman@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
stat_tracking_info() assumes that upstream references (as specified by
--track or set up automatically) are commits. By calling lookup_commit()
on them, create_objects() creates objects for them with type commit no
matter what their real type is; this disturbs lookup_tag() later on in the
call sequence, leading to git status, git branch -v and git checkout
erroring out.
Fix this by using lookup_commit_reference() instead so that (annotated)
tags can be used as upstream references.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The sender address, as specified with the '--from' command line option,
couldn't be set in the config file. So add a new config option,
'sendemail.from', which sets it. One can use 'sendemail.<identity>.from'
as well of course, which is likely the more useful case.
The sender address would default to GIT_AUTHOR_IDENT, which is usually the
right thing, but this doesn't allow switching based on the identity
selected. It's possible to switch the SMTP server and envelope sender by
using the '--identity' option, in which case one probably wants to use a
different from address as well, but this had to be manually specified.
The documentation for 'from' is also corrected somewhat. If '--from' is
specified (or the new sendemail.from option is used) then the user isn't
prompted. The default with no '--from' option (or sendemail.from option)
is GIT_AUTHOR_IDENT first then GIT_COMMITTER_IDENT, not just
GIT_COMMITTER_IDENT.
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile
When the installed programs are tar'ed up and installed on a system where
bin/ and libexec/git-core/ live on different file systems, we do not want
libexec/git-core/git-* to be hardlinks to bin/git.
Noticed by Cedric Staniewski.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-checkout and git-branch allow setting up an arbitrary committish as
the upstream reference for --track. In particular, tags are allowed. But
they and git-status barf on non-commit upstreams as soon as they are
asked for trackings stats.
Expose this shortcoming by adding two tests: annotated tags are affected
but lightweight tags are OK.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The fmt-merge-msg does a strong syntax checking of its input and fails
with if it is incorrect. The LF character is the only character
important for fmt-merge-msg. As the url in FETCH_HEAD plays only
informational role, a quoted representation of the url should be good
and true enough.
The url often comes from either user-editable config or command line,
so it is reasonable to expect all kinds of characters in it, including
the characters which the format of FETCH_HEAD considers special (line
separator in this case).
Noticed and reported by Hugo Mildenberger.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation: clarify / requirement in 'git check-ref-format'
'git check-ref-format' checks for the presence of at least one '/', the
idea being that there should be no refs directly below 'refs/', so there
should be a category like 'heads/' or 'tags/' in a refname.
Try and make this clearer in the man page.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
bash completion: complete variable names for "git config" with options
This makes it easier for users to get and unset their configuration
variables without having to open documentation or dig through their
configuration file.
__git_config_get_set_variables() retrieves the set configuration
variables from the appropriate configuration file. For example, if
the user has previously specified --global only the global variables
are returned. The same applies for --system, and --file. If no
location has been specified, all set variables are returned.
Signed-off-by: Stephen Boyd <bebarino@gmail.com> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb: Remove unused $hash_base parameter from normalize_link_target
...since it was decided for normalize_link_target to only mangle
pathname, and do not try to check if target is present in $hash_base
tree, for performance reasons.
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb: Simplify snapshot format detection logic in evaluate_path_info
This issue was caught by perlcritic in harsh severity level noticing
that catch variable was used outside conditional thanks to the
Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest
policy. See "Perl Best Practices", chapter 12. Regular Expressions,
section 12.15. Captured Values:
Pattern matches that fail never assign anything to $1, $2, etc.,
nor do they leave those variables undefined. After an unsuccessful
pattern match, the numeric capture variables remain exactly as they
were before the match was attempted.
New version is in my opinion much easier to understand; previous
version worked correctly due to the fact that we returned from loop
on first found match.
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Acked-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The logic in 83ae209 (checkout branch: prime cache-tree fully,
2009-04-20) is bogus; checkout can switch branches with a dirty
index and in such a case the tree won't match HEAD.
t3900: ISO-2022-JP has more than one popular variants
When converting from other encodings (e.g. EUC-JP or UTF-8), there are
subtly different variants of ISO-2022-JP, all of which are valid. At the
end of line or when a run of string switches to 1-byte sequence, ESC ( B
can be used to switch to ASCII or ESC ( J can be used to switch to ISO
646:JP (JIS X 0201) but they essentially are the same character set and
are used interchangeably. Similarly the set ESC $ @ switches to (JIS X
0208-1978) and ESC $ B switches to (JIS X 0208-1983) are in practice used
interchangeably.
Depending on the iconv library and the locale definition on the system, a
program that converts from another encoding to ISO-2022-JP can produce
different byte sequence, and GIT_TEST_CMP (aka "diff -u") will report the
difference as a failure.
Fix this by converting the expected and the actual output to UTF-8 before
comparing when the end result is ISO-2022-JP. The test vector string in
t3900/ISO-2022-JP.txt is expressed with ASCII and JIS X 0208-1983, but it
can be expressed with any other possible variant, and when converted back
to UTF-8, these variants produce identical byte sequences.
gitweb: Use block form of map/grep in a few cases more
Use block form of 'grep' i.e. 'grep {BLOCK} LIST' rather than
'grep(EXPR, LIST)' in filter_snapshot_fmts subroutine. This makes
code more readable, as expression is rather long, and statement above
there is 'map' with very similar expression also in the block form.
Remove unnecessary and misleading parentheses around block form 'map'
arguments in quote_command subroutine.
The inner "map" in format_snapshot_links was left alone, as it is not
clear whether adding parentheses or changing it into block form would
improve readibility and clarity of this code.
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
In most cases (except insert_file() subroutine) we used old two argument
form of 'open' to open files for reading. This can cause subtle bugs when
$projectroot or $projects_list file starts with mode characters ('>', '<',
'+<', '|', etc.) or with leading whitespace; and also when $projects_list
file or $mimetypes_file or ctags files end with trailing whitespace or '|'.
Additionally it is also more clear to explicitly state that we open those
files for reading.
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The script was using bareword filehandles. This is considered a bad
practice so they have been changed to indirect filehandles.
Changes touch git_get_project_ctags and mimetype_guess_file;
while at it rename local variable from $mime to $mimetype (in
mimetype_guess_file) to better reflect its value (its contents).
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
bisect: make "git bisect" use new "--next-all" bisect-helper function
This patch replace the "--next-exit" option of "git bisect--helper"
with a "--next-all" option that does merge base checking using
the "check_good_are_ancestors_of_bad" function implemented in
"bisect.c" in a former patch.
The new "--next-all" option is then used in "git-bisect.sh" instead
of the "--next-exit" option, and all the shell functions in
"git-bisect.sh" that are now unused are removed.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This is done by renaming many functions and some variables to
remove "skip" in the name, and by adding a
"struct sha1_array *array" argument where needed.
While at it, make the second argument to "lookup_sha1_array"
const. It becomes "const unsigned char *sha1".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This patch moves some function calls into "bisect_next_exit" so
that functions are nesting less.
The call to "bisect_rev_setup" is moved from "bisect_common" into
"bisect_next_exit" and the call to "read_bisect_refs" from
"bisect_rev_setup" into "bisect_next_exit".
While at it, "rev_argv" is moved into "bisect_rev_setup".
This will make it easier and cleaner to implement checking merge
bases.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
bisect: use new "struct argv_array" to prepare argv for "setup_revisions"
Because we will use other instances of this struct.
The "rev_argv_push" function is changed into 2 functions
"argv_array_push" and "argv_array_push_sha1" that take a "struct
argv_array *" as first argument. And these functions are used to
simplify "bisect_rev_setup".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This will make it easier to use good revisions for checking merge
bases later.
To simplify the code, a new "sha1_array_push" function is also
introduced.
And while at it we move the earlier part of the code to fill the
argv that is passed to "setup_revisions", so that all this code is
now completely after "read_bisect_refs".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
bisect: use "git rev-parse --sq-quote" instead of a custom "sq" function
As the "sq" function was the only place using Perl in "git-bisect.sh",
this removes the Perl dependency in this script.
While at it, we also remove the sed instruction in the Makefile that
substituted @@PERL@@ with the Perl path in shell scripts, as this is
not needed anymore. (It is now only needed in "git-instaweb.sh" but
this command is dealt with separately in the Makefile.)
Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive: never leave index unmerged while recursing
When you are trying to come up with the final result (i.e. depth=0), you
want to record how the conflict arose by registering the state of the
common ancestor, your branch and the other branch in the index, hence you
want to do update_stages().
When you are merging with positive depth, that is because of a criss-cross
merge situation. In such a case, you would need to record the tentative
result, with conflict markers and all, as if the merge went cleanly, even
if there are conflicts, in order to write it out as a tree object later to
be used as a common ancestor tree.
update_file() calls update_file_flags() with update_cache=1 to signal that
the result needs to be written to the index at stage #0 (i.e. merged), and
the code should not clobber the index further by calling update_stages().
The codepath to deal with rename/delete conflict in a recursive merge
however left the index unmerged.
Signed-off-by: Dave Olszewski <cxreg@pobox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Teach 'git checkout' to preload the index contents
This makes git checkout know to use the threaded index preloading if it
is enabled in the config file. You need to have
[core]
preloadindex = true
in your config file to see it, and for that feature to make sense your
filesystem needs to be able to do concurrent 'lstat()' lookups, but when
that is the case (especially NFS over a high-latency network), this can
be a noticeable performance win.
But with a low-latency network and at least older Linux NFS clients, this
will clearly potentially cause a lot of lock contention. It may still
speed up the uncached case, but the threading and locking overhead will
result in the cached case likely slowing down.
That was almost certainly fixed by Linux commit fc0f684c2 ("NFS: Remove
BKL from NFS lookup code"), but that one got merged into 2.6.27-rc1, so
older kernel versions than 2.6.27 will not scale very well.
But regardless, it's the right thing to do. If your filesystem doesn't
scale, don't enable index preloading.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Avoid unnecessary 'lstat()' calls in 'get_stat_data()'
When we ask get_stat_data() to get the mode and size of an index entry,
we can avoid the lstat() call if we have marked the index entry as being
uptodate due to earlier lstat() calls.
This avoids a lot of unnecessary lstat() calls in eg 'git checkout',
where the last phase shows the differences to the working tree
(requiring a diff), but earlier phases have already verified the index.
On the kernel repo (with a fast machine and everything cached), this
changes timings of a nul 'git checkout' from
so it can obviously be noticeable, although equally obviously it's not a
show-stopper on this particular machine. The difference is likely larger
on slower machines, or with operating systems that don't do as good a job
of name caching.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* maint:
Documentation: cloning to empty directory is allowed
Clarify kind of conflict in merge-one-file helper
git config: clarify --add and --get-color
archive-tar.c: squelch a type mismatch warning
add: don't complain when adding empty project root
We try to warn the user if one of their pathspecs caused no
matches, as it may have been a typo. However, we disable the
warning if the pathspec points to an existing file, since
that means it is not a typo but simply an empty directory.
Unfortunately, the file_exists() test was broken for one
special case: the pathspec of the project root is just "".
This patch detects this special case and acts as if the file
exists (which it must, since it is the project root).
The user-visible effect is that this:
$ mkdir repo && cd repo && git init && git add .
used to complain like:
fatal: pathspec '' did not match any files
but now is a silent no-op.
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetool--lib: specialize diff options for emerge and ecmerge
The ecmerge documentation mentions the following form:
ecmerge --mode=diff2 $1 $2
Since git-difftool is about diffing, we should use that instead
of --mode=merge2. Likewise, this drops the $MERGED argument to
emerge, as discussed on the git list ($gmane/117930).
Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
format-patch let -k override a config-specified format.numbered
Let a command-line --keep-subject (-k) override a config-specified
format.numbered (--numbered (-n)), rather than provoking the
"-n and -k are mutually exclusive" failure.
* t4021-format-patch-numbered.sh: Test for the above
Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The alias argv comes from the split_cmdline function, which
splits the config text for the alias into an array of
strings. It returns the number of elements in the array, but
does not actually put a NULL at the end of the array.
Later, the trace function tries to print this argv and
assumes that it has the trailing NULL.
The split_cmdline function is probably at fault, since argv
lists almost always end with a NULL signal. This patch adds
one, in addition to the returned count; this doesn't hurt
the other callers at all, since they were presumably using
the count already (and will never look at the NULL).
While we're there and using ALLOC_GROW, let's clean up the
other manual grow.
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Use of function prototypes is considered bad practice in Perl. The
ones used here didn't accomplish anything anyhow, so they've been
removed.
>From perlsub(1):
[...] the intent of this feature [prototypes] is primarily to let
you define subroutines that work like built-in functions [...]
you can generate new syntax with it [...]
We don't want to have subroutines behaving exactly like built-in
functions, we don't want to define new syntax / syntactic sugar, so
prototypes in gitweb are not needed... and they can have unintended
consequences.
Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
The bitfields in struct grep_opt are converted to full ints,
increasing its size. This shouldn't be a problem as there is only a
single instance in memory.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Add support for options that don't start with a dash. Initially, they
don't accept arguments and can only be short options, i.e. consist of a
single character.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
On Thu, May 07, 2009 at 09:44:17PM +0200, René Scharfe wrote:
Subject: [PATCH] ls-files: make --no-empty-directory properly negatable
This option was specified to parseopt as an OPT_BIT; however, we
actually want to _set_ the bit on --no-empty-directory. Thus the
existing implementation used --no-empty-directory, and required
--no-no-empty-directory to negate it.
Now that OPT_NEGBIT exists, we can properly support it as
--empty-directory and --no-empty-directory (but of course
still defaulting to showing empty directories).
Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Add OPTION_NEGBIT and OPT_NEGBIT, mirroring OPTION_BIT and OPT_BIT.
OPT_NEGBIT can be used together with OPT_BIT to define two options
that cancel each other out.
Note: this patch removes the reminder from the test script because
it adds a test for --no-or4 and there already was one for --or4.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
t4200: convert sed expression which operates on non-text file to perl
POSIX only requires sed to work on text files and MERGE_RR is not a text
file. Some versions of sed complain that this file is not newline
terminated, and exit non-zero. Use perl instead which does not have a
problem with it.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
These two lines appear to be unnecessary. They set variables which are not
used afterwards. The primary motivation to remove them is that the sed
invocation exits non-zero for seds which require newline termination of
input files.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/annotate-tests.sh: avoid passing a non-newline terminated file to sed
Some versions of sed exit non-zero if the file they are supplied is not
newline terminated. Solaris's /usr/xpg4/bin/sed is one such sed. So
rework this test to avoid doing so.
This affects tests t8001-annotate.sh and t8002-blame.sh.
t4118: avoid sed invocation on file without terminating newline
Some versions of sed exit non-zero if the file they are supplied is not
newline terminated. Solaris's /usr/xpg4/bin/sed is one such sed. In
this case the sed invocation can be avoided entirely since the resulting
file is equivalent to a previously created file. So, just copy that file
into place instead.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-clean doc: the command only affects paths under $(cwd)
Fredrik Skolmli and Thomas Rast noticed that it was left unstated that
"git clean" ran from a subdirectory will not affect anything outside it,
with or without path limiters.
* maint:
improve error message in config.c
t4018-diff-funcname: add cpp xfuncname pattern to syntax test
Work around BSD whose typeof(tv.tv_sec) != time_t
git-am.txt: reword extra headers in message body
git-am.txt: Use date or value instead of time or timestamp
git-am.txt: add an 'a', say what 'it' is, simplify a sentence
dir.c: Fix two minor grammatical errors in comments
git-svn: fix a sloppy Getopt::Long usage