Commit graph

589 commits

Author SHA1 Message Date
Stephen Boyd c2e86addb8 Fix sparse warnings
Fix warnings from 'make check'.

 - These files don't include 'builtin.h' causing sparse to complain that
   cmd_* isn't declared:

   builtin/clone.c:364, builtin/fetch-pack.c:797,
   builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
   builtin/merge-index.c:69, builtin/merge-recursive.c:22
   builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
   builtin/notes.c:822, builtin/pack-redundant.c:596,
   builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
   builtin/remote.c:1512, builtin/remote-ext.c:240,
   builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
   builtin/unpack-file.c:25, builtin/var.c:75

 - These files have symbols which should be marked static since they're
   only file scope:

   submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
   submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
   unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
   url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48

 - These files redeclare symbols to be different types:

   builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
   usage.c:49, usage.c:58, usage.c:63, usage.c:72

 - These files use a literal integer 0 when they really should use a NULL
   pointer:

   daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362

While we're in the area, clean up some unused #includes in builtin files
(mostly exec_cmd.h).

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-22 10:16:54 -07:00
Junio C Hamano a91df69cbb Merge branch 'mm/maint-log-n-with-diff-filtering'
* mm/maint-log-n-with-diff-filtering:
  log: fix --max-count when used together with -S or -G
2011-03-19 23:25:38 -07:00
Junio C Hamano bcd5461a35 Merge branch 'js/rerere-forget-always-take-pathspec'
* js/rerere-forget-always-take-pathspec:
  rerere forget: deprecate invocation without pathspec
2011-03-19 23:24:48 -07:00
Junio C Hamano 32b31ab7f3 Merge branch 'uk/ls-remote-in-get-remote-url'
* uk/ls-remote-in-get-remote-url:
  git-request-pull: open-code the only invocation of get_remote_url
  get_remote_url(): use the same data source as ls-remote to get remote urls
2011-03-19 23:24:34 -07:00
Junio C Hamano f4784b3eab Merge branch 'jn/status-translatable'
* jn/status-translatable:
  commit, status: use status_printf{,_ln,_more} helpers
  commit: refer to commit template as s->fp
  wt-status: add helpers for printing wt-status lines

Conflicts:
	builtin/commit.c
2011-03-19 23:24:19 -07:00
Junio C Hamano 0d7f242110 Merge branch 'jk/trace-sifter'
* jk/trace-sifter:
  trace: give repo_setup trace its own key
  add packet tracing debug code
  trace: add trace_strbuf
  trace: factor out "do we want to trace" logic
  trace: refactor to support multiple env variables
  trace: add trace_vprintf
2011-03-19 23:24:12 -07:00
Junio C Hamano 0ce6a51b43 Merge branch 'jk/merge-rename-ux'
* jk/merge-rename-ux:
  pull: propagate --progress to merge
  merge: enable progress reporting for rename detection
  add inexact rename detection progress infrastructure
  commit: stop setting rename limit
  bump rename limit defaults (again)
  merge: improve inexact rename limit warning
2011-03-19 23:23:56 -07:00
René Scharfe c41dd2fd7d grep: read patterns from stdin with -f -
Support the well-know convention of reading standard input instead of a
named file if "-" (dash) is specified.  GNU grep does the same.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-19 21:46:52 -07:00
Carlos Martín Nieto e2a57aac8a Name make_*_path functions more accurately
Rename the make_*_path functions so it's clearer what they do, in
particlar make clear what the differnce between make_absolute_path and
make_nonrelative_path is by renaming them real_path and absolute_path
respectively. make_relative_path has an understandable name and is
renamed to relative_path to maintain the name convention.

The function calls have been replaced 1-to-1 in their usage.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-17 16:08:30 -07:00
Junio C Hamano b2f6eab402 Merge branch 'maint'
* maint:
  Prepare draft release notes to 1.7.4.2
  gitweb: highlight: replace tabs with spaces
  make_absolute_path: return the input path if it points to our buffer
  valgrind: ignore SSE-based strlen invalid reads
  diff --submodule: split into bite-sized pieces
  cherry: split off function to print output lines
  branch: split off function that writes tracking info and commit subject
  standardize brace placement in struct definitions
  compat: make gcc bswap an inline function
  enums: omit trailing comma for portability

Conflicts:
	RelNotes
2011-03-16 16:59:30 -07:00
Junio C Hamano afb497d472 Merge branch 'jn/maint-commit-missing-template' into maint
* jn/maint-commit-missing-template:
  commit: error out for missing commit message template
2011-03-16 16:47:26 -07:00
Junio C Hamano 43c1b6efb8 Merge branch 'lt/rename-no-extra-copy-detection' into maint
* lt/rename-no-extra-copy-detection:
  diffcore-rename: improve estimate_similarity() heuristics
  diffcore-rename: properly honor the difference between -M and -C
  for_each_hash: allow passing a 'void *data' pointer to callback
2011-03-16 16:47:26 -07:00
Junio C Hamano 8209b7fb9b Merge branch 'jk/fail-null-clone' into maint
* jk/fail-null-clone:
  clone: die when trying to clone missing local path
2011-03-16 16:47:26 -07:00
Junio C Hamano 61a6f1faec Merge branch 'jh/push-default-upstream-configname' into maint
* jh/push-default-upstream-configname:
  push.default: Rename 'tracking' to 'upstream'
2011-03-16 16:47:26 -07:00
Junio C Hamano 7633a5ab9a Merge branch 'mg/placeholders-are-lowercase' into maint
* mg/placeholders-are-lowercase:
  Make <identifier> lowercase in Documentation
  Make <identifier> lowercase as per CodingGuidelines
  Make <identifier> lowercase as per CodingGuidelines
  Make <identifier> lowercase as per CodingGuidelines
  CodingGuidelines: downcase placeholders in usage messages
2011-03-16 16:47:25 -07:00
Junio C Hamano bd2700dbdf Merge branch 'mg/patch-id' into maint
* mg/patch-id:
  git-patch-id: do not trip over "no newline" markers
  git-patch-id: test for "no newline" markers
2011-03-16 16:47:25 -07:00
Junio C Hamano 5b8aac32fb Merge branch 'js/maint-merge-use-prepare-commit-msg-hook' into maint
* js/maint-merge-use-prepare-commit-msg-hook:
  merge: honor prepare-commit-msg hook
2011-03-16 16:47:25 -07:00
Jonathan Nieder a3a32e7f08 cherry: split off function to print output lines
Readers uninterested in the details of "git cherry"'s output format
can see

	print_commit('-', commit, verbose, abbrev);

and ignore the details.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16 12:54:44 -07:00
Jonathan Nieder 6e0332ec3e branch: split off function that writes tracking info and commit subject
Introduce a add_verbose_info function that takes care of adding

 - an abbreviated object name;
 - a summary of the form [ahead x, behind y] of the relationship
   to the corresponding upstream branch;
 - a one line commit subject

for the tip commit of a branch, for use in "git branch -v" output.

No functional change intended.  This just unindents the code a little
and makes it easier to skip on first reading.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16 12:52:15 -07:00
Jonathan Nieder 9cba13ca5d standardize brace placement in struct definitions
In a struct definitions, unlike functions, the prevailing style is for
the opening brace to go on the same line as the struct name, like so:

 struct foo {
	int bar;
	char *baz;
 };

Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many
matches as 'struct [a-z_]*$'.

Linus sayeth:

 Heretic people all over the world have claimed that this inconsistency
 is ...  well ...  inconsistent, but all right-thinking people know that
 (a) K&R are _right_ and (b) K&R are right.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-16 12:49:02 -07:00
Junio C Hamano bde7f7389f Merge branch 'mm/push-default-advice'
* mm/push-default-advice:
  push: better error message when no remote configured
  push: better error messages when push.default = tracking
2011-03-15 14:22:55 -07:00
Junio C Hamano ccf6d62d1e Merge branch 'jc/checkout-orphan-warning'
* jc/checkout-orphan-warning:
  commit: give final warning when reattaching HEAD to leave commits behind
2011-03-15 14:22:16 -07:00
Junio C Hamano 8506588107 Merge branch 'jc/maint-apply-report-offset'
* jc/maint-apply-report-offset:
  apply -v: show offset count when patch did not apply exactly
2011-03-15 14:22:02 -07:00
Junio C Hamano af2b1848cc Merge branch 'jc/maint-apply-no-double-patch'
* jc/maint-apply-no-double-patch:
  apply: do not patch lines that were already patched
2011-03-15 14:22:00 -07:00
Junio C Hamano 66ecd2d053 Merge branch 'js/cherry-pick-usability'
* js/cherry-pick-usability:
  Teach commit about CHERRY_PICK_HEAD
  bash: teach __git_ps1 about CHERRY_PICK_HEAD
  Introduce CHERRY_PICK_HEAD
  t3507: introduce pristine-detach helper
2011-03-09 15:56:17 -08:00
Matthieu Moy 251df09be3 log: fix --max-count when used together with -S or -G
The --max-count limit is implemented by counting revisions in
get_revision(), but the -S and -G take effect later when running diff.
Hence "--max-count=10 -Sfoo" meant "examine the 10 first revisions, and
out of them, show only those changing the occurences of foo", not "show 10
revisions changing the occurences of foo".

In case the commit isn't actually shown, cancel the decrement of
max_count.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-09 14:28:24 -08:00
Jonathan Nieder b926c0d10d commit, status: use status_printf{,_ln,_more} helpers
wt-status code is used to provide a reminder of changes included and
not included for the commit message template opened in the operator's
text editor by "git commit".  Therefore each line of its output begins
with the comment character "#":

	# Please enter the commit message for your changes. Lines starting

Use the new status_printf{,_ln,_more} functions to take care of adding
"#" to the beginning of such status lines automatically.  Using these
will have two advantages over the current code:

 - The obvious one is to force separation of the "#" from the
   translatable part of the message when git learns to translate its
   output.

 - Another advantage is that this makes it easier for us to drop "#"
   prefix in "git status" output in later versions of git if we want
   to.

Explained-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-08 12:12:43 -08:00
Jonathan Nieder 37f3012ff2 commit: refer to commit template as s->fp
Instead of maintaining a local variable for it, use s->fp to keep
track of where the commit message template should be written.

This prepares us to take advantage of the status_printf functions,
which use a struct wt_status instead of a FILE pointer to determine
where to send their output.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-08 12:12:43 -08:00
Jeff King bbc30f9963 add packet tracing debug code
This shows a trace of all packets coming in or out of a given
program. This can help with debugging object negotiation or
other protocol issues.

To keep the code changes simple, we operate at the lowest
level, meaning we don't necessarily understand what's in the
packets. The one exception is a packet starting with "PACK",
which causes us to skip that packet and turn off tracing
(since the gigantic pack data will not be interesting to
read, at least not in the trace format).

We show both written and read packets. In the local case,
this may mean you will see packets twice (written by the
sender and read by the receiver). However, for cases where
the other end is remote, this allows you to see the full
conversation.

Packet tracing can be enabled with GIT_TRACE_PACKET=<foo>,
where <foo> takes the same arguments as GIT_TRACE.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-08 12:12:04 -08:00
Junio C Hamano 334f8cb22a apply -v: show offset count when patch did not apply exactly
When the line number the patch intended to touch does not match
the line in the version being patched, GNU patch reports that
it applied the hunk at a different line number, with how big an
offset.

Teach "git apply" to do the same under --verbose option.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-06 14:02:45 -08:00
Junio C Hamano 07873dc5dd Merge branch 'maint'
* maint:
  Documentation: fix a typo in git-apply.txt
  init: remove unnecessary check
2011-03-04 15:02:45 -08:00
Junio C Hamano 5cb3c9b7df Merge branch 'jn/maint-commit-missing-template'
* jn/maint-commit-missing-template:
  commit: error out for missing commit message template
2011-03-04 15:02:27 -08:00
Junio C Hamano 24161eb036 Merge branch 'lt/rename-no-extra-copy-detection'
* lt/rename-no-extra-copy-detection:
  diffcore-rename: improve estimate_similarity() heuristics
  diffcore-rename: properly honor the difference between -M and -C
  for_each_hash: allow passing a 'void *data' pointer to callback
2011-03-04 15:02:27 -08:00
Junio C Hamano 51aca1665b Merge branch 'jk/fail-null-clone'
* jk/fail-null-clone:
  clone: die when trying to clone missing local path
2011-03-04 15:02:26 -08:00
Junio C Hamano 63bf941e5a Merge branch 'jc/grep--no-index-pathspec-fix'
* jc/grep--no-index-pathspec-fix:
  grep --no-index: honor pathspecs correctly
2011-03-04 15:02:26 -08:00
Junio C Hamano 9d158601b3 apply: do not patch lines that were already patched
When looking for a place to apply a hunk, we used to check lines that
match the preimage of it, starting from the line that the patch wants to
apply the hunk at, looking forward and backward with increasing offsets
until we find a match.

Colin Guthrie found an interesting case where this misapplied a patch that
wanted to touch a preimage that consists of

                        }
                }

                return 0;
        }

which is a rather unfortunately common pattern.

The target version of the file originally had only one such location, but
the hunk immediately before that created another instance of such block of
lines, and find_pos() happily reported that the preimage of the hunk
matched what it wanted to modify.

Oops.

By marking the lines application of earlier hunks touched and preventing
match_fragment() from considering them as a match with preimage of other
hunks, we can reduce such an accident.

I also considered to teach apply_one_fragment() to take the offset we have
found while applying the previous hunk into account when looking for a
match with find_pos(), but dismissed that approach, because it would
sometimes work better but sometimes worse, depending on the difference
between the version the patch was created against and the version the
patch is being applied.

This does _not_ prevent misapplication of patches to a file that has many
similar looking blocks of lines and a preimage cannot identify which one
of them should be applied.  For that, we would need to scan beyond the
first match in find_pos(), and issue a warning (or error out).  That will
be a separate topic.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-04 14:47:18 -08:00
Nguyễn Thái Ngọc Duy b31d20227a init: remove unnecessary check
git_dir must always be non-NULL so "if (git_dir)" is unnecessary.
Before this code, if git_dir == NULL, it will default to
DEFAULT_GIT_DIR_ENVIRONMENT.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-03 15:45:10 -08:00
Matthieu Moy a3f5e7a32e push: better error message when no remote configured
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-02 15:34:26 -08:00
Matthieu Moy ec8460bd91 push: better error messages when push.default = tracking
A common scenario is to create a new branch and push it (checkout -b &&
push [--set-upstream]). In this case, the user was getting "The current
branch %s has no upstream branch.", which doesn't help much.

Provide the user a command to push the current branch. To avoid the
situation in the future, suggest --set-upstream.

While we're there, also improve the error message in the "detached HEAD"
case. We mention explicitly "detached HEAD" since this is the keyword to
look for in documentations.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-02 15:34:23 -08:00
Uwe Kleine-König 45781adb9a get_remote_url(): use the same data source as ls-remote to get remote urls
The formerly implemented algorithm behaved differently to
remote.c:remote_get() at least for remotes that contain a slash.  While the
former just assumes a/b is a path the latter checks the config for
remote."a/b" first which is more reasonable.

This removes the last user of git-parse-remote.sh:get_data_source(), so
this function is removed.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-02 12:26:53 -08:00
Johannes Sixt 5d2c3b0160 rerere forget: deprecate invocation without pathspec
rerere forget is a destructive command. When invoked without a path, it
operates on the current directory, potentially deleting many recorded
conflict resolutions.

To make the command safer, a path must be specified as of git 1.8.0. Until
then, give users time to write 'git rerere forget .' if they really mean
the entire current directory.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-03-02 12:26:18 -08:00
Junio C Hamano 8978166e53 Merge branch 'jh/push-default-upstream-configname'
* jh/push-default-upstream-configname:
  push.default: Rename 'tracking' to 'upstream'
2011-02-27 21:58:31 -08:00
Junio C Hamano fbfeeaf294 Merge branch 'lp/config-vername-check'
* lp/config-vername-check:
  Disallow empty section and variable names
  Sanity-check config variable names
2011-02-27 21:58:31 -08:00
Junio C Hamano ecd75ddb6f Merge branch 'mg/placeholders-are-lowercase'
* mg/placeholders-are-lowercase:
  Make <identifier> lowercase in Documentation
  Make <identifier> lowercase as per CodingGuidelines
  Make <identifier> lowercase as per CodingGuidelines
  Make <identifier> lowercase as per CodingGuidelines
  CodingGuidelines: downcase placeholders in usage messages
2011-02-27 21:58:30 -08:00
Junio C Hamano c8cdbf2bad Merge branch 'mg/patch-id'
* mg/patch-id:
  git-patch-id: do not trip over "no newline" markers
  git-patch-id: test for "no newline" markers
2011-02-27 21:58:30 -08:00
Junio C Hamano 66a6a31420 Merge branch 'mz/rerere-remaining'
* mz/rerere-remaining:
  mergetool: don't skip modify/remove conflicts
  rerere "remaining"
2011-02-27 21:58:30 -08:00
Junio C Hamano 11e4b4fa49 Merge branch 'js/maint-merge-use-prepare-commit-msg-hook'
* js/maint-merge-use-prepare-commit-msg-hook:
  merge: honor prepare-commit-msg hook
2011-02-27 21:58:30 -08:00
Junio C Hamano fc7ae9c156 Merge branch 'nd/hash-object-sanity'
* nd/hash-object-sanity:
  Make hash-object more robust against malformed objects

Conflicts:
	cache.h
2011-02-27 21:58:30 -08:00
Junio C Hamano c0791f365e Merge branch 'uk/checkout-ambiguous-ref'
* uk/checkout-ambiguous-ref:
  Rename t2019 with typo "amiguous" that meant "ambiguous"
  checkout: rearrange update_refs_for_switch for clarity
  checkout: introduce --detach synonym for "git checkout foo^{commit}"
  checkout: split off a function to peel away branchname arg
  checkout: fix bug with ambiguous refs

Conflicts:
	builtin/checkout.c
2011-02-27 21:58:29 -08:00
Junio C Hamano d5c87a802d Merge branch 'nd/struct-pathspec'
* nd/struct-pathspec: (22 commits)
  t6004: add pathspec globbing test for log family
  t7810: overlapping pathspecs and depth limit
  grep: drop pathspec_matches() in favor of tree_entry_interesting()
  grep: use writable strbuf from caller for grep_tree()
  grep: use match_pathspec_depth() for cache/worktree grepping
  grep: convert to use struct pathspec
  Convert ce_path_match() to use match_pathspec_depth()
  Convert ce_path_match() to use struct pathspec
  struct rev_info: convert prune_data to struct pathspec
  pathspec: add match_pathspec_depth()
  tree_entry_interesting(): optimize wildcard matching when base is matched
  tree_entry_interesting(): support wildcard matching
  tree_entry_interesting(): fix depth limit with overlapping pathspecs
  tree_entry_interesting(): support depth limit
  tree_entry_interesting(): refactor into separate smaller functions
  diff-tree: convert base+baselen to writable strbuf
  glossary: define pathspec
  Move tree_entry_interesting() to tree-walk.c and export it
  tree_entry_interesting(): remove dependency on struct diff_options
  Convert struct diff_options to use struct pathspec
  ...
2011-02-27 21:17:36 -08:00