Commit graph

1526 commits

Author SHA1 Message Date
Junio C Hamano 419f2ecf78 Merge branch 'hv/submodule-recurse-push'
"git push --recurse-submodules" learns to optionally look into the
histories of submodules bound to the superproject and push them out.

By Heiko Voigt
* hv/submodule-recurse-push:
  push: teach --recurse-submodules the on-demand option
  Refactor submodule push check to use string list instead of integer
  Teach revision walking machinery to walk multiple times sequencially
2012-04-24 14:40:20 -07:00
Junio C Hamano 987dbb86ec Merge branch 'jl/maint-submodule-recurse-fetch'
"git fetch" that recurses into submodules on demand did not check if
it needs to go into submodules when non branches (most notably, tags)
are fetched.

By Jens Lehmann
* jl/maint-submodule-recurse-fetch:
  submodules: recursive fetch also checks new tags for submodule commits
2012-04-23 12:58:28 -07:00
Junio C Hamano 9d76db4e67 Merge branch 'jc/maint-blame-minimal'
"git blame" started missing quite a few changes from the origin since we
stopped using the diff minimalization by default in v1.7.2 era.

* jc/maint-blame-minimal:
  blame: accept --need-minimal
2012-04-23 12:58:23 -07:00
Junio C Hamano 58bbace89d Merge branch 'jh/apply-free-patch'
Valgrind reports quite a lot of discarded memory inside apply.
Fix them, audit and document the buffer ownership rules.

By Junio C Hamano (8) and Jared Hance (1)
* jh/apply-free-patch:
  apply: document buffer ownership rules across functions
  apply: tighten constness of line buffer
  apply: drop unused macro
  apply: free unused fragments for submodule patch
  apply: free patch->result
  apply: release memory for fn_table
  apply: free patch->{def,old,new}_name fields
  apply: rename free_patch() to free_patch_list()
  apply: do not leak patches and fragments
2012-04-23 12:52:18 -07:00
Junio C Hamano bca57eeac1 Merge branch 'rl/show-empty-prefix'
"git rev-parse --show-prefix" emitted nothing when run at the
top-level of the working tree, while "git rev-parse --show-cdup" gave
an empty line.  Make them consistent.

By Ross Lagerwall
* rl/show-empty-prefix:
  rev-parse --show-prefix: add in trailing newline
2012-04-23 12:40:08 -07:00
Junio C Hamano 29a03fa562 Merge branch 'ms/remote-usage-string'
Adds some subcommands that were not listed in "git remote --help"
usage strings.

As an independent follow-up, we may want to rethink how the overall
usage string and subcommand usage strings are maintained.

By Michael Schubert
* ms/remote-usage-string:
  remote: update builtin usage
2012-04-23 12:39:18 -07:00
Junio C Hamano c5da24a73a Merge branch 'ct/advise-push-default'
Break down the cases in which "git push" fails due to non-ff into
three categories, and give separate advise messages for each case.

By Christopher Tiwald (2) and Jeff King (1)
* ct/advise-push-default:
  Fix httpd tests that broke when non-ff push advice changed
  clean up struct ref's nonfastforward field
  push: Provide situational hints for non-fast-forward errors
2012-04-20 15:50:37 -07:00
Junio C Hamano 27da1cf65b Merge branch 'jc/push-upstream-sanity'
Fix broken 'push to upstream' implementation.  "git push $there" without
refspec, when the current branch is set to push to a remote different from
$there, used to push to $there using the upstream information to a remote
unreleated to $there.

* jc/push-upstream-sanity:
  push: error out when the "upstream" semantics does not make sense
2012-04-20 15:49:51 -07:00
Junio C Hamano 503c15ac09 Merge branch 'jc/fmt-merge-msg-people'
The "fmt-merge-msg" command learns to list the primary contributors
involved in the side topic you are merging.

* jc/fmt-merge-msg-people:
  fmt-merge-msg: show those involved in a merged series
2012-04-20 15:48:33 -07:00
Junio C Hamano 091df17f27 Merge branch 'jc/commit-unedited-template'
When "git commit --template F" errors out because the user did not touch
the message, it claimed that it aborts due to "empty message", which was
utterly wrong.

By Junio C Hamano (4) and Adam Monsen (1)
* jc/commit-unedited-template:
  Documentation/git-commit: rephrase the "initial-ness" of templates
  git-commit.txt: clarify -t requires editing message
  commit: rephrase the error when user did not touch templated log message
  commit: do not trigger bogus "has templated message edited" check
  t7501: test the right kind of breakage
2012-04-16 12:43:07 -07:00
Junio C Hamano b3ba46945d Merge branch 'jk/branch-quiet'
Even with "-q"uiet option, "checkout" used to report setting up tracking.
Also "branch" learns "-q"uiet option to squelch informational message.

By Jeff King
* jk/branch-quiet:
  teach "git branch" a --quiet option
  checkout: suppress tracking message with "-q"
2012-04-16 12:42:22 -07:00
Junio C Hamano c0599f6993 Merge branch 'jk/diff-no-rename-empty'
Forbids rename detection logic from matching two empty files as renames
during merge-recursive to prevent mismerges.

By Jeff King
* jk/diff-no-rename-empty:
  merge-recursive: don't detect renames of empty files
  teach diffcore-rename to optionally ignore empty content
  make is_empty_blob_sha1 available everywhere
  drop casts from users EMPTY_TREE_SHA1_BIN
2012-04-16 12:41:49 -07:00
Junio C Hamano 9eefd8ae8a Merge branch 'jc/commit-hook-authorship'
"git commit --author=$name" did not tell the name that was being recorded
in the resulting commit to hooks, even though it does do so when the end
user overrode the authorship via the "GIT_AUTHOR_NAME" environment
variable.

* jc/commit-hook-authorship:
  commit: pass author/committer info to hooks
  t7503: does pre-commit-hook learn authorship?
  ident.c: add split_ident_line() to parse formatted ident line
2012-04-15 22:51:01 -07:00
Junio C Hamano 47de6b0425 Merge branch 'nd/stream-more'
Use API to read blob data in smaller chunks in more places to reduce the
memory footprint.

By Nguyễn Thái Ngọc Duy (6) and Junio C Hamano (1)
* nd/stream-more:
  update-server-info: respect core.bigfilethreshold
  fsck: use streaming API for writing lost-found blobs
  show: use streaming API for showing blobs
  parse_object: avoid putting whole blob in core
  cat-file: use streaming API to print blobs
  Add more large blob test cases
  streaming: make streaming-write-entry to be more reusable
2012-04-15 22:50:39 -07:00
Jens Lehmann a6801adc52 submodules: recursive fetch also checks new tags for submodule commits
Since 88a21979c (fetch/pull: recurse into submodules when necessary) all
fetched commits are examined if they contain submodule changes (unless
configuration or command line options inhibit that). If a newly recorded
submodule commit is not present in the submodule, a fetch is run inside
it to download that commit.

Checking new refs was done in an else branch where it wasn't executed for
tags. This normally isn't a problem because tags are only fetched with
the branches they live on, then checking the new commits in the fetched
branches for submodule commits will also process all tags. But when a
specific tag is fetched (or the refspec contains refs/tags/) commits only
reachable by tags won't be searched for submodule commits, which is a bug.

Fix that by moving the code outside the if/else construct to handle new
tags just like any other ref. The performance impact of adding tags that
most of the time lie on a branch which is checked anyway for new submodule
commit should be minimal, as since 6859de4 (fetch: avoid quadratic loop
checking for updated submodules) all ref-tips are collected first and then
fed to a single rev-list.

Spotted-by: Jeff King <peff@peff.net>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-14 16:26:57 -07:00
Junio C Hamano 92737a2201 apply: document buffer ownership rules across functions
In general, the private functions in this file were not very
much documented; even though what each of them do is reasonably
self explanatory, the ownership rules for various buffers and
data structures were not very obvious.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-11 14:43:48 -07:00
Junio C Hamano 26693ba81c apply: tighten constness of line buffer
These point into a single line in the patch text we read from
the input, and they are not used to modify it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-11 14:41:42 -07:00
Junio C Hamano c2066a3eda apply: drop unused macro
CHUNKSIZE is no longer used.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-11 14:38:31 -07:00
Junio C Hamano 059a500d25 blame: accept --need-minimal
Between v1.7.1 and v1.7.2, 582aa00bdf switched the default "diff"
invocation not to use XDF_NEED_MINIMAL, but this breaks "git blame"
rather badly.

Allow the command line option to ask for an extra careful matching.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-11 13:11:55 -07:00
Ross Lagerwall 658219f1c7 rev-parse --show-prefix: add in trailing newline
Print out a trailing newline when --show-prefix is run with cwd
at the top level of the tree which results in an empty prefix.
Behavior is now like --show-cdup.

Fixes an expected failure in t1501.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-10 09:25:35 -07:00
Michael Schubert 31558fd48e remote: update builtin usage
Add missing options "--tags|--no-tags" and "--push".

Signed-off-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-09 15:06:50 -07:00
Junio C Hamano 6d5c16a90c Merge branch 'tr/cache-tree' into maint-1.7.8
* tr/cache-tree:
  t0090: be prepared that 'wc -l' writes leading blanks
  reset: update cache-tree data when appropriate
  commit: write cache-tree data when writing index anyway
  Refactor cache_tree_update idiom from commit
  Test the current state of the cache-tree optimization
  Add test-scrap-cache-tree
2012-04-09 13:40:32 -07:00
Junio C Hamano 135dadef71 push: error out when the "upstream" semantics does not make sense
The user can say "git push" without specifying any refspec.  When using
the "upstream" semantics via the push.default configuration, the user
wants to update the "upstream" branch of the current branch, which is the
branch at a remote repository the current branch is set to integrate with,
with this command.

However, there are cases that such a "git push" that uses the "upstream"
semantics does not make sense:

 - The current branch does not have branch.$name.remote configured.  By
   definition, "git push" that does not name where to push to will not
   know where to push to.  The user may explicitly say "git push $there",
   but again, by definition, no branch at repository $there is set to
   integrate with the current branch in this case and we wouldn't know
   which remote branch to update.

 - The current branch does have branch.$name.remote configured, but it
   does not specify branch.$name.merge that names what branch at the
   remote this branch integrates with. "git push" knows where to push in
   this case (or the user may explicitly say "git push $remote" to tell us
   where to push), but we do not know which remote branch to update.

 - The current branch does have its remote and upstream branch configured,
   but the user said "git push $there", where $there is not the remote
   named by "branch.$name.remote".  By definition, no branch at repository
   $there is set to integrate with the current branch in this case, and
   this push is not meant to update any branch at the remote repository
   $there.

The first two cases were already checked correctly, but the third case was
not checked and we ended up updating the branch named branch.$name.merge
at repository $there, which was totally bogus.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-05 13:35:57 -07:00
Junio C Hamano d82829b612 Sync with 1.7.9.6 2012-04-02 13:11:49 -07:00
Junio C Hamano b52ab19d91 Merge branch 'jc/maint-merge-autoedit' into maint
* jc/maint-merge-autoedit:
  merge: backport GIT_MERGE_AUTOEDIT support
2012-04-02 12:56:35 -07:00
Junio C Hamano b2eda9bdfb commit: rephrase the error when user did not touch templated log message
When the user exited editor without editing the commit log template given
by "git commit -t <template>", the commit was aborted (correct) with an
error message that said "due to empty commit message" (incorrect).

This was because the original template support was done by piggybacking on
the check to detect an empty log message.  Split the codepaths into two
independent checks to clarify the error.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-30 12:20:00 -07:00
Junio C Hamano 010c7dbcbe commit: do not trigger bogus "has templated message edited" check
When "-t template" and "-F msg" options are both given (or worse yet,
there is "commit.template" configuration but a message is given in some
other way), the documentation says that template is ignored.  However,
the "has the user edited the message?" check still used the contents of
the template file as the basis of the emptyness check.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-30 11:30:59 -07:00
Heiko Voigt eb21c732d6 push: teach --recurse-submodules the on-demand option
When using this option git will search for all submodules that
have changed in the revisions to be send. It will then try to
push the currently checked out branch of each submodule.

This helps when a user has finished working on a change which
involves submodules and just wants to push everything in one go.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
Mentored-by: Jens Lehmann <Jens.Lehmann@web.de>
Mentored-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-30 09:02:55 -07:00
Junio C Hamano 9d16c2d514 apply: free unused fragments for submodule patch
We simply discarded the fragments that we are not going to use upon seeing
a patch to update the submodule commit bound at path that we have not
checked out.

Free these fragments, not to leak them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-28 23:27:00 -07:00
René Scharfe b3065bdc03 config: remove useless assignment
v1.7.9-8-g270a344 (config: stop using config_exclusive_filename) replaced
config_exclusive_filename with given_config_file.  In one case this
resulted in a self-assignment, which is reported by clang as a warning.
Remove the useless code.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-28 15:19:17 -07:00
Junio C Hamano 8192a2fafc apply: free patch->result
This is by far the largest piece of data, much larger than the patch and
fragment structures or the three name fields in the patch structure.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-27 15:41:22 -07:00
Junio C Hamano 5c8774330f apply: release memory for fn_table
The fn_table is used to record the result of earlier patch application in
case a hand-crafted input file contains multiple patches to the same file.
Both its string key (filename) and the contents are borrowed from "struct
patch" that represents the previous application in the same apply_patch()
call, and they do not leak, but the table itself was not freed properly.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-27 15:40:39 -07:00
Junio C Hamano 2901bbe5be apply: free patch->{def,old,new}_name fields
These were all allocated in the heap by parsing the header parts of the
patch, but we did not bother to free them.  Some used to share the memory
(e.g. copying def_name to old_name) so this is not just the matter of
adding three calls to free().

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-27 15:40:36 -07:00
Junio C Hamano a604ddef73 apply: rename free_patch() to free_patch_list()
As that is the only logical name for a function that walks a list
and frees each element on it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-27 15:39:31 -07:00
Jeff King d65ddf1984 teach "git branch" a --quiet option
There's currently no way to suppress the informational
"deleted branch..." or "set up tracking..." messages.  This
patch provides a "-q" option to do so.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-26 21:32:43 -07:00
Jeff King f9a482e62b checkout: suppress tracking message with "-q"
Like the "switched to..." message (which is already
suppressed by "-q"), this message is purely informational.
Let's silence it if the user asked us to be quiet.

This patch is slightly more than a one-liner, because we
have to teach create_branch to propagate the flag all the
way down to install_branch_config.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-26 21:32:43 -07:00
Jeff King cba595bd21 drop casts from users EMPTY_TREE_SHA1_BIN
This macro already evaluates to the correct type, as it
casts the string literal to "unsigned char *" itself
(and callers who want the literal can use the _LITERAL
form).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23 13:52:05 -07:00
Junio C Hamano 0f360763c0 Merge branch 'maint-1.7.8' into maint
* maint-1.7.8:
  t/Makefile: Use $(sort ...) explicitly where needed
  gitweb: Fix actionless dispatch for non-existent objects
  i18n of multi-line advice messages
2012-03-20 15:53:30 -07:00
Junio C Hamano d387868a7d merge: backport GIT_MERGE_AUTOEDIT support
Even though 1.7.9.x series does not open the editor by default
when merging in general, it does do so in one occassion: when
merging an annotated tag. And worse yet, there is no good way
for older scripts to decline this.

Backport the support for GIT_MERGE_AUTOEDIT environment variable
from 1.7.10 track to help those stuck on 1.7.9.x maintenance
track.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-20 15:39:10 -07:00
Junio C Hamano 39af78961d Merge branch 'jc/advise-i18n' into maint-1.7.8
* jc/advise-i18n:
  i18n of multi-line advice messages
2012-03-20 15:25:38 -07:00
Christopher Tiwald f25950f347 push: Provide situational hints for non-fast-forward errors
Pushing a non-fast-forward update to a remote repository will result in
an error, but the hint text doesn't provide the correct resolution in
every case. Give better resolution advice in three push scenarios:

1) If you push your current branch and it triggers a non-fast-forward
error, you should merge remote changes with 'git pull' before pushing
again.

2) If you push to a shared repository others push to, and your local
tracking branches are not kept up to date, the 'matching refs' default
will generate non-fast-forward errors on outdated branches. If this is
your workflow, the 'matching refs' default is not for you. Consider
setting the 'push.default' configuration variable to 'current' or
'upstream' to ensure only your current branch is pushed.

3) If you explicitly specify a ref that is not your current branch or
push matching branches with ':', you will generate a non-fast-forward
error if any pushed branch tip is out of date. You should checkout the
offending branch and merge remote changes before pushing again.

Teach transport.c to recognize these scenarios and configure push.c
to hint for them. If 'git push's default behavior changes or we
discover more scenarios, extension is easy. Standardize on the
advice API and add three new advice variables, 'pushNonFFCurrent',
'pushNonFFDefault', and 'pushNonFFMatching'. Setting any of these
to 'false' will disable their affiliated advice. Setting
'pushNonFastForward' to false will disable all three, thus preserving the
config option for users who already set it, but guaranteeing new
users won't disable push advice accidentally.

Based-on-patch-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Christopher Tiwald <christiwald@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-19 21:42:06 -07:00
Junio C Hamano 418a1435f1 fmt-merge-msg: show those involved in a merged series
As we already walk the history of the branch that gets merged to
come up with a short log, let's label it with names of the primary
authors, so that the user who summarizes the merge can easily give
credit to them in the log message.

Also infer the names of "lieutents" to help integrators at higher
level of the food-chain to give credit to them, by counting:

 * The committer of the 'tip' commit that is merged
 * The committer of merge commits that are merged

Often the first one gives the owner of the history being pulled, but
his last pull from his sublieutenants may have been a fast-forward,
in which case the first one would not be.  The latter rule will
count the integrator of the history, so together it might be a
reasonable heuristics.

There are two special cases:

 - The "author" credit is omitted when the series is written solely
   by the same author who is making the merge. The name can be seen
   on the "Author" line of the "git log" output to view the log
   message anyway.

 - The "lieutenant" credit is omitted when there is only one key
   committer in the merged branch and it is the committer who is
   making the merge. Typically this applies to the case where the
   developer merges his own branch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-13 20:44:29 -07:00
Junio C Hamano 57cec0aec7 Merge branch 'az/verify-tag-use-gpg-config'
"git tag -s" honored "gpg.program" configuration variable since
1.7.9, but "git tag -v" and "git verify-tag" didn't.

By Alex Zepeda
* az/verify-tag-use-gpg-config:
  verify-tag: Parse GPG configuration options.
2012-03-12 15:55:54 -07:00
Junio C Hamano 7dfe8ad600 commit: pass author/committer info to hooks
When lying the author name via GIT_AUTHOR_NAME environment variable
to "git commit", the hooks run by the command saw it and could act
on the name that will be recorded in the final commit. When the user
uses the "--author" option from the command line, the command should
give the same information to the hook, and back when "git command"
was a scripted Porcelain, it did set the environment variable and
hooks can learn the author name from it.

However, when the command was reimplemented in C, the rewritten code
was not very faithful to the original, and hooks stopped getting the
authorship information given with "--author".  Fix this by exporting
the necessary environment variables.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-11 14:07:22 -07:00
Alex Zepeda a2c25061aa verify-tag: Parse GPG configuration options.
Modify verify-tag to load relevant GPG variables from the git
configuratio file.  This allows git tag -v to use an alternative
GPG binary in the same way that git tag -s does.

Signed-off-by: Alex Zepeda <alex@inferiorhumanorgans.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-08 14:03:07 -08:00
Junio C Hamano 9a4c97eb89 Merge branch 'kb/maint-prune-rmdir-closedir'
By Karsten Blees
* kb/maint-prune-rmdir-closedir:
  fix deletion of .git/objects sub-directories in git-prune/repack
2012-03-08 13:05:04 -08:00
Jared Hance 6fe53908f9 apply: do not leak patches and fragments
In the while loop inside apply_patch, patch and fragments are
dynamically allocated with a calloc. However, only unused patches
are actually freed and the rest are left to leak. Since a list is
actively built up consisting of the used patches, they can simply be
iterated and freed at the end of the function.

In addition, the text in fragments were not freed, primarily because
they mostly point into a patch text that is freed as a whole. But
there are some cases where new piece of memory is allocated and
pointed by a fragment (namely, when handling a binary patch).

Introduce a free_patch bitfield to mark each fragment if its text
needs to be freed, and free patches, fragments and fragment text
that need to be freed when we are done with the input.

Signed-off-by: Jared Hance <jaredhance@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-07 14:56:08 -08:00
Karsten Blees d34e70d6b8 fix deletion of .git/objects sub-directories in git-prune/repack
Both git-prune and git-repack (and thus, git-gc) try to rmdir while
holding a DIR* handle on the directory.  This can leave dangling
empty directories in the .git/objects on platforms where directory
cannot be removed while they are open.

First call closedir() and then rmdir(); that is more logical ordering.

Reported-by: John Chen <john0312@gmail.com>
Reported-by: Stefan Naewe <stefan.naewe@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
Improved-and-Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-07 10:24:33 -08:00
Nguyễn Thái Ngọc Duy da591a7f4b update-server-info: respect core.bigfilethreshold
This command indirectly calls check_sha1_signature() (add_info_ref ->
deref_tag -> parse_object -> ..) , which may put whole blob in memory
if the blob's size is under core.bigfilethreshold. As config is not
read, the threshold is always 512MB. Respect user settings here.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-07 09:07:39 -08:00
Nguyễn Thái Ngọc Duy 6f7f3beb2d fsck: use streaming API for writing lost-found blobs
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-07 09:07:39 -08:00